[tip:x86/setup] x86, setup: Allow global variables and functions in the decompressor

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: tip-bot for H. Peter Anvin
Date: Monday, August 2, 2010 - 8:30 pm

Commit-ID:  22a57f5896df218356bae6203dfaf04bcfd6c88c
Gitweb:     http://git.kernel.org/tip/22a57f5896df218356bae6203dfaf04bcfd6c88c
Author:     H. Peter Anvin <hpa@linux.intel.com>
AuthorDate: Mon, 2 Aug 2010 15:34:44 -0700
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Mon, 2 Aug 2010 15:34:44 -0700

x86, setup: Allow global variables and functions in the decompressor

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>
---
 arch/x86/boot/compressed/head_32.S     |   13 +++++++++++++
 arch/x86/boot/compressed/head_64.S     |   13 +++++++++++++
 arch/x86/boot/compressed/vmlinux.lds.S |    6 ++++++
 3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index f543b70..67a655a 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), %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..
  */
 	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..52f85a1 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), %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..
  */
 	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)
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[tip:x86/setup] x86, setup: Allow global variables and fun ..., tip-bot for H. Peter ..., (Mon Aug 2, 8:30 pm)
[tip:x86/setup] x86, setup: reorganize the early console setup, tip-bot for Yinghai Lu, (Mon Aug 2, 8:31 pm)
[tip:x86/setup] x86, setup: move isdigit.h to ctype.h, hea ..., tip-bot for H. Peter ..., (Mon Aug 2, 9:10 pm)