ARM position-independent code problem
Thu Jan 31 15:04:00 GMT 2019
Hi, I'm hoping someone might be able to shed some light on this. I'm developing a bootloader for an ARM M4 core. The GCC is built into an Eclipse environment, but I'm hoping the info might be relevant. I had originally built the bootloader without the -fPIC switch, which I didn't know was an option in the builder. In the first incarnation, I used a macro to calculate the entry points into the bootloader section after it was copied to RAM. It worked, except I discovered that there were a few lines where there were absolute jumps to the code which was linked into flash. Doesn't work so well if the flash image being programmed doesn't match.
So, I learned about the -fPIC option, and I have that applied to the relevant code. I took out the macros to compute the offsets into the entry points, and I've added the .got section to the boot sector, along with the code which will run from RAM. It is entering code correctly, and it appears to be executing code correctly, but some of the accesses to static variables within the module are not coming out right. This bids the question: Is the global offset table section supposed to be relocated along with the position-independent code so it stays at the same relative location to the code? Even before using the -pic option it seemed to handle locating the static variables properly.
More information about the Gcc-help