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 

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


   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

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


2012-03-06  Rainer Orth  <r...@cebitec.uni-bielefeld.de>

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

# HG changeset patch
# Parent 92b41d77ccb58c31a969736dc5ae2da1d7ce83bd
Fix R_386_TLS_LDM_PLT detection

diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3724,7 +3724,8 @@ foo:	nop
     gcc_GAS_CHECK_FEATURE([R_386_TLS_LDM_PLT reloc],
-	[call    tls_ld@tlsldmplt],
+	[tls_ld:
+	 call    tls_ld@tlsldmplt],
 	[if test x$gcc_cv_ld != x \
 	 && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1; then

Rainer Orth, Center for Biotechnology, Bielefeld University

Reply via email to