This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
sparc TPOFF handling in GOLD
- From: David Miller <davem at davemloft dot net>
- To: iant at google dot com
- Cc: binutils at sourceware dot org
- Date: Tue, 09 Feb 2010 23:37:01 -0800 (PST)
- Subject: sparc TPOFF handling in GOLD
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!