diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-02-15 17:47:09 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-02-15 17:47:09 -0800 |
commit | ead47b56aac1d327fa4788b12e53d04c3eafb198 (patch) | |
tree | f931ed220b090f5bb36e9a7634f44d924eecbec5 | |
parent | 48cb36465251f4b44797ef3bdfe446ef58e728cb (diff) | |
download | syslinux-ead47b56aac1d327fa4788b12e53d04c3eafb198.tar.gz |
core: separate bcopyxx code and data; use linker-generated symbols
Separate out bcopyxx code and data, and use linker-generated barrier
symbols instead of inline label hacks. This makes it possible to link
code into the bcopyxx area if need be.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | core/bcopyxx.inc | 36 | ||||
-rw-r--r-- | core/comboot.inc | 3 | ||||
-rw-r--r-- | core/layout.inc | 6 | ||||
-rw-r--r-- | core/syslinux.ld | 22 |
4 files changed, 39 insertions, 28 deletions
diff --git a/core/bcopyxx.inc b/core/bcopyxx.inc index abaafa75..c669b7a8 100644 --- a/core/bcopyxx.inc +++ b/core/bcopyxx.inc @@ -29,9 +29,8 @@ ; bits 32 - section .bcopyxx + section .bcopyxx.text align 16 -bcopyxx_start equ $ ; ; pm_bcopy: ; @@ -212,17 +211,18 @@ pm_shuffle: lea edx,[edi+ecx+15] ; EDX <- where to relocate our code to and edx,~15 ; Align 16 to benefit the GDT call pm_bcopy - mov edi,edx - mov esi,bcopyxx_start - mov ecx,bcopyxx_dwords - lea eax,[edx+.safe-bcopyxx_start] ; Resume point + mov esi,__bcopyxx_start ; Absolute source address + mov edi,edx ; Absolute target address + sub edx,esi ; EDX <- address delta + mov ecx,__bcopyxx_dwords + lea eax,[edx+.safe] ; Resume point ; Relocate this code rep movsd jmp eax ; Jump to safe location .safe: ; Give ourselves a safe stack - lea esp,[edx+bcopyxx_stack+bcopyxx_end-bcopyxx_start] - add edx,bcopy_gdt-bcopyxx_start + lea esp,[edx+bcopyxx_stack+__bcopyxx_end] + add edx,bcopy_gdt ; EDX <- new GDT mov [edx+2],edx ; GDT self-pointer lgdt [edx] ; Switch to local GDT @@ -266,9 +266,7 @@ pm_shuffle_16: mov ss,edx jmp PM_CS16:0 - align 4 -RM_IDT_ptr: dw 0FFFFh ; Length (nonsense, but matches CPU) - dd 0 ; Offset + section .bcopyxx.data alignz 16 ; GDT descriptor entry @@ -303,16 +301,6 @@ bcopy_gdt: dd 00cf9300h ; present, dpl 0, cover all 4G bcopy_gdt_size: equ $-bcopy_gdt - - alignz 4 -bcopyxx_end equ $ ; *Must* be dword-aligned! -bcopyxx_len equ $-bcopyxx_start -bcopyxx_dwords equ bcopyxx_len >> 2 - -bcopyxx_stack equ 128 ; We want this much stack - ; The +15 is for alignment -bcopyxx_safe equ bcopyxx_len + bcopyxx_stack + 15 - ; ; Space for a dummy task state segment. It should never be actually ; accessed, but just in case it is, point to a chunk of memory that @@ -320,5 +308,11 @@ bcopyxx_safe equ bcopyxx_len + bcopyxx_stack + 15 ; DummyTSS equ 0x580 + align 4 +RM_IDT_ptr: dw 0FFFFh ; Length (nonsense, but matches CPU) + dd 0 ; Offset + +bcopyxx_stack equ 128 ; We want this much stack + bits 16 section .text16 diff --git a/core/comboot.inc b/core/comboot.inc index 6a4c9b9c..74ec55dc 100644 --- a/core/comboot.inc +++ b/core/comboot.inc @@ -944,7 +944,8 @@ comapi_closedir: ; INT 22h AX=0023h Query shuffler size ; comapi_shufsize: - mov P_CX,bcopyxx_safe + ; +15 is padding to guarantee alignment + mov P_CX,__bcopyxx_len + 15 ret ; diff --git a/core/layout.inc b/core/layout.inc index 7823b628..50998023 100644 --- a/core/layout.inc +++ b/core/layout.inc @@ -76,8 +76,9 @@ RBFG_brainfuck: resb 2048 ; Bigger than an Ethernet packet... section .init exec write progbits align=1 section .text16 exec write progbits align=1 section .textnr exec nowrite progbits align=1 - section .bcopyxx exec write progbits align=16 - section .data16 write progbits align=16 + section .bcopyxx.text exec nowrite progbits align=16 + section .bcopyxx.data noexec write progbits align=16 + section .data16 noexec write progbits align=16 section .adv write nobits align=512 @@ -96,6 +97,7 @@ RBFG_brainfuck: resb 2048 ; Bigger than an Ethernet packet... SECINFO uibss SECINFO config SECINFO replacestub + SECINFO bcopyxx SECINFO pm_code SECINFO high_clear diff --git a/core/syslinux.ld b/core/syslinux.ld index 0c709a07..df7242e3 100644 --- a/core/syslinux.ld +++ b/core/syslinux.ld @@ -125,12 +125,26 @@ SECTIONS __textnr_dwords = (__textnr_len + 3) >> 2; . = ALIGN(16); - .bcopyxx : { + __bcopyxx_start = .; + + .bcopyxx.text : { FILL(0x90909090) - __bcopyxx_start = .; - *(.bcopyxx) - __bcopyxx_end = .; + __bcopyxx_text_start = .; + *(.bcopyxx.text) + __bcopyxx_text_end = .; + } + __bcopyxx_text_len = __bcopyxx_text_end - __bcopyxx_text_start; + __bcopyxx_text_dwords = (__bcopyxx_text_len + 3) >> 2; + + .bcopyxx.data : { + __bcopyxx_data_start = .; + *(.bcopyxx.text) + __bcopyxx_data_end = .; } + __bcopyxx_data_len = __bcopyxx_data_end - __bcopyxx_data_start; + __bcopyxx_data_dwords = (__bcopyxx_data_len + 3) >> 2; + + __bcopyxx_end = .; __bcopyxx_len = __bcopyxx_end - __bcopyxx_start; __bcopyxx_dwords = (__bcopyxx_len + 3) >> 2; |