cancel
Showing results for 
Search instead for 
Did you mean: 

Position Independent Code Support(PIC) on STM32F479NI

jitheesh
Associate
Posted on November 16, 2016 at 13:18

We are trying to implement Position Independent Code (PIC) on STM32F479NI. We have used -fpic and -msingle-pic-base options while compiling the code.

Initially we wanted prove that this PIC concept will work on a basic level with gnu-gcc toolchain. For this reason we have loaded the code into exact location where it should be without PIC support(in STM32F479NI it will be 0x80000 the flash address). But this doesn't seems to be working. I am wondering what could go wrong if you are placing PIC in same location as that of non-PIC.  am i missing something which is why everything going wrong?

Could somebody give some insight in to the proper method to be followed for Position Independent Code implementation. Any help is appreciated.

Thanks & Regards,

Jitheesh Surendran
2 REPLIES 2
Posted on November 16, 2016 at 16:06

..am i missing something which is why everything going wrong?

The vector table contains absolute addresses?

So, either fix it to the correct address during the write to flash by the loader, or place the vector table at the base of RAM, and have the loader copy a fixed up version of the loader into RAM, and have the app not use that small block of RAM.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
jitheesh
Associate
Posted on November 17, 2016 at 06:49

Hi Clive,

So are you saying that vector table will contain the absolute addresses to the actual IRQ_handlers?

Even in this case when we load the code to base of flash 0x80000(which is the on mentioned in linker script) eventhough it compiled with PIC option it should work, right?

Without PIC option enabled code should be at 0x80000 (flash addr), SO even after enabling PIC option we are loading at the same addrees(0x80000). So all the adress reference from linker will match with absolute addresses, right?