Trying to load position independent code on cortex-m3

前端 未结 2 1315
遥遥无期
遥遥无期 2020-12-13 22:18

I have an embedded application which will have a bootloader which will decide to run 1 of two applications directly from internal flash. I am trying to make these apps posi

2条回答
  •  甜味超标
    2020-12-13 22:24

    I finally got it working. It looks like I need to do the following: All code needs to be complied with -fpic (previously I was trying -fpie)

    Also I had my linker script needed modification. I was forcing the GOT into the sram section and it was located after the dynamic section which was in flash. Looks like everything works properly if the GOT section is located prior to the dynamic section in the flash. Not sure why this matters but it seemed to fix everything - prior to this it was as if the code did not locate the GOT properly since the GOT had the correct values stored in it but the address of all my variables were incorrect.

提交回复
热议问题