sparc TPOFF handling in GOLD
David Miller
davem@davemloft.net
Wed Feb 10 07:36:00 GMT 2010
Ian, I figured out why I was using the relative reloc
emitters for relocations other than R_SPARC_RELATIVE.
It seems to be for an issue with TPOFF{32,64} handling.
For example, when we have an IE TLS relocation for a local symbol, the
TPOFF{32,64} relocation pointing to the GOT entry needs to have an
addend with value:
value - tls_segment()->vaddr();
This is needed because the dynamic linker sets the relocation using:
*reloc_addr = sym->st_value - sym_map->l_tls_offset
+ reloc->r_addend;
Compare to i386 which, lacking addends, goes:
*reloc_addr += map->l_tls_offset - sym->st_value;
x86_64 uses addends and seems to compute the TPOFF64 relocation
similar to sparc, so I wonder how it is working there?
Anyways, way back when writing the Sparc GOLD backend I couldn't
figure out any way to get that TPOFF{32,64} addend set correctly other
than to use the relative reloc trick since that triggers the logic in
Output_reloc::write() which goes:
addend = this->rel_.symbol_value(addend);
But now that we emit DT_RELACOUNT in the dynamic section, this trick
no longer works.
Maybe I'm missing something obvious here that can be used to make this
work? Perhaps I need to use a target specific relocation?
Thanks!
More information about the Binutils
mailing list