libpayload: Fix the stack and data labels

We should make sure _stack/_estack and the other labels are consistent.
And _data & _edata is also useful to clean up the sensitive data on the
data section.

BUG=b:248610274
TEST=emerge-cherry libpayload
BRANCH=none

Cq-Depend: chromium:5052462
Change-Id: I589040f4db60b35813ea9f4ba9503244bd7def00
Signed-off-by: Yi Chou <yich@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/79144
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
This commit is contained in:
Yi Chou 2023-11-18 12:12:01 +08:00 committed by Julius Werner
parent 1397fd3668
commit 32ea2abe3b
6 changed files with 33 additions and 15 deletions

View File

@ -56,4 +56,4 @@ ENDPROC(_entry)
1: 1:
.word cb_header_ptr .word cb_header_ptr
2: 2:
.word _stack .word _estack

View File

@ -40,29 +40,35 @@ SECTIONS
_start = .; _start = .;
.text : { .text : {
_text = .;
*(.text._entry) *(.text._entry)
*(.text) *(.text)
*(.text.*) *(.text.*)
_etext = .;
} }
.rodata : { .rodata : {
_rodata = .;
*(.rodata) *(.rodata)
*(.rodata.*) *(.rodata.*)
_erodata = .;
} }
.data : { .data : {
_data = .;
*(.data) *(.data)
*(.data.*) *(.data.*)
_edata = .;
} }
_edata = .;
.bss : { .bss : {
_bss = .;
*(.sbss) *(.sbss)
*(.sbss.*) *(.sbss.*)
*(.bss) *(.bss)
*(.bss.*) *(.bss.*)
*(COMMON) *(COMMON)
_ebss = .;
/* Stack and heap */ /* Stack and heap */
@ -72,10 +78,10 @@ SECTIONS
. = ALIGN(16); . = ALIGN(16);
_eheap = .; _eheap = .;
_estack = .; _stack = .;
. += CONFIG_LP_STACK_SIZE; . += CONFIG_LP_STACK_SIZE;
. = ALIGN(16); . = ALIGN(16);
_stack = .; _estack = .;
} }
_end = .; _end = .;

View File

@ -55,4 +55,4 @@ ENDPROC(_entry)
1: 1:
.quad cb_header_ptr .quad cb_header_ptr
2: 2:
.quad _stack .quad _estack

View File

@ -40,31 +40,37 @@ SECTIONS
_start = .; _start = .;
.text : { .text : {
_text = .;
*(.text._entry) *(.text._entry)
*(.text) *(.text)
*(.text.*) *(.text.*)
_etext = .;
} }
.rodata : { .rodata : {
_rodata = .;
*(.rodata) *(.rodata)
*(.rodata.*) *(.rodata.*)
_erodata = .;
} }
.data : { .data : {
_data = .;
*(.data) *(.data)
*(.data.*) *(.data.*)
_edata = .;
} }
_edata = .;
.bss : { .bss : {
*(.ttb_buffer) *(.ttb_buffer)
_bss = .;
*(.sbss) *(.sbss)
*(.sbss.*) *(.sbss.*)
*(.bss) *(.bss)
*(.bss.*) *(.bss.*)
*(COMMON) *(COMMON)
_ebss = .;
/* Stack and heap */ /* Stack and heap */
@ -74,10 +80,10 @@ SECTIONS
. = ALIGN(16); . = ALIGN(16);
_eheap = .; _eheap = .;
_estack = .; _stack = .;
. += CONFIG_LP_STACK_SIZE; . += CONFIG_LP_STACK_SIZE;
. = ALIGN(16); . = ALIGN(16);
_stack = .; _estack = .;
} }
_end = .; _end = .;

View File

@ -73,7 +73,7 @@ _init:
/* Store current stack pointer and set up new stack. */ /* Store current stack pointer and set up new stack. */
movl %esp, %eax movl %esp, %eax
movl $_stack, %esp movl $_estack, %esp
pushl %eax pushl %eax
/* Enable special x86 functions if present. */ /* Enable special x86 functions if present. */

View File

@ -39,29 +39,35 @@ SECTIONS
_start = .; _start = .;
.text : { .text : {
_text = .;
*(.text._entry) *(.text._entry)
*(.text) *(.text)
*(.text.*) *(.text.*)
_etext = .;
} }
.rodata : { .rodata : {
_rodata = .;
*(.rodata) *(.rodata)
*(.rodata.*) *(.rodata.*)
_erodata = .;
} }
.data : { .data : {
_data = .;
*(.data) *(.data)
*(.data.*) *(.data.*)
_edata = .;
} }
_edata = .;
.bss : { .bss : {
_bss = .;
*(.sbss) *(.sbss)
*(.sbss.*) *(.sbss.*)
*(.bss) *(.bss)
*(.bss.*) *(.bss.*)
*(COMMON) *(COMMON)
_ebss = .;
/* Stack and heap */ /* Stack and heap */
@ -71,10 +77,10 @@ SECTIONS
. = ALIGN(16); . = ALIGN(16);
_eheap = .; _eheap = .;
_estack = .; _stack = .;
. += CONFIG_LP_STACK_SIZE; . += CONFIG_LP_STACK_SIZE;
. = ALIGN(16); . = ALIGN(16);
_stack = .; _estack = .;
} }
_end = .; _end = .;