I'm attempting to build an XIP "Hello, world!" application for the ARM
processor. I'm compiling with -fPIC -msingle-pic-base with the default
-mpic-register=r10. The layout of the memory map is such that the
.text and .rodata are in flash memory, and the .got, .data and so
forth are loaded into RAM. r10 is loaded with the address of the .got.
I'm having trouble with string constants. The address of a string
constant is being resolved using a R_ARM_GOTOFF32 relocation. For
example...
d6: 4803 ldr r0, [pc, #12] (e4 <.text+0xe4>)
d8: 4450 add r0, sl
...
e4: ffdc ffff undefined
e4: R_ARM_GOTOFF32 .LC0
The address to the string constant is being specified as a negative
offset from the GOT. However, in this memory layout the GOT does not
immediately follow the .text section, so a negative offset from the
GOT expecting to find the .text section does not make any sense. A PC
relative relocation (R_ARM_PC24), on the other hand, should work. The
address of the string constant would be specified as a positive offset
from the program counter, rather than a negative offset from the GOT.
Is there a compiler option to force this behaviour?
Please cc me in your reply. Thanks,
Shaun