Skip to content

Commit

Permalink
x86, setup: Allow global variables and functions in the decompressor
Browse files Browse the repository at this point in the history
In order for global variables and functions to work in the
decompressor, we need to fix up the GOT in assembly code.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
LKML-Reference: <4C57382E.8050501@zytor.com>
  • Loading branch information
H. Peter Anvin committed Aug 2, 2010
1 parent 70b0d22 commit 22a57f5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
13 changes: 13 additions & 0 deletions arch/x86/boot/compressed/head_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ relocated:
shrl $2, %ecx
rep stosl

/*
* Adjust our own GOT
*/
leal _got(%ebx), %edx
leal _egot(%ebx), %ecx
1:
cmpl %ecx, %edx
jae 2f
addl %ebx, (%edx)
addl $4, %edx
jmp 1b
2:

/*
* Do the decompression, and jump to the new kernel..
*/
Expand Down
13 changes: 13 additions & 0 deletions arch/x86/boot/compressed/head_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,19 @@ relocated:
shrq $3, %rcx
rep stosq

/*
* Adjust our own GOT
*/
leaq _got(%rip), %rdx
leaq _egot(%rip), %rcx
1:
cmpq %rcx, %rdx
jae 2f
addq %rbx, (%rdx)
addq $8, %rdx
jmp 1b
2:

/*
* Do the decompression, and jump to the new kernel..
*/
Expand Down
6 changes: 6 additions & 0 deletions arch/x86/boot/compressed/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ SECTIONS
*(.rodata.*)
_erodata = . ;
}
.got : {
_got = .;
KEEP(*(.got.plt))
KEEP(*(.got))
_egot = .;
}
.data : {
_data = . ;
*(.data)
Expand Down

0 comments on commit 22a57f5

Please sign in to comment.