Skip to content

Commit f4c3f32

Browse files
committed
layout: Add explict .stack section
This replaces our hacky asserts and makes debugging easier. Signed-off-by: Joe Richey <[email protected]>
1 parent 7bb1d31 commit f4c3f32

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

layout.ld

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ PHDRS
99
/* Loaders like to put stuff in low memory (< 1M), so we don't use it. */
1010
ram_min = 1M;
1111
ram_max = 2M;
12-
/* Our stack grows down from ram_max. TODO: Add a guard for stack overflows. */
13-
stack_size = 64K;
1412

1513
SECTIONS
1614
{
@@ -28,16 +26,17 @@ SECTIONS
2826
.data : { *(.data .data.*) }
2927
data_size = . - data_start;
3028

31-
/* The BSS section isn't mapped from any file data. It is simply zeroed
32-
in RAM. So our file size should be computed from here. */
33-
file_size = . - ram_min;
29+
/* The BSS section isn't mapped from file data. It is just zeroed in RAM. */
3430
.bss : {
3531
bss_start = .;
3632
*(.bss .bss.*)
3733
bss_size = . - bss_start;
3834
}
3935

40-
ASSERT((. <= ram_max - stack_size), "firmware size too big for RAM region")
36+
/* Our stack grows down from ram_max. TODO: Add stack overflow guards. */
37+
stack_size = 64K;
38+
. = ram_max - stack_size;
39+
.stack (NOLOAD) : { . += stack_size; } :NONE
4140

4241
/* Match edk2's GccBase.lds DISCARD section */
4342
/DISCARD/ : {

0 commit comments

Comments
 (0)