[4.7/4.8 build] Fix R_386_TLS_LDM_PLT detection

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Thu Mar 8 13:21:00 GMT 2012


When checking Solaris/x86 testsuite results on mainline and 4.7 branch,
I noticed that on Solaris 10/x86 with Sun as/ld, several 32-bit TLS LD
execution tests were failing:

FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o execute -O2 -flto -flto-partition=none 
FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o execute -O2 -flto -flto-partition=1to1 
FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o execute -O2 -flto

FAIL: gcc.dg/torture/tls/run-ld.c  -O1  execution test

and many more.

FAIL: gcc.dg/torture/tls/thr-init-2.c  -O2  -fpic  execution test

and some more.

I've started with an investigation of first failure and found that it
died with SIGILL.  It turned out that the linker mis-transformed

        leal    value.1356@tlsldm(%ebx), %eax
        call    ___tls_get_addr@plt

into

   0x80508da <main+42>: mov    %gs:0x0,%eax
   0x80508e0 <main+48>: call   0x80508e1 <main+49>
   0x80508e5 <main+53>: test   %edi,%edi

which ultimately is no wonder since before Solaris 11, Sun ld cannot
properly handle the @tlsldm reloc.  There's code in place to detect
as/ld support for @tlsldmplt instead (which is the only TLS LD support
present in Sun as/ld before Solaris 11), but the linker part of that
doesn't work:

$ echo 'call    tls_ld@tlsldmplt' > conftest.s
$ as conftest.s -o conftest.o
$ ld -o conftest conftest.o -G
ld: fatal: relocation error: R_386_TLS_LDM_PLT: file conftest.o: symbol tls_ld: bound to: conftest.o: relocation illegal when not bound to object being created

I've no idea how this can ever have worked (perhaps I just didn't notice
the failure on Solaris 11 where ld support for TLS relocs is
considerably richer), but the fix is trivial.

With the patch below, I've bootstrapped the 4.7 branch on
i386-pc-solaris2.{8, 9, 10, 11} with as/ld, gas/ls, and gas/gld, and
mainline on i386-pc-solaris2.1[01] with the same tool combinations.

On Solaris 8 and 9, there's no change since the native as doesn't
support @tlsldmplt, on Solaris 10, the failues with the as/ld combo are
now gone, and Solaris 11 is still fine, too.

Given that HAVE_AS_IX86_TLSLDMPLT is only use for Solaris/x86 and fixes
a stupid bug, I'd like to get this into both mainline and the 4.7
branch?

I don't need approval for mainline, but certainly for the branch.

Ok?
	Rainer


2012-03-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* configure.ac (gcc_cv_as_ix86_tlsldmplt): Add label.
	* configure: Regenerate.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: solx86-tlsldmplt-link.patch
Type: text/x-patch
Size: 524 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120308/15005dee/attachment.bin>
-------------- next part --------------


-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


More information about the Gcc-patches mailing list