Skip to content

layout: don't give the NOLOAD .stack section a flash LMA - #595

Merged
jrvanwhy merged 1 commit into
tock:masterfrom
AkshathaUdayashankar:stack-noload-lma
Jul 4, 2026
Merged

layout: don't give the NOLOAD .stack section a flash LMA#595
jrvanwhy merged 1 commit into
tock:masterfrom
AkshathaUdayashankar:stack-noload-lma

Conversation

@AkshathaUdayashankar

Copy link
Copy Markdown
Contributor

The .stack section is NOLOAD but used > RAM AT > FLASH. Because it precedes .data and was also assigned a flash load address, the linker reserved stack-sized space in the flash LMA layout, leaving a gap between .rodata and .data. elf2tab pads gaps between load segments, so this gap was emitted as zero bytes into the TBF, inflating the flash image for stack space that is never loaded from flash.

Drop AT > FLASH so .stack's LMA equals its RAM VMA and .data follows .rodata with no gap. rt_header uses LOADADDR(.data) and _sram_origin/_stack_top are VMAs, so ARM/RISC-V behavior should be unchanged.

The .stack section is NOLOAD but used `> RAM AT > FLASH`. Because it precedes .data and was also assigned a flash load address, the linker reserved stack-sized space in the flash LMA layout, leaving a gap between .rodata and .data. elf2tab pads gaps between load segments, so this gap was emitted as zero bytes into the TBF, inflating the flash image for stack space that is never loaded from flash.

Drop `AT > FLASH` so .stack's LMA equals its RAM VMA and .data follows .rodata with no gap. rt_header uses LOADADDR(.data) and _sram_origin/_stack_top are VMAs, so ARM/RISC-V behavior should be unchanged.

Signed-off-by: Akshatha Udayashankar <akudayas@microsoft.com>
@jrvanwhy
jrvanwhy added this pull request to the merge queue Jul 4, 2026
Merged via the queue into tock:master with commit 39c8cd8 Jul 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants