I am trying to force the linker (ld from XC32) to place the same executable code in two different sections of flash.
The application is so that the code can be run as a standalone application, and also so that the reset vector can be overridden by a bootloader which can then branch to a pseudo reset vector.
The relevant sections of my linker script are
MEMORY
{
kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x480
bootload_boot_mem : ORIGIN = 0x9D1F0000, LENGTH = 0x480
}
SECTIONS
{
.reset 0xBFC00000 :
{
KEEP(*(.reset))
} > kseg1_boot_mem
.bootloadreset 0x9D1F0000 :
{
KEEP(*(.reset))
} > bootload_boot_mem
}
Using this the area at 0xBFC00000 is populated as expected, but nothing gets placed at 0x9D1F0000. I have tried passing the option --no-gc-sections to the linker but it doesn't seem to make any difference.
My question is: Is it possible to force the linker to put the same code into 2 different sections, and how to do so?