Hi
I want to create a position independent application in Keil for an EFM32 device (Cortex-M3). The application should be loaded by a bootloader. I use the ROPI option when compiling the C-code and the bootloader takes care of updating the interrupt vectors.
The problem I have is that the startup code (__main) still seems to use fixed addressing. Is there a way to make __main position independent or is there another startup function I can use?
Best regards Filip
Which is why one typically links the boot loader to run at 0x08000000, and the application to run at, say, 0x08004000 and then relocate the vector table (SCB->VTOR) and jump to the new SP/PC
Alternately you can take your startup.s (or whatever) and park BSS initialization pointers in there, or via the scatter file (linker script), in a fashion your boot loader can fix up. This does however seem an unnecessary amount of work for a simple boot loader / app pairing.
You could implement your own C Runtime startup code to replace __main,etc and jump directly to main() once you've initialized the environment/arena correctly.
Do you have multiple applications driving the address independence quest?