Skip to content

Commit bbc32dd

Browse files
josephlrrbradford
authored andcommitted
layout: Cleanup and comment linker script
Signed-off-by: Joe Richey <joerichey@google.com>
1 parent 2b5905d commit bbc32dd

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

layout.ld

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ENTRY(ram64_start)
22

33
PHDRS
44
{
5-
program PT_LOAD FILEHDR PHDRS ;
5+
ram PT_LOAD FILEHDR PHDRS ;
66
}
77

88
/* Loaders like to put stuff in low memory (< 1M), so we don't use it. */
@@ -13,16 +13,26 @@ stack_size = 64K;
1313

1414
SECTIONS
1515
{
16-
/* Mapping in the program headers makes it easier to mmap the whole file. */
16+
/* Mapping the program headers into RAM makes the file smaller. */
1717
. = ram_min;
1818
. += SIZEOF_HEADERS;
1919

20-
.rodata : { *(.rodata .rodata.*) } :program
21-
.text : { *(.text .text.*) } :program
22-
.data : { *(.data .data.*) } :program
23-
.bss : { *(.bss .bss.*) } :program
20+
/* These sections are mapped into RAM from the file. Omitting :ram from
21+
later sections avoids emitting empty sections in the final binary. */
22+
data_start = .;
23+
.rodata : { *(.rodata .rodata.*) } :ram
24+
.text : { *(.text .text.*) }
25+
.data : { *(.data .data.*) }
26+
data_size = . - data_start;
2427

25-
firmware_ram_size = . - ram_min;
28+
/* The BSS section isn't mapped from any file data. It is simply zeroed
29+
in RAM. So our file size should be computed from here. */
30+
file_size = . - ram_min;
31+
.bss : {
32+
bss_start = .;
33+
*(.bss .bss.*)
34+
bss_size = . - bss_start;
35+
}
2636

2737
ASSERT((. <= ram_max - stack_size), "firmware size too big for RAM region")
2838

0 commit comments

Comments
 (0)