2019-01-15 01:49 PM
I'm trying to build the IO_Toggle demo for the STM32 Nucleo board as position independent. I've followed the description given in the Atollic TrueStudio for Arm User Guide (p171), and I still end up with variables and structs having problems. Has anyone run into this, and are there any suggestions / solutions? Thanks.
2019-01-15 08:34 PM
If you can describe what you needs in condensed explanation, would help (time is precious, we may not have the time to read a yellow page book size manual)
2019-01-16 05:17 AM
I've added -fPIE to the assembly, C and linker command lines (also tried -fPIC, which made no discernible difference), set up the stack pointer in Reset_Handler(). I still end up in the HardFault_Handler due to invalid address access. Is there something I'm still missing for building this as position independent code?
2019-01-16 05:37 AM
I would start by identify the specific points of failure.
I would build two binaries at different address so that I could diff them to confirm what address data continued to leak into the output.
The alternative is to have some relocation data so you can fix-up the image as you write it to flash at a specific address.
2019-01-16 05:51 AM
Code seems to be fine. I'm seeing problems with structs and variables, where they get located to areas outside of the RAM address space. I seem to have fixed a couple of the problems by defining the variables as static, but I'm not sure if that's a real fix or just hiding the problems. I also don't understand why the compiler is producing the output it is.