public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [4.7/4.8 build] Fix R_386_TLS_LDM_PLT detection
@ 2012-03-08 13:21 Rainer Orth
  2012-03-08 13:36 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Rainer Orth @ 2012-03-08 13:21 UTC (permalink / raw)
  To: gcc-patches; +Cc: Uros Bizjak, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 2470 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: solx86-tlsldmplt-link.patch --]
[-- Type: text/x-patch, Size: 524 bytes --]

# 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],
         gcc_cv_as_ix86_tlsldmplt,,,
-	[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
 	   gcc_cv_as_ix86_tlsldmplt=yes

[-- Attachment #3: Type: text/plain, Size: 144 bytes --]



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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [4.7/4.8 build] Fix R_386_TLS_LDM_PLT detection
  2012-03-08 13:21 [4.7/4.8 build] Fix R_386_TLS_LDM_PLT detection Rainer Orth
@ 2012-03-08 13:36 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2012-03-08 13:36 UTC (permalink / raw)
  To: Rainer Orth; +Cc: gcc-patches, Uros Bizjak

On Thu, Mar 08, 2012 at 02:21:18PM +0100, Rainer Orth wrote:
> 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?

Ok.

> 2012-03-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
> 
> 	* configure.ac (gcc_cv_as_ix86_tlsldmplt): Add label.
> 	* configure: Regenerate.

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-08 13:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-08 13:21 [4.7/4.8 build] Fix R_386_TLS_LDM_PLT detection Rainer Orth
2012-03-08 13:36 ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).