Skip to content

Commit

Permalink
layout: Cleanup and comment linker script
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Richey <[email protected]>
  • Loading branch information
josephlr committed Mar 30, 2020
1 parent 4fd1677 commit 6ef27a1
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions layout.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ENTRY(ram64_start)

PHDRS
{
program PT_LOAD FILEHDR PHDRS ;
ram PT_LOAD FILEHDR PHDRS ;
}

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

SECTIONS
{
/* Mapping in the program headers makes it easier to mmap the whole file. */
/* Mapping the program headers into RAM makes the file smaller. */
. = ram_min;
. += SIZEOF_HEADERS;

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

firmware_ram_size = . - ram_min;
/* The BSS section isn't mapped from any file data. It is simply zeroed
in RAM. So our file size should be computed from here. */
file_size = . - ram_min;
.bss : {
bss_start = .;
*(.bss .bss.*)
bss_size = . - bss_start;
}

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

Expand Down

0 comments on commit 6ef27a1

Please sign in to comment.