layout: don't give the NOLOAD .stack section a flash LMA - #595
Merged
Conversation
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
approved these changes
Jul 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 > FLASHso .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.