public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
@ 2011-05-23 20:04 Rainer Orth
  2011-05-23 21:32 ` Uros Bizjak
  0 siblings, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-05-23 20:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: Uros Bizjak

As described in

	[testsuite] Provide TLS access model testcases
        http://gcc.gnu.org/ml/gcc-patches/2011-05/msg01601.html

both the 32 and 64-bit TLS GD and LD execution tests fail on Solaris 2
with Sun ld unless you have a very recent Solaris 11 version (snv_164).

This happens because the code sequences emitted by GCC don't match those
expected by Sun ld:

	32-bit x86: Thread-Local Variable Access
	http://download.oracle.com/docs/cd/E19963-01/html/819-0690/chapter8-20.html#gentextid-20367	

For GD, one needs to use call x@tlsgdplt here, but call ___tls_get_addr@plt
works, too.

For LD, one really needs call x@tlsldmplt.

The corresponding R_386_TLS_GD_PLT and R_386_TLS_LDM_PLT relocations are
not yet handled by binutils.

        x64: Thread-Local Variable Access
        http://download.oracle.com/docs/cd/E19963-01/html/819-0690/chapter8-20.html#chapter8-60

For both GD and LD, one needs to use call __tls_get_addr@plt.

The following patch handles this:

* It autoconfigures support for the @tlsgdplt and @tlsldmplt
  relocations: Sun as supports them, while gas doesn't yet.  I've got a
  patch in the works to fix this: while the gas part is easy, I have
  serious problems getting the ld side to work properly.  Unfortunately,
  I doubt the binutils maintainers will accept such partial support for
  the relocs.

* I'm using a new 'p' code to control the printing of @plt.  'P' doesn't
  work since this is needed in both PIC and non-PIC code.

Bootstrapped without regressions on i386-pc-solaris2.10.

Ok for mainline?

	Rainer


2010-12-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* configure.ac (gcc_cv_as_ix86_tlsgdplt): Check for @tlsgdplt
	(HAVE_AS_IX86_TLSGDPTL): Define.
	(gcc_cv_as_ix86_tlsldmplt): Check for @tlsldmplt.
	(HAVE_AS_IX86_TLSLDMPLT): Define.
	* configure: Regenerate.
	* config.in: Regenerate.
	* config/i386/i386.c (output_pic_addr_const): Handle code 'p' like 'P'.
	(ix86_print_operand): Handle code 'p'.
	* config/i386/i386.md (*tls_global_dynamic_32_gnu): Use @tlsgdplt
	if TARGET_SUN_TLS && HAVE_AS_IX86_TLSGDPLT.
	Use 'p' code.
	(*tls_global_dynamic_64): Use 'p' code.
	(*tls_local_dynamic_base_32_gnu): Use @tlsldmplt if TARGET_SUN_TLS
	&& HAVE_AS_IX86_TLSLDMPLT.
	Use 'p' code.
	(*tls_local_dynamic_base_64): Use 'p' code.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -13209,7 +13209,7 @@ output_pic_addr_const (FILE *file, rtx x
 	  assemble_name (file, name);
 	}
       if (!TARGET_MACHO && !(TARGET_64BIT && DEFAULT_ABI == MS_ABI)
-	  && code == 'P' && ! SYMBOL_REF_LOCAL_P (x))
+	  && (code == 'P' || code == 'p') && ! SYMBOL_REF_LOCAL_P (x))
 	fputs ("@PLT", file);
       break;
 
@@ -13917,6 +13917,7 @@ get_some_local_dynamic_name (void)
    d -- print duplicated register operand for AVX instruction.
    D -- print condition for SSE cmp instruction.
    P -- if PIC, print an @PLT suffix.
+   p -- print an @PLT suffix for Sun ld.
    X -- don't print any sort of PIC '@' suffix for a symbol.
    & -- print some in-use local-dynamic symbol name.
    H -- print a memory address offset by 8; used for sse high-parts
@@ -14122,6 +14123,7 @@ ix86_print_operand (FILE *file, rtx x, i
 	case 'x':
 	case 'X':
 	case 'P':
+	case 'p':
 	  break;
 
 	case 's':
@@ -14426,7 +14428,8 @@ ix86_print_operand (FILE *file, rtx x, i
   else if (MEM_P (x))
     {
       /* No `byte ptr' prefix for call instructions or BLKmode operands.  */
-      if (ASSEMBLER_DIALECT == ASM_INTEL && code != 'X' && code != 'P'
+      if (ASSEMBLER_DIALECT == ASM_INTEL
+	  && code != 'X' && code != 'P' && code != 'p'
 	  && GET_MODE (x) != BLKmode)
 	{
 	  const char * size;
@@ -14462,9 +14465,13 @@ ix86_print_operand (FILE *file, rtx x, i
 
       x = XEXP (x, 0);
       /* Avoid (%rip) for call operands.  */
-      if (CONSTANT_ADDRESS_P (x) && code == 'P'
+      if (CONSTANT_ADDRESS_P (x) && (code == 'P' || code == 'p')
 	  && !CONST_INT_P (x))
-	output_addr_const (file, x);
+	{
+	  output_addr_const (file, x);
+	  if (code == 'p' && TARGET_SUN_TLS)
+	    fputs ("@PLT", file);
+	}
       else if (this_is_asm_operands && ! address_operand (x, VOIDmode))
 	output_operand_lossage ("invalid constraints for operand");
       else
@@ -14521,7 +14528,7 @@ ix86_print_operand (FILE *file, rtx x, i
 	  x = const0_rtx;
 	}
 
-      if (code != 'P')
+      if (code != 'P' && code != 'p')
 	{
 	  if (CONST_INT_P (x) || GET_CODE (x) == CONST_DOUBLE)
 	    {
@@ -14542,7 +14549,11 @@ ix86_print_operand (FILE *file, rtx x, i
       else if (flag_pic || MACHOPIC_INDIRECT)
 	output_pic_addr_const (file, x, code);
       else
-	output_addr_const (file, x);
+	{
+	  output_addr_const (file, x);
+	  if (code == 'p' && TARGET_SUN_TLS)
+	    fputs ("@PLT", file);
+	}
     }
 }
 
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -53,6 +53,7 @@
 ;; d -- print duplicated register operand for AVX instruction.
 ;; D -- print condition for SSE cmp instruction.
 ;; P -- if PIC, print an @PLT suffix.
+;; p -- if Sun ld, print an @PLT suffix.
 ;; X -- don't print any sort of PIC '@' suffix for a symbol.
 ;; & -- print some in-use local-dynamic symbol name.
 ;; H -- print a memory address offset by 8; used for sse high-parts
@@ -12367,7 +12368,10 @@
 {
   output_asm_insn
     ("lea{l}\t{%a2@tlsgd(,%1,1), %0|%0, %a2@tlsgd[%1*1]}", operands);
-  return "call\t%P3";
+  if (TARGET_SUN_TLS && HAVE_AS_IX86_TLSGDPLT)
+    return "call\t%a2@tlsgdplt";
+  else
+    return "call\t%p3";
 }
   [(set_attr "type" "multi")
    (set_attr "length" "12")])
@@ -12397,7 +12401,7 @@
     ("lea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}", operands);
   fputs (ASM_SHORT "0x6666\n", asm_out_file);
   fputs ("\trex64\n", asm_out_file);
-  return "call\t%P2";
+  return "call\t%p2";
 }
   [(set_attr "type" "multi")
    (set_attr "length" "16")])
@@ -12424,7 +12428,10 @@
 {
   output_asm_insn
     ("lea{l}\t{%&@tlsldm(%1), %0|%0, %&@tlsldm[%1]}", operands);
-  return "call\t%P2";
+  if (TARGET_SUN_TLS && HAVE_AS_IX86_TLSLDMPLT)
+    return "call\t%&@tlsldmplt";
+  else
+    return "call\t%p2";
 }
   [(set_attr "type" "multi")
    (set_attr "length" "11")])
@@ -12450,7 +12457,7 @@
 {
   output_asm_insn
     ("lea{q}\t{%&@tlsld(%%rip), %%rdi|rdi, %&@tlsld[rip]}", operands);
-  return "call\t%P1";
+  return "call\t%p1";
 }
   [(set_attr "type" "multi")
    (set_attr "length" "12")])
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3653,6 +3653,20 @@ foo:	nop
         [AC_DEFINE(HAVE_AS_IX86_REP_LOCK_PREFIX, 1,
           [Define if the assembler supports 'rep <insn>, lock <insn>'.])])
 
+    gcc_GAS_CHECK_FEATURE([R_386_TLS_GD_PLT reloc],
+        gcc_cv_as_ix86_tlsgdplt,,,
+	[call    tls_gd@tlsgdplt])
+    AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLSGDPLT,
+      [`if test $gcc_cv_as_ix86_tlsgdplt = yes; then echo 1; else echo 0; fi`],
+      [Define 0/1 if your assembler supports @tlsgdplt.])
+
+    gcc_GAS_CHECK_FEATURE([R_386_TLS_LDM_PLT reloc],
+        gcc_cv_as_ix86_tlsldmplt,,,
+	[call    tls_ld@tlsldmplt])
+    AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLSLDMPLT,
+      [`if test $gcc_cv_as_ix86_tlsldmplt = yes; then echo 1; else echo 0; fi`],
+      [Define 0/1 if your assembler supports @tlsldmplt.])
+
     ;;
 
   ia64*-*-*)

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

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-23 20:04 [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld Rainer Orth
@ 2011-05-23 21:32 ` Uros Bizjak
  2011-05-24 16:42   ` Rainer Orth
  0 siblings, 1 reply; 14+ messages in thread
From: Uros Bizjak @ 2011-05-23 21:32 UTC (permalink / raw)
  To: Rainer Orth; +Cc: gcc-patches

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

On Mon, May 23, 2011 at 7:22 PM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> As described in
>
>        [testsuite] Provide TLS access model testcases
>        http://gcc.gnu.org/ml/gcc-patches/2011-05/msg01601.html
>
> both the 32 and 64-bit TLS GD and LD execution tests fail on Solaris 2
> with Sun ld unless you have a very recent Solaris 11 version (snv_164).
>
> This happens because the code sequences emitted by GCC don't match those
> expected by Sun ld:
>
>        32-bit x86: Thread-Local Variable Access
>        http://download.oracle.com/docs/cd/E19963-01/html/819-0690/chapter8-20.html#gentextid-20367
>
> For GD, one needs to use call x@tlsgdplt here, but call ___tls_get_addr@plt
> works, too.
>
> For LD, one really needs call x@tlsldmplt.
>
> The corresponding R_386_TLS_GD_PLT and R_386_TLS_LDM_PLT relocations are
> not yet handled by binutils.
>
>        x64: Thread-Local Variable Access
>        http://download.oracle.com/docs/cd/E19963-01/html/819-0690/chapter8-20.html#chapter8-60
>
> For both GD and LD, one needs to use call __tls_get_addr@plt.
>
> The following patch handles this:
>
> * It autoconfigures support for the @tlsgdplt and @tlsldmplt
>  relocations: Sun as supports them, while gas doesn't yet.  I've got a
>  patch in the works to fix this: while the gas part is easy, I have
>  serious problems getting the ld side to work properly.  Unfortunately,
>  I doubt the binutils maintainers will accept such partial support for
>  the relocs.
>
> * I'm using a new 'p' code to control the printing of @plt.  'P' doesn't
>  work since this is needed in both PIC and non-PIC code.

Since handling of "p" is not conditional (that is, controlled by some
compile flag), it is IMO better to just output correct assembly from
the insn pattern itself.  You will also output lower-case "@plt" which
is IIRC preferred by Sun assebler.

Something like attached (untested) patch.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1263 bytes --]

Index: i386.md
===================================================================
--- i386.md	(revision 174076)
+++ i386.md	(working copy)
@@ -12367,6 +12367,12 @@
 {
   output_asm_insn
     ("lea{l}\t{%a2@tlsgd(,%1,1), %0|%0, %a2@tlsgd[%1*1]}", operands);
+  if (TARGET_SUN_TLS)
+#ifdef HAVE_AS_IX86_TLSGDPLT
+    return "call\t%&@tlslgdplt";
+#else
+    return "call\t%a3@plt";
+#endif
   return "call\t%P3";
 }
   [(set_attr "type" "multi")
@@ -12397,6 +12403,8 @@
     ("lea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}", operands);
   fputs (ASM_SHORT "0x6666\n", asm_out_file);
   fputs ("\trex64\n", asm_out_file);
+  if (TARGET_SUN_TLS)
+    return "call\t%a2@plt";
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
@@ -12424,6 +12432,12 @@
 {
   output_asm_insn
     ("lea{l}\t{%&@tlsldm(%1), %0|%0, %&@tlsldm[%1]}", operands);
+  if (TARGET_SUN_TLS)
+#ifdef HAVE_AS_IX86_TLSLDMPLT
+    return "call\t%&@tlsldmplt";
+#else
+    return "call\t%a2@plt";
+#endif
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
@@ -12450,6 +12464,8 @@
 {
   output_asm_insn
     ("lea{q}\t{%&@tlsld(%%rip), %%rdi|rdi, %&@tlsld[rip]}", operands);
+  if (TARGET_SUN_TLS)
+    return "call\t%a1@plt";
   return "call\t%P1";
 }
   [(set_attr "type" "multi")

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-23 21:32 ` Uros Bizjak
@ 2011-05-24 16:42   ` Rainer Orth
  2011-05-24 16:43     ` Uros Bizjak
  0 siblings, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-05-24 16:42 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

Uros,

> Since handling of "p" is not conditional (that is, controlled by some
> compile flag), it is IMO better to just output correct assembly from
> the insn pattern itself.  You will also output lower-case "@plt" which

I think I tried something along these lines, but failed with duplicate
@plt@plt for PIC code.

> is IIRC preferred by Sun assebler.

I've never seen such an issue.

> Something like attached (untested) patch.

Unfortunately, the Solaris 10/x86 bootstrap fails in the stage1 libgomp:

/vol/gcc/src/hg/trunk/solaris/libgomp/single.c: In function 'GOMP_single_start':
/vol/gcc/src/hg/trunk/solaris/libgomp/single.c:55:1: internal compiler error: ou
tput_operand: '%&' used without any local dynamic TLS references

	Rainer

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

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-24 16:42   ` Rainer Orth
@ 2011-05-24 16:43     ` Uros Bizjak
  2011-05-24 17:19       ` Rainer Orth
  0 siblings, 1 reply; 14+ messages in thread
From: Uros Bizjak @ 2011-05-24 16:43 UTC (permalink / raw)
  To: Rainer Orth; +Cc: gcc-patches

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

On Tue, May 24, 2011 at 5:09 PM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:

>> Since handling of "p" is not conditional (that is, controlled by some
>> compile flag), it is IMO better to just output correct assembly from
>> the insn pattern itself.  You will also output lower-case "@plt" which
>
> I think I tried something along these lines, but failed with duplicate
> @plt@plt for PIC code.

Hm, there is no %P1 present, so I don't think this should be an issue.

>> is IIRC preferred by Sun assebler.
>
> I've never seen such an issue.

OK, it is your call... please change @plt to @PLT if desired.

>> Something like attached (untested) patch.
>
> Unfortunately, the Solaris 10/x86 bootstrap fails in the stage1 libgomp:
>
> /vol/gcc/src/hg/trunk/solaris/libgomp/single.c: In function 'GOMP_single_start':
> /vol/gcc/src/hg/trunk/solaris/libgomp/single.c:55:1: internal compiler error: ou
> tput_operand: '%&' used without any local dynamic TLS references

Yeah, I found the problem in tlsgdplt template, please find attached
new version of the patch...

Uros.

[-- Attachment #2: t.diff.txt --]
[-- Type: text/plain, Size: 1263 bytes --]

Index: i386.md
===================================================================
--- i386.md	(revision 174119)
+++ i386.md	(working copy)
@@ -12367,6 +12367,12 @@
 {
   output_asm_insn
     ("lea{l}\t{%a2@tlsgd(,%1,1), %0|%0, %a2@tlsgd[%1*1]}", operands);
+  if (TARGET_SUN_TLS)
+#ifdef HAVE_AS_IX86_TLSGDPLT
+    return "call\t%a2@tlsgdplt";
+#else
+    return "call\t%a3@plt";
+#endif
   return "call\t%P3";
 }
   [(set_attr "type" "multi")
@@ -12397,6 +12403,8 @@
     ("lea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}", operands);
   fputs (ASM_SHORT "0x6666\n", asm_out_file);
   fputs ("\trex64\n", asm_out_file);
+  if (TARGET_SUN_TLS)
+    return "call\t%a2@plt";
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
@@ -12424,6 +12432,12 @@
 {
   output_asm_insn
     ("lea{l}\t{%&@tlsldm(%1), %0|%0, %&@tlsldm[%1]}", operands);
+  if (TARGET_SUN_TLS)
+#ifdef HAVE_AS_IX86_TLSLDMPLT
+    return "call\t%&@tlsldmplt";
+#else
+    return "call\t%a2@plt";
+#endif
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
@@ -12450,6 +12464,8 @@
 {
   output_asm_insn
     ("lea{q}\t{%&@tlsld(%%rip), %%rdi|rdi, %&@tlsld[rip]}", operands);
+  if (TARGET_SUN_TLS)
+    return "call\t%a1@plt";
   return "call\t%P1";
 }
   [(set_attr "type" "multi")

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-24 16:43     ` Uros Bizjak
@ 2011-05-24 17:19       ` Rainer Orth
  2011-05-24 17:40         ` Joseph S. Myers
  2011-05-24 17:40         ` Uros Bizjak
  0 siblings, 2 replies; 14+ messages in thread
From: Rainer Orth @ 2011-05-24 17:19 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

Uros Bizjak <ubizjak@gmail.com> writes:

>> I think I tried something along these lines, but failed with duplicate
>> @plt@plt for PIC code.
>
> Hm, there is no %P1 present, so I don't think this should be an issue.

Unfortunately, I do get assembler errors (Sun as at the moment) with
your updated patch:

libtool: compile:  /var/gcc/gcc-4.7.0-20110523/10-gcc/./gcc/xgcc -shared-libgcc -B/var/gcc/gcc-4.7.0-20110523/10-gcc/./gcc -nostdinc++ -L/var/gcc/gcc-4.7.0-20110523/10-gcc/i386-pc-solaris2.10/amd64/libstdc++-v3/src -L/var/gcc/gcc-4.7.0-20110523/10-gcc/i386-pc-solaris2.10/amd64/libstdc++-v3/src/.libs -B/usr/local/i386-pc-solaris2.10/bin/ -B/usr/local/i386-pc-solaris2.10/lib/ -isystem /usr/local/i386-pc-solaris2.10/include -isystem /usr/local/i386-pc-solaris2.10/sys-include -m64 -I/vol/gcc/src/hg/trunk/solaris/libstdc++-v3/../gcc -I/var/gcc/gcc-4.7.0-20110523/10-gcc/i386-pc-solaris2.10/amd64/libstdc++-v3/include/i386-pc-solaris2.10 -I/var/gcc/gcc-4.7.0-20110523/10-gcc/i386-pc-solaris2.10/amd64/libstdc++-v3/include -I/vol/gcc/src/hg/trunk/solaris/libstdc++-v3/libsupc++ -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -g -O2 -m64 -c /vol/gcc/src/hg/trunk/solaris/libstdc++-v3/libsupc++/fundamental_type_info.cc  -fPIC -DPIC -o funinfo.o
damental_type_info.o
Assembler: eh_globals.cc
        "/var/tmp//ccJ1MA8h.s", line 17 : Syntax error
        Near line: "    call    __tls_get_addr(%rip)@plt"
        "/var/tmp//ccJ1MA8h.s", line 38 : Syntax error
        Near line: "    call    __tls_get_addr(%rip)@plt"
make[9]: *** [eh_globals.lo] Error 1

Which makes me wonder if I should run the gcc.dg/torture/tls-*.c tests
with -fPIC, too.

>>> is IIRC preferred by Sun assebler.
>>
>> I've never seen such an issue.
>
> OK, it is your call... please change @plt to @PLT if desired.

I'll keep it at @plt for consistency with the rest.

Thanks.
	Rainer

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

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-24 17:19       ` Rainer Orth
@ 2011-05-24 17:40         ` Joseph S. Myers
  2011-05-24 17:40         ` Uros Bizjak
  1 sibling, 0 replies; 14+ messages in thread
From: Joseph S. Myers @ 2011-05-24 17:40 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Uros Bizjak, gcc-patches

On Tue, 24 May 2011, Rainer Orth wrote:

> Which makes me wonder if I should run the gcc.dg/torture/tls-*.c tests
> with -fPIC, too.

I think it makes sense to try to provide reasonable coverage of TLS tests 
with all of -fPIC, -fpic, -fPIE and -fpie.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-24 17:19       ` Rainer Orth
  2011-05-24 17:40         ` Joseph S. Myers
@ 2011-05-24 17:40         ` Uros Bizjak
  2011-05-24 17:41           ` Rainer Orth
  1 sibling, 1 reply; 14+ messages in thread
From: Uros Bizjak @ 2011-05-24 17:40 UTC (permalink / raw)
  To: Rainer Orth; +Cc: gcc-patches

On Tue, May 24, 2011 at 5:34 PM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> Uros Bizjak <ubizjak@gmail.com> writes:
>
>>> I think I tried something along these lines, but failed with duplicate
>>> @plt@plt for PIC code.
>>
>> Hm, there is no %P1 present, so I don't think this should be an issue.
>
> Unfortunately, I do get assembler errors (Sun as at the moment) with
> your updated patch:
>
> libtool: compile:  /var/gcc/gcc-4.7.0-20110523/10-gcc/./gcc/xgcc -shared-libgcc -B/var/gcc/gcc-4.7.0-20110523/10-gcc/./gcc -nostdinc++ -L/var/gcc/gcc-4.7.0-20110523/10-gcc/i386-pc-solaris2.10/amd64/libstdc++-v3/src -L/var/gcc/gcc-4.7.0-20110523/10-gcc/i386-pc-solaris2.10/amd64/libstdc++-v3/src/.libs -B/usr/local/i386-pc-solaris2.10/bin/ -B/usr/local/i386-pc-solaris2.10/lib/ -isystem /usr/local/i386-pc-solaris2.10/include -isystem /usr/local/i386-pc-solaris2.10/sys-include -m64 -I/vol/gcc/src/hg/trunk/solaris/libstdc++-v3/../gcc -I/var/gcc/gcc-4.7.0-20110523/10-gcc/i386-pc-solaris2.10/amd64/libstdc++-v3/include/i386-pc-solaris2.10 -I/var/gcc/gcc-4.7.0-20110523/10-gcc/i386-pc-solaris2.10/amd64/libstdc++-v3/include -I/vol/gcc/src/hg/trunk/solaris/libstdc++-v3/libsupc++ -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -g -O2 -m64 -c /vol/gcc/src/hg/trunk/solaris/libstdc++-v3/libsupc++/fundamental_type_info.cc  -fPIC -DPIC -o funinfo.o
> damental_type_info.o
> Assembler: eh_globals.cc
>        "/var/tmp//ccJ1MA8h.s", line 17 : Syntax error
>        Near line: "    call    __tls_get_addr(%rip)@plt"
>        "/var/tmp//ccJ1MA8h.s", line 38 : Syntax error
>        Near line: "    call    __tls_get_addr(%rip)@plt"
> make[9]: *** [eh_globals.lo] Error 1

Bah. %P has a special handling that removes (%rip). Are you sure Sun
assembler requests @plt in PIC and non-PIC cases? Can we solve this
with TARGET_SUN_TLS somehow?

Thanks,
Uros.

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-24 17:40         ` Uros Bizjak
@ 2011-05-24 17:41           ` Rainer Orth
  2011-05-24 18:07             ` Uros Bizjak
  0 siblings, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-05-24 17:41 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

Uros Bizjak <ubizjak@gmail.com> writes:

>> Assembler: eh_globals.cc
>>        "/var/tmp//ccJ1MA8h.s", line 17 : Syntax error
>>        Near line: "    call    __tls_get_addr(%rip)@plt"
>>        "/var/tmp//ccJ1MA8h.s", line 38 : Syntax error
>>        Near line: "    call    __tls_get_addr(%rip)@plt"
>> make[9]: *** [eh_globals.lo] Error 1
>
> Bah. %P has a special handling that removes (%rip). Are you sure Sun
> assembler requests @plt in PIC and non-PIC cases? Can we solve this

Pretty much so: my first attempts to resolve this consisted in taking
the regular gcc assembler output and mangling it until it worked with ld.

> with TARGET_SUN_TLS somehow?

We could certainly duplicate (some of) the logic that %P already uses,
but I though it easier to just introduce a straightforward variant (%p)
instead.  It's not pretty, but it worked.

	Rainer

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

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-24 17:41           ` Rainer Orth
@ 2011-05-24 18:07             ` Uros Bizjak
  2011-05-26 11:12               ` Rainer Orth
  0 siblings, 1 reply; 14+ messages in thread
From: Uros Bizjak @ 2011-05-24 18:07 UTC (permalink / raw)
  To: Rainer Orth; +Cc: gcc-patches

On Tue, May 24, 2011 at 6:42 PM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> Uros Bizjak <ubizjak@gmail.com> writes:
>
>>> Assembler: eh_globals.cc
>>>        "/var/tmp//ccJ1MA8h.s", line 17 : Syntax error
>>>        Near line: "    call    __tls_get_addr(%rip)@plt"
>>>        "/var/tmp//ccJ1MA8h.s", line 38 : Syntax error
>>>        Near line: "    call    __tls_get_addr(%rip)@plt"
>>> make[9]: *** [eh_globals.lo] Error 1
>>
>> Bah. %P has a special handling that removes (%rip). Are you sure Sun
>> assembler requests @plt in PIC and non-PIC cases? Can we solve this
>
> Pretty much so: my first attempts to resolve this consisted in taking
> the regular gcc assembler output and mangling it until it worked with ld.
>
>> with TARGET_SUN_TLS somehow?
>
> We could certainly duplicate (some of) the logic that %P already uses,
> but I though it easier to just introduce a straightforward variant (%p)
> instead.  It's not pretty, but it worked.

OK then... can you propose a new patch, please, changing as little of
generic code as possible?

Uros.

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-24 18:07             ` Uros Bizjak
@ 2011-05-26 11:12               ` Rainer Orth
  2011-05-27  0:47                 ` Uros Bizjak
  0 siblings, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-05-26 11:12 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

Uros Bizjak <ubizjak@gmail.com> writes:

>> We could certainly duplicate (some of) the logic that %P already uses,
>> but I though it easier to just introduce a straightforward variant (%p)
>> instead.  It's not pretty, but it worked.
>
> OK then... can you propose a new patch, please, changing as little of
> generic code as possible?

I'll try, but somewhat fear that I will arive again at what I had
initially.  Will probably have to wait for the weekend.

	Rainer

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

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-26 11:12               ` Rainer Orth
@ 2011-05-27  0:47                 ` Uros Bizjak
  2011-05-27 13:35                   ` Rainer Orth
  0 siblings, 1 reply; 14+ messages in thread
From: Uros Bizjak @ 2011-05-27  0:47 UTC (permalink / raw)
  To: Rainer Orth; +Cc: gcc-patches

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

On Thu, May 26, 2011 at 12:47 PM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:

>>> We could certainly duplicate (some of) the logic that %P already uses,
>>> but I though it easier to just introduce a straightforward variant (%p)
>>> instead.  It's not pretty, but it worked.
>>
>> OK then... can you propose a new patch, please, changing as little of
>> generic code as possible?
>
> I'll try, but somewhat fear that I will arive again at what I had
> initially.  Will probably have to wait for the weekend.

Please find attached the patch that introduces %p to output only the
raw symbol name. @plt is added "manually", since it doesn't really
follow -fpic flag.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 2287 bytes --]

Index: gcc/config/i386/i386.md
===================================================================
--- gcc/config/i386/i386.md	(revision 174306)
+++ gcc/config/i386/i386.md	(working copy)
@@ -12367,6 +12367,12 @@
 {
   output_asm_insn
     ("lea{l}\t{%a2@tlsgd(,%1,1), %0|%0, %a2@tlsgd[%1*1]}", operands);
+  if (TARGET_SUN_TLS)
+#ifdef HAVE_AS_IX86_TLSGDPLT
+    return "call\t%a2@tlsgdplt";
+#else
+    return "call\t%p3@plt";
+#endif
   return "call\t%P3";
 }
   [(set_attr "type" "multi")
@@ -12397,6 +12403,8 @@
     ("lea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}", operands);
   fputs (ASM_SHORT "0x6666\n", asm_out_file);
   fputs ("\trex64\n", asm_out_file);
+  if (TARGET_SUN_TLS)
+    return "call\t%p2@plt";
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
@@ -12424,6 +12432,12 @@
 {
   output_asm_insn
     ("lea{l}\t{%&@tlsldm(%1), %0|%0, %&@tlsldm[%1]}", operands);
+  if (!TARGET_SUN_TLS)
+#ifdef HAVE_AS_IX86_TLSLDMPLT
+    return "call\t%&@tlsldmplt";
+#else
+    return "call\t%p2@plt";
+#endif
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
@@ -12450,6 +12464,8 @@
 {
   output_asm_insn
     ("lea{q}\t{%&@tlsld(%%rip), %%rdi|rdi, %&@tlsld[rip]}", operands);
+  if (TARGET_SUN_TLS)
+    return "call\t%p1@plt";
   return "call\t%P1";
 }
   [(set_attr "type" "multi")
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 174306)
+++ gcc/config/i386/i386.c	(working copy)
@@ -13918,6 +13918,7 @@ get_some_local_dynamic_name (void)
    d -- print duplicated register operand for AVX instruction.
    D -- print condition for SSE cmp instruction.
    P -- if PIC, print an @PLT suffix.
+   p -- print raw symbol name.
    X -- don't print any sort of PIC '@' suffix for a symbol.
    & -- print some in-use local-dynamic symbol name.
    H -- print a memory address offset by 8; used for sse high-parts
@@ -14123,6 +14124,7 @@ ix86_print_operand (FILE *file, rtx x, i
 	case 'x':
 	case 'X':
 	case 'P':
+	case 'p':
 	  break;
 
 	case 's':
@@ -14522,7 +14524,7 @@ ix86_print_operand (FILE *file, rtx x, i
 	  x = const0_rtx;
 	}
 
-      if (code != 'P')
+      if (code != 'P' && code != 'p')
 	{
 	  if (CONST_INT_P (x) || GET_CODE (x) == CONST_DOUBLE)
 	    {

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-27  0:47                 ` Uros Bizjak
@ 2011-05-27 13:35                   ` Rainer Orth
  2011-05-27 14:00                     ` Uros Bizjak
  0 siblings, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-05-27 13:35 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

Uros Bizjak <ubizjak@gmail.com> writes:

> Please find attached the patch that introduces %p to output only the
> raw symbol name. @plt is added "manually", since it doesn't really
> follow -fpic flag.

Thanks, that almost did it:

* HAVE_AS_IX86_{TLSGDPLT, TLSLDMPLT} are always defined as 0/1, so we
  need if, not #ifdef.

* The @tlsldmplt TARGET_SUN_TLS test was inverted.

The patch below has just been bootstrapped on i386-pc-solaris2.11 with
both Sun as (which supports both relocs) and gas (which supports none).

With Sun as, all run-{gd, ld}.c failures are gone, with GNU as, the
32-bit run-ld.c failures remain, as expected.  I'll next try to get
@tls{gd, ldm}plt support into gas.

Ok for mainline now?

	Rainer


2010-12-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
	    Uros Bizjak <ubizjak@gmail.com>

	* configure.ac (gcc_cv_as_ix86_tlsgdplt): Check for @tlsgdplt
	(HAVE_AS_IX86_TLSGDPTL): Define.
	(gcc_cv_as_ix86_tlsldmplt): Check for @tlsldmplt.
	(HAVE_AS_IX86_TLSLDMPLT): Define.
	* configure: Regenerate.
	* config.in: Regenerate.
	* config/i386/i386.c (ix86_print_operand): Handle code 'p'.
	* config/i386/i386.md (*tls_global_dynamic_32_gnu): If
	TARGET_SUN_TLS, use @tlsgdplt or @plt.
	(*tls_global_dynamic_64): Use @plt if TARGET_SUN_TLS.
	(*tls_local_dynamic_base_32_gnu): If TARGET_SUN_TLS, use
	@tlsldmplt or @plt.
	(*tls_local_dynamic_base_64): Use @plt if TARGET_SUN_TLS.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -13918,6 +13918,7 @@ get_some_local_dynamic_name (void)
    d -- print duplicated register operand for AVX instruction.
    D -- print condition for SSE cmp instruction.
    P -- if PIC, print an @PLT suffix.
+   p -- print raw symbol name.
    X -- don't print any sort of PIC '@' suffix for a symbol.
    & -- print some in-use local-dynamic symbol name.
    H -- print a memory address offset by 8; used for sse high-parts
@@ -14123,6 +14124,7 @@ ix86_print_operand (FILE *file, rtx x, i
 	case 'x':
 	case 'X':
 	case 'P':
+	case 'p':
 	  break;
 
 	case 's':
@@ -14522,7 +14524,7 @@ ix86_print_operand (FILE *file, rtx x, i
 	  x = const0_rtx;
 	}
 
-      if (code != 'P')
+      if (code != 'P' && code != 'p')
 	{
 	  if (CONST_INT_P (x) || GET_CODE (x) == CONST_DOUBLE)
 	    {
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -12367,6 +12367,13 @@
 {
   output_asm_insn
     ("lea{l}\t{%a2@tlsgd(,%1,1), %0|%0, %a2@tlsgd[%1*1]}", operands);
+  if (TARGET_SUN_TLS)
+    {
+      if (HAVE_AS_IX86_TLSGDPLT)
+        return "call\t%a2@tlsgdplt";
+      else
+        return "call\t%p3@plt";
+    }
   return "call\t%P3";
 }
   [(set_attr "type" "multi")
@@ -12397,6 +12404,8 @@
     ("lea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}", operands);
   fputs (ASM_SHORT "0x6666\n", asm_out_file);
   fputs ("\trex64\n", asm_out_file);
+  if (TARGET_SUN_TLS)
+    return "call\t%p2@plt";
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
@@ -12424,6 +12433,13 @@
 {
   output_asm_insn
     ("lea{l}\t{%&@tlsldm(%1), %0|%0, %&@tlsldm[%1]}", operands);
+  if (TARGET_SUN_TLS)
+    {
+      if (HAVE_AS_IX86_TLSLDMPLT)
+        return "call\t%&@tlsldmplt";
+      else
+        return "call\t%p2@plt";
+    }
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
@@ -12450,6 +12466,8 @@
 {
   output_asm_insn
     ("lea{q}\t{%&@tlsld(%%rip), %%rdi|rdi, %&@tlsld[rip]}", operands);
+  if (TARGET_SUN_TLS)
+    return "call\t%p1@plt";
   return "call\t%P1";
 }
   [(set_attr "type" "multi")
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3550,6 +3550,20 @@ foo:	nop
         [AC_DEFINE(HAVE_AS_IX86_REP_LOCK_PREFIX, 1,
           [Define if the assembler supports 'rep <insn>, lock <insn>'.])])
 
+    gcc_GAS_CHECK_FEATURE([R_386_TLS_GD_PLT reloc],
+        gcc_cv_as_ix86_tlsgdplt,,,
+	[call    tls_gd@tlsgdplt])
+    AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLSGDPLT,
+      [`if test $gcc_cv_as_ix86_tlsgdplt = yes; then echo 1; else echo 0; fi`],
+      [Define 0/1 if your assembler supports @tlsgdplt.])
+
+    gcc_GAS_CHECK_FEATURE([R_386_TLS_LDM_PLT reloc],
+        gcc_cv_as_ix86_tlsldmplt,,,
+	[call    tls_ld@tlsldmplt])
+    AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLSLDMPLT,
+      [`if test $gcc_cv_as_ix86_tlsldmplt = yes; then echo 1; else echo 0; fi`],
+      [Define 0/1 if your assembler supports @tlsldmplt.])
+
     ;;
 
   ia64*-*-*)

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

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-27 13:35                   ` Rainer Orth
@ 2011-05-27 14:00                     ` Uros Bizjak
  2011-05-27 16:57                       ` Rainer Orth
  0 siblings, 1 reply; 14+ messages in thread
From: Uros Bizjak @ 2011-05-27 14:00 UTC (permalink / raw)
  To: Rainer Orth; +Cc: gcc-patches

On Fri, May 27, 2011 at 2:25 PM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:

>> Please find attached the patch that introduces %p to output only the
>> raw symbol name. @plt is added "manually", since it doesn't really
>> follow -fpic flag.
>
> Thanks, that almost did it:
>
> * HAVE_AS_IX86_{TLSGDPLT, TLSLDMPLT} are always defined as 0/1, so we
>  need if, not #ifdef.

There is no need to always define it. Please simplify your
configure.ac check, see i.e. check for sahf mnemonic in configure.ac.

> * The @tlsldmplt TARGET_SUN_TLS test was inverted.

Uh, yes... I have used it during testing and forgot to remove inverted check.

> The patch below has just been bootstrapped on i386-pc-solaris2.11 with
> both Sun as (which supports both relocs) and gas (which supports none).
>
> With Sun as, all run-{gd, ld}.c failures are gone, with GNU as, the
> 32-bit run-ld.c failures remain, as expected.  I'll next try to get
> @tls{gd, ldm}plt support into gas.
>
> Ok for mainline now?

Please change the check in configure.ac to conditionally define
HAVE_AS_IX86_... defines.

The patch is OK with this change.

Thanks,
Uros.

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

* Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld
  2011-05-27 14:00                     ` Uros Bizjak
@ 2011-05-27 16:57                       ` Rainer Orth
  0 siblings, 0 replies; 14+ messages in thread
From: Rainer Orth @ 2011-05-27 16:57 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

Uros Bizjak <ubizjak@gmail.com> writes:

>> * HAVE_AS_IX86_{TLSGDPLT, TLSLDMPLT} are always defined as 0/1, so we
>>  need if, not #ifdef.
>
> There is no need to always define it. Please simplify your
> configure.ac check, see i.e. check for sahf mnemonic in configure.ac.

Ok, done.

> Please change the check in configure.ac to conditionally define
> HAVE_AS_IX86_... defines.
>
> The patch is OK with this change.

Here's what I've checked in after retesting as described before.  I've
also added the description of the new 'p' code to i386.md.

Thanks for your help.

	Rainer


2011-05-27  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
	    Uros Bizjak <ubizjak@gmail.com>

	* configure.ac (gcc_cv_as_ix86_tlsgdplt): Check for @tlsgdplt
	(HAVE_AS_IX86_TLSGDPTL): Define.
	(gcc_cv_as_ix86_tlsldmplt): Check for @tlsldmplt.
	(HAVE_AS_IX86_TLSLDMPLT): Define.
	* configure: Regenerate.
	* config.in: Regenerate.
	* config/i386/i386.c (ix86_print_operand): Handle code 'p'.
	* config/i386/i386.md (*tls_global_dynamic_32_gnu): If
	TARGET_SUN_TLS, use @tlsgdplt or @plt.
	(*tls_global_dynamic_64): Use @plt if TARGET_SUN_TLS.
	(*tls_local_dynamic_base_32_gnu): If TARGET_SUN_TLS, use
	@tlsldmplt or @plt.
	(*tls_local_dynamic_base_64): Use @plt if TARGET_SUN_TLS.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -13918,6 +13918,7 @@ get_some_local_dynamic_name (void)
    d -- print duplicated register operand for AVX instruction.
    D -- print condition for SSE cmp instruction.
    P -- if PIC, print an @PLT suffix.
+   p -- print raw symbol name.
    X -- don't print any sort of PIC '@' suffix for a symbol.
    & -- print some in-use local-dynamic symbol name.
    H -- print a memory address offset by 8; used for sse high-parts
@@ -14123,6 +14124,7 @@ ix86_print_operand (FILE *file, rtx x, i
 	case 'x':
 	case 'X':
 	case 'P':
+	case 'p':
 	  break;
 
 	case 's':
@@ -14522,7 +14524,7 @@ ix86_print_operand (FILE *file, rtx x, i
 	  x = const0_rtx;
 	}
 
-      if (code != 'P')
+      if (code != 'P' && code != 'p')
 	{
 	  if (CONST_INT_P (x) || GET_CODE (x) == CONST_DOUBLE)
 	    {
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -53,6 +53,7 @@
 ;; d -- print duplicated register operand for AVX instruction.
 ;; D -- print condition for SSE cmp instruction.
 ;; P -- if PIC, print an @PLT suffix.
+;; p -- print raw symbol name.
 ;; X -- don't print any sort of PIC '@' suffix for a symbol.
 ;; & -- print some in-use local-dynamic symbol name.
 ;; H -- print a memory address offset by 8; used for sse high-parts
@@ -12367,6 +12368,12 @@
 {
   output_asm_insn
     ("lea{l}\t{%a2@tlsgd(,%1,1), %0|%0, %a2@tlsgd[%1*1]}", operands);
+  if (TARGET_SUN_TLS)
+#ifdef HAVE_AS_IX86_TLSGDPLT
+    return "call\t%a2@tlsgdplt";
+#else
+    return "call\t%p3@plt";
+#endif
   return "call\t%P3";
 }
   [(set_attr "type" "multi")
@@ -12397,6 +12404,8 @@
     ("lea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}", operands);
   fputs (ASM_SHORT "0x6666\n", asm_out_file);
   fputs ("\trex64\n", asm_out_file);
+  if (TARGET_SUN_TLS)
+    return "call\t%p2@plt";
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
@@ -12424,6 +12433,12 @@
 {
   output_asm_insn
     ("lea{l}\t{%&@tlsldm(%1), %0|%0, %&@tlsldm[%1]}", operands);
+  if (TARGET_SUN_TLS)
+#ifdef HAVE_AS_IX86_TLSLDMPLT
+    return "call\t%&@tlsldmplt";
+#else
+    return "call\t%p2@plt";
+#endif
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
@@ -12450,6 +12465,8 @@
 {
   output_asm_insn
     ("lea{q}\t{%&@tlsld(%%rip), %%rdi|rdi, %&@tlsld[rip]}", operands);
+  if (TARGET_SUN_TLS)
+    return "call\t%p1@plt";
   return "call\t%P1";
 }
   [(set_attr "type" "multi")
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3649,6 +3649,18 @@ foo:	nop
         [AC_DEFINE(HAVE_AS_IX86_REP_LOCK_PREFIX, 1,
           [Define if the assembler supports 'rep <insn>, lock <insn>'.])])
 
+    gcc_GAS_CHECK_FEATURE([R_386_TLS_GD_PLT reloc],
+        gcc_cv_as_ix86_tlsgdplt,,,
+	[call    tls_gd@tlsgdplt],,
+      [AC_DEFINE(HAVE_AS_IX86_TLSGDPLT, 1,
+        [Define if your assembler supports @tlsgdplt.])])
+
+    gcc_GAS_CHECK_FEATURE([R_386_TLS_LDM_PLT reloc],
+        gcc_cv_as_ix86_tlsldmplt,,,
+	[call    tls_ld@tlsldmplt],,
+      [AC_DEFINE(HAVE_AS_IX86_TLSLDMPLT, 1,
+        [Define if your assembler supports @tlsldmplt.])])
+
     ;;
 
   ia64*-*-*)


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

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

end of thread, other threads:[~2011-05-27 15:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23 20:04 [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld Rainer Orth
2011-05-23 21:32 ` Uros Bizjak
2011-05-24 16:42   ` Rainer Orth
2011-05-24 16:43     ` Uros Bizjak
2011-05-24 17:19       ` Rainer Orth
2011-05-24 17:40         ` Joseph S. Myers
2011-05-24 17:40         ` Uros Bizjak
2011-05-24 17:41           ` Rainer Orth
2011-05-24 18:07             ` Uros Bizjak
2011-05-26 11:12               ` Rainer Orth
2011-05-27  0:47                 ` Uros Bizjak
2011-05-27 13:35                   ` Rainer Orth
2011-05-27 14:00                     ` Uros Bizjak
2011-05-27 16:57                       ` Rainer Orth

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).