I currently have a very rudimentary linker script, which sets the start of memory to 0x80000000, and then has the text, data, and bss sections and nothing else, as seen below:
MEMORY
{
mem: ORIGIN = 0x80000000, LENGTH = 4M
}
SECTIONS
{
.text : { *(.text) } > mem
.data : { *(.data) } > mem
.bss : { *(.bss) } > mem
}
This seems to work fine, until I try to define a static integer within a function, and to test I gave it an initialized value of 0x12345678.
The code compiles and links, and according to the map file that static variable is allocated right at the beginning of the bss section. The trouble is, it's not being assigned to 12345678, or to anything else I might try to set it to initially. The address in the output binary that it's getting assigned to actually contains the compiler info string. If I open the output binary in a hex editor, I can't find 0x12345678 anywhere, nor its endian-swapped counterpart 0x78563412.
I'm fairly certain there's something I'm missing in the linker script, but I have no idea what it could be. Does anyone know?
it will not magically set itself and the linker script is not responsible for that.
User contributions licensed under CC BY-SA 3.0