i386 and x86_64 TLSDESC relocations to local symbols broken in gold
Alexandre Oliva
aoliva@redhat.com
Fri Sep 12 00:54:00 GMT 2008
Hi,
I finally got 'round to investigating how _TLS_MODULE_BASE_ could
possibly be working on gold, since it hadn't been fixed along the
lines of the fix that I installed in bfd on 2008-07-28. Turns out it
doesn't, and it's even more broken than I'd expected.
I found out it generates bad TLSDESC relocations in dynamic libraries,
referencing local symbols. The relocations that used to refer to
local symbols are adjusted to refer to .tdata or .tbss symbols, but
this doesn't work: the value of these section symbols is not an offset
into the TLS segment like regular TLS symbols, but rather an absolute
offset within the executable, so the computations are all way off.
BFD generates an *ABS*+<dtpoff> relocation for these cases, as
expected. I guess I should mention this in the specs... Ideally,
libc run-time should be able to cope with section symbols, but it
doesn't, and I'm not sure how easy it would be to add this.
Furthermore, symbols that are not at offset zero in their sections are
getting what should have been the addend of the relocation in place at
the GOT entry, rather than in the addend field of the relocation, as
expected for a RELA relocation. I'm pretty sure this will cause the
addend to be completely disregarded at run-time, even if the other
problems above are fixed.
FTR, all tls*gnu2* testcases in the gold testsuite pass when the
bfd-based linker is used to link them, but tls_shared_gnu2_test fails
because of errors WRT local variables.
Anyhow, here's the patch that fixes the first of the 3 problems. I'm
not sure when I'm going to be able to get back to the other two;
pretty please beat me to it :-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gold-x86-tls-pie.patch
Type: text/x-patch
Size: 2908 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20080912/83ab8fda/attachment.bin>
-------------- next part --------------
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
FSFLA Board Member ?S? Libre! => http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
More information about the Binutils
mailing list