This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: %pc relative addressing of string literals/const data
On 10/05/2010 01:55 PM, Joakim Tjernlund wrote:
> I don't do x86 or alpha so let me ask: If you run the code on an address
> != link address, will it do the right thing?
Yes of course. It wouldn't be -fpic code otherwise.
> I tested the #pragma/no #pragma on PPC and the resulting code
> was the same:
Yes of course. I said it wouldn't on PPC.
> You can get at the GOT table using PC relative addressing so why not
> strings or data in a similar fashion?
Well, I suppose you could, with the right code model. It's not
compatible with generic -fpic code without using a second base
register, which is unfortunate.
I had thought that the assembler magically recognized the
_GLOBAL_OFFSET_TABLE_ symbol (disgusting, but several assembler
ports do exactly that), but not true -- one can generate
R_PPC_REL16_{HA,LO} relocations against any symbol.
r~