Messages in this thread Patch in this message | | | Date | Mon, 02 Aug 2010 13:59:27 -0700 | From | "H. Peter Anvin" <> | Subject | Re: [PATCH -v3 2/2] x86: more early console output from compressed/misc.c |
| |
On 08/02/2010 12:35 PM, Yinghai Lu wrote: > > it seems I can not global variables in arch/x86/boot/compressed/misc.c >
I just looked at it, it's the fact that we don't relocate the GOT that is causing problems. It's relatively easy to fix: here is a patch, but in grand Linus tradition it is completely untested.
-hpa diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S index f543b70..6597aeb 100644 --- a/arch/x86/boot/compressed/head_32.S +++ b/arch/x86/boot/compressed/head_32.S @@ -124,6 +124,19 @@ relocated: rep stosl /* + * Adjust our own GOT + */ + leal _got(%ebx), %esi + leal _egot(%ebx), %edi +1: + cmpl %esi, %edi + jae 2f + addl %ebx, (%esi) + addl $4, %esi + jmp 1b +2: + +/* * Do the decompression, and jump to the new kernel.. */ leal z_extract_offset_negative(%ebx), %ebp diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index faff0dc..ef69e97 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -280,6 +280,19 @@ relocated: rep stosq /* + * Adjust our own GOT + */ + leaq _got(%rip), %rsi + leaq _egot(%rip), %rdi +1: + cmpq %rsi, %rdi + jae 2f + addq %rbx, (%rsi) + addq $8, %rsi + jmp 1b +2: + +/* * Do the decompression, and jump to the new kernel.. */ pushq %rsi /* Save the real mode argument */ diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S index 5ddabce..34d047c 100644 --- a/arch/x86/boot/compressed/vmlinux.lds.S +++ b/arch/x86/boot/compressed/vmlinux.lds.S @@ -41,6 +41,12 @@ SECTIONS *(.rodata.*) _erodata = . ; } + .got : { + _got = .; + KEEP(*(.got.plt)) + KEEP(*(.got)) + _egot = .; + } .data : { _data = . ; *(.data) | |