diff mbox

[build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld

Message ID yddmxi88h4e.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth May 27, 2011, 12:25 p.m. UTC
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.

Comments

Uros Bizjak May 27, 2011, 12:50 p.m. UTC | #1
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.
diff mbox

Patch

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