S32DS ARM2.2 K144xx fPic Example description.
Provided example demonstrate possibility of creation Position Independent Code using standard S32DS ARM 2.2 tools. Example code blink RGB LED using svc interrupt handler. Output picExample.bin should be loaded via restore gdb command only into existing K144 RAM area(0x1fff8000 – 20007000 for EVB board), then pc set to startup value.(see picExample_Debug_RAM_PNE_fpic Debug configuration).
Note: restore gdb command needs absolute path to *.bin file.
Example is based on standard K144 application.
Changes:
For an in-depth analysis and step-by-step guide on the topic of implementing position-independent code, please see the following blog at mcuoneclipse.com:
Hello ,
Thanks for the example . I am trying to make our current code position independant so that we can load apllication anywhere in memory .
What i need to know is that , is there a way to make it work without setting No startup or default libs ?
Your example is generating a hard fault exception could you give compiler version used or a compiled binary file ?
Thanks Mike
In order to make this work from Flash memory GOT and PLT tables must be placed in the RAM to be patched further by the app itself (not bootloader).
Once flashed to Flash memory bootloader should set PC to entry point of the application. At the very beginning it patches GOT and PLT that re in RAM. And then it switches to regular application that exploits these tables for function calls and global variables.
Here is an article which might be helpful to you:
https://www.embeddedrelated.com/showthread/comp.arch.embedded/200209-1.php
Hope it helps,
Mike