Why do you put that section in VMA?
From my understanding of linker script:
- LMA or Load Memory Address. Specifies where the section and associated data shall be loaded into memory.
- VMA or Virtual Memory Address. Specifies the virtual address for the section, which will be used during runtime by the program to access the symbols in it.
Source : tutorial link
We don’t want to place the “_user_heap_stack” symbol directly at the RAM address (0x20000000). The linker will directly put it in this position in the final binary
Using the VMA, it will be placed as a runtime instead. This doesn’t seem like the best solution
After digging:
Output command : arm-none-eabi-readelf -S
Zig build (lld):
[11] ._user_heap_stack PROGBITS 2000009c 02009c 000604 00 WA 0 0 1
Gcc build (ld):
[11] ._user_heap_stack NOBITS 200000b8 0040b8 000600 00 WA 0 0 1
The symbol is not of the same type depending on the linker. LLD and LD don’t behave the same way when it interprets the script. The `(NOLOAD)’ directive will mark a section to not be loaded at run time
The updated version of the section :
._user_heap_stack (NOLOAD):
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM
The section is used only to control the remaining memory. It will not be used in the final binary.
Solution: link