[coreboot] New patch to review for coreboot: 0ddffb2 x86: remove stack definition in linker script

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Tue Mar 19 01:58:50 CET 2013


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2785

-gerrit

commit 0ddffb26981a969f5bddafda2e91eb44e48a69de
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Wed Feb 6 15:28:40 2013 -0600

    x86: remove stack definition in linker script
    
    In order to prepare the ramstage to be linked by the rmodule linker the
    stack needs to be self-contained within the ramstage objects. The
    reasoning is that the rmodule linker provides a way to define a heap,
    but it doesn't currently have a region for the stack.
    
    The downside to this is that memory footprint of the ramstage can change
    when compared before this change. The size difference stems from the
    link ordering of the objects as the stack is now defined within
    c_start.S. The size fluctuation ranges from 0 to CONFIG_STACK_SIZE - 1
    because of the previous behavior or aligning to CONFIG_STACK_SIZE. It
    should be noted that such an alignment is unnecessary for 32-bit x86 as
    the alignment requirement for the stacks are 4 byte alignment. Also the
    memory footprint is still dominated by CONFIG_RAMTOP and CONFIG_RAMBASE.
    
    Change-Id: I63a4ddd249104bc27aff2ab6b39fc6db12b54028
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 src/arch/x86/coreboot_ram.ld | 14 --------------
 src/arch/x86/lib/c_start.S   | 36 ++++++++++++++++++++++++------------
 2 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/src/arch/x86/coreboot_ram.ld b/src/arch/x86/coreboot_ram.ld
index 7ce0367..d9f0909 100644
--- a/src/arch/x86/coreboot_ram.ld
+++ b/src/arch/x86/coreboot_ram.ld
@@ -92,20 +92,6 @@ SECTIONS
 		*(COMMON)
 	}
 	_ebss = .;
-	_end = .;
-
-	/* coreboot really "ends" here. Only heap and stack are placed after
-	 * this line.
-	 */
-
-	. = ALIGN(CONFIG_STACK_SIZE);
-
-	_stack = .;
-	.stack . : {
-		/* Reserve a stack for each possible cpu */
-		. += CONFIG_MAX_CPUS*CONFIG_STACK_SIZE;
-	}
-	_estack = .;
 
         _heap = .;
         .heap . : {
diff --git a/src/arch/x86/lib/c_start.S b/src/arch/x86/lib/c_start.S
index 9a8b4ac..295283b 100644
--- a/src/arch/x86/lib/c_start.S
+++ b/src/arch/x86/lib/c_start.S
@@ -1,5 +1,16 @@
 #include <cpu/x86/post_code.h>
 
+/* Place the stack in the bss section. It's not necessary to define it in the
+ * the linker script. */
+	.section .bss, "aw", @nobits
+.global _stack
+.global _estack
+
+.align CONFIG_STACK_SIZE
+_stack:
+.space CONFIG_MAX_CPUS*CONFIG_STACK_SIZE
+_estack:
+
 	.section ".textfirst"
 	.code32
 	.globl _start
@@ -16,19 +27,7 @@ _start:
 
 	post_code(POST_ENTRY_C_START)		/* post 13 */
 
-	/** poison the stack. Code should not count on the
-	 * stack being full of zeros. This stack poisoning
-	 * recently uncovered a bug in the broadcast SIPI
-	 * code.
-	 */
 	cld
-	leal	_stack, %edi
-	movl	$_estack, %ecx
-	subl	%edi, %ecx
-	shrl	$2, %ecx   /* it is 32 bit aligned, right? */
-	movl	$0xDEADBEEF, %eax
-	rep
-	stosl
 
 	/** clear bss, which unlike the stack is zero by definition */
 	leal	_bss, %edi
@@ -41,6 +40,19 @@ _start:
 	stosl
 .Lnobss:
 
+	/** poison the stack. Code should not count on the
+	 * stack being full of zeros. This stack poisoning
+	 * recently uncovered a bug in the broadcast SIPI
+	 * code.
+	 */
+	leal	_stack, %edi
+	movl	$_estack, %ecx
+	subl	%edi, %ecx
+	shrl	$2, %ecx   /* it is 32 bit aligned, right? */
+	movl	$0xDEADBEEF, %eax
+	rep
+	stosl
+
 	/* set new stack */
 	movl	$_estack, %esp
 



More information about the coreboot mailing list