I'm trying to understand the behaviour of the GNU linker and how sections are treated.
I'm editing the stm32_flash.ld file in this stm32 project.
When I modify the linker script to put the following as the first section:
.my_test :
{
. = ALIGN(4);
KEEP(*(.my_test))
LONG(0xdeadbeef);
. = ALIGN(4);
} >FLASH
I can see the built binary has the 0xdeadbeef as the first bytes, as I would expect.
$ od -An -tx1 -w1 -v build/program.bin | head
ef
be
ad
de
00
a0
00
20
31
5e
However, if I use the following as the first section:
.my_test :
{
. = ALIGN(8);
KEEP(*(.my_test))
FILL(0xDEADBEEF)
. = 0x8000;
} > FLASH
Then it looks like the linker completely skips this section:
$ od -An -tx1 -w1 -v build/program.bin | head
00
a0
00
20
2d
de
00
08
c1
d9
But I would expect the first 0x8000 bytes to be filled with 0xdeadbeef. Why is the linker ignoring my section?