This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Support TLS with Sun as on Solaris 2/x86


I've just successfully finished adding TLS support for Solaris 2/x86
with Sun as (instead of GNU as which works already).  There were a
couple of assembler language differences that this patch handles:

* Sun as uses the 't' as flag to mark TLS sections, whereas gas uses 'T'
  here.  Neither assembler understands the other variant here.

* Sun as expects all TLS relocations in lowercase, while gas can handle
  either case.

* Sun uses .tcomm instead of the gas .tls_common, each can only handle
  its own syntax.

* As on SPARC, TLS objects need to be declared as @tls_obj, not
  @object.  Unfortately, gas understands the SPARC @tls_object variant,
  but not @tls_obj.

* Not a syntactic difference, but like the Sun SPARC assembler, a
  .comm directive in a .tbss section behaves as .tls_common/.tcomm,
  not non-TLS .comm (PR target/38118).

Once these differences were understood, the patch itself is straight
forward:

* It adapts gcc/configure.ac to accept both syntaxes, using the Solaris
  2/SPARC section as a guide, but avoiding to duplicate identical code.
  One ugly problem here is that I've had to move the
  AC_DEFINE(TLS_SECTION_ASM_FLAG) from the case statement where it
  belonged further down, otherwise autoconf would choke on me:

/usr/bin/gm4:configure2.ac:2604: non-numeric argument to builtin `m4_substr'
/usr/bin/gm4:configure2.ac:2604: Warning: too few arguments to builtin `m4_index'
/usr/bin/gm4:configure2.ac:2604: Warning: excess arguments to builtin `m4_if' ignored
/usr/bin/gm4:configure2.ac:2604: Warning: excess arguments to builtin `m4_if' ignored
configure2.ac:2604: error: m4_cond: missing an argument
configure2.ac:2604: the top level
autom4te: /usr/bin/gm4 failed with exit status: 1

  and I've been completely unable to determine why this would happen.

* It supports using non-default values for the TLS section flag
  (TLS_SECTION_ASM_FLAG) and the directive to declare a TLS common
  variable (TLS_COMMON_ASM_OP).

* It changes i386/i386.c and i386/i386.md to emit the TLS relocs in
  lowercase.

* It removes the (completely unused) TLS_DIALECT_SUN: this was only used
  in the *tls_global_dynamic_32_sun and *tls_local_dynamic_base_32_sun
  insns in i386.md, and at least for the latter the @TMDNX relocation
  used there isn't found in Sun as, so it can hardly ever have worked
  and seems to be useless right now.  At the same time, it redefines
  TARGET_SUN_TLS to mean not a different dialect but the (sometimes)
  stricter requirements of the Solaris platform, e.g. the one mentioned
  in

	PATCH: Fix 64-bit Solaris 2/x86 IE TLS code sequence
        http://gcc.gnu.org/ml/gcc-patches/2010-02/msg00993.html

  Thus is is also defined even if gas is in use!

* The redefinition of ASM_OUTPUT_ALIGNED_COMMON is moved from
  sparc/sol2.h to sol2.h, and another one added to i386/sol2-10.h to
  carry forward the workaround for PR target/38118.

While this is all relatively straight forward, I hesitate to ask for
mainline approval now, since especially the lowercasing of the TLS
relocs might influence other targets in unexpected ways.

Bootstrapped without regressions on i386-pc-solaris2.11 (both Sun as and
gas 2.19).

Ok for mainline (or, if considered too risky, mainline after 4.5 has
branched)?

	Rainer

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


2010-02-15  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* configure.ac (i[34567]86-*-*): Handle Solaris 2/x86 TLS support
	and Sun as TLS syntax.
	(TLS_SECTION_ASM_FLAG) [on_solaris && !gas_flag]: Define.
	* configure: Regenerate.
	* config.in: Regenerate.
	* varasm.c (TLS_SECTION_ASM_FLAG): Define default.
	(default_elf_asm_named_section): Use it.
	* config/i386/i386.c (output_pic_addr_const): Lowercase @DTPOFF.
	(i386_output_dwarf_dtprel): Likewise.
	(output_addr_const_extra): Likewise.
	(output_pic_addr_const): Lowercase @GOTTPOFF.
	(output_addr_const_extra): Likewise.
	(output_pic_addr_const): Lowercase @GOTNTPOFF.
	(output_addr_const_extra): Likewise.
	(output_pic_addr_const): Lowercase @INDNTPOFF.
	(output_addr_const_extra): Likewise.
	(output_pic_addr_const): Lowercase @NTPOFF.
	(output_addr_const_extra): Likewise.
	(output_pic_addr_const): Lowercase @TPOFF.
	(output_addr_const_extra): Likewise.
	(override_options): Don't accept -mtls-dialect=sun any longer.
	* config/i386/i386.h (TARGET_SUN_TLS): Define as 0.
	* config/i386/i386.md (*tls_global_dynamic_32_gnu): Lowercase
	@TLSGD.
	(*tls_global_dynamic_64): Likewise.
	(*tls_local_dynamic_base_32_gnu): Lowercase @TLSLDM.
	(*tls_local_dynamic_base_64): Lowercase	@TLSLD.
	(*tls_global_dynamic_32_sun): Remove.
	(*tls_local_dynamic_base_32_sun): Likewise.

	* defaults.h (TLS_COMMON_ASM_OP): Provide default.
	(ASM_OUTPUT_TLS_COMMON): Use it.
	* config/i386/sol2-gas.h (TLS_COMMON_ASM_OP): Undef.

	PR target/38118
	* config/sparc/sol2.h (ASM_OUTPUT_ALIGNED_COMMON): Move ...
	* config/sol2.h (ASM_OUTPUT_ALIGNED_COMMON): ... here.
	* config/i386/sol2-10.h (ASM_OUTPUT_ALIGNED_COMMON): Redefine.
	* config/i386/sol2.h (TARGET_SUN_TLS): Redefine.
	(ASM_DECLARE_OBJECT_NAME) [!USE_GAS]: Redefine.

diff -r 07a4c477186c -r 12f2e6ffa730 gcc/config.in
--- a/gcc/config.in	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/config.in	Wed Feb 17 14:19:49 2010 +0100
@@ -1628,6 +1628,13 @@
 #endif
 
 
+/* Define to the flag used to mark TLS sections if the default (`T') doesn't
+   work. */
+#ifndef USED_FOR_TARGET
+#undef TLS_SECTION_ASM_FLAG
+#endif
+
+
 /* Define if your assembler mis-optimizes .eh_frame data. */
 #ifndef USED_FOR_TARGET
 #undef USE_AS_TRADITIONAL_FORMAT
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/config/i386/i386.c
--- a/gcc/config/i386/i386.c	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/config/i386/i386.c	Wed Feb 17 14:19:49 2010 +0100
@@ -3191,8 +3191,6 @@
 	ix86_tls_dialect = TLS_DIALECT_GNU;
       else if (strcmp (ix86_tls_dialect_string, "gnu2") == 0)
 	ix86_tls_dialect = TLS_DIALECT_GNU2;
-      else if (strcmp (ix86_tls_dialect_string, "sun") == 0)
-	ix86_tls_dialect = TLS_DIALECT_SUN;
       else
 	error ("bad value (%s) for %stls-dialect=%s %s",
 	       ix86_tls_dialect_string, prefix, suffix, sw);
@@ -10794,29 +10792,29 @@
 	  break;
 	case UNSPEC_GOTTPOFF:
 	  /* FIXME: This might be @TPOFF in Sun ld too.  */
-	  fputs ("@GOTTPOFF", file);
+	  fputs ("@gottpoff", file);
 	  break;
 	case UNSPEC_TPOFF:
-	  fputs ("@TPOFF", file);
+	  fputs ("@tpoff", file);
 	  break;
 	case UNSPEC_NTPOFF:
 	  if (TARGET_64BIT)
-	    fputs ("@TPOFF", file);
-	  else
-	    fputs ("@NTPOFF", file);
+	    fputs ("@tpoff", file);
+	  else
+	    fputs ("@ntpoff", file);
 	  break;
 	case UNSPEC_DTPOFF:
-	  fputs ("@DTPOFF", file);
+	  fputs ("@dtpoff", file);
 	  break;
 	case UNSPEC_GOTNTPOFF:
 	  if (TARGET_64BIT)
 	    fputs (ASSEMBLER_DIALECT == ASM_ATT ?
-		   "@GOTTPOFF(%rip)": "@GOTTPOFF[rip]", file);
-	  else
-	    fputs ("@GOTNTPOFF", file);
+		   "@gottpoff(%rip)": "@gottpoff[rip]", file);
+	  else
+	    fputs ("@gotntpoff", file);
 	  break;
 	case UNSPEC_INDNTPOFF:
-	  fputs ("@INDNTPOFF", file);
+	  fputs ("@indntpoff", file);
 	  break;
 #if TARGET_MACHO
 	case UNSPEC_MACHOPIC_OFFSET:
@@ -10843,7 +10841,7 @@
 {
   fputs (ASM_LONG, file);
   output_addr_const (file, x);
-  fputs ("@DTPOFF", file);
+  fputs ("@dtpoff", file);
   switch (size)
     {
     case 4:
@@ -12102,34 +12100,34 @@
     case UNSPEC_GOTTPOFF:
       output_addr_const (file, op);
       /* FIXME: This might be @TPOFF in Sun ld.  */
-      fputs ("@GOTTPOFF", file);
+      fputs ("@gottpoff", file);
       break;
     case UNSPEC_TPOFF:
       output_addr_const (file, op);
-      fputs ("@TPOFF", file);
+      fputs ("@tpoff", file);
       break;
     case UNSPEC_NTPOFF:
       output_addr_const (file, op);
       if (TARGET_64BIT)
-	fputs ("@TPOFF", file);
-      else
-	fputs ("@NTPOFF", file);
+	fputs ("@tpoff", file);
+      else
+	fputs ("@ntpoff", file);
       break;
     case UNSPEC_DTPOFF:
       output_addr_const (file, op);
-      fputs ("@DTPOFF", file);
+      fputs ("@dtpoff", file);
       break;
     case UNSPEC_GOTNTPOFF:
       output_addr_const (file, op);
       if (TARGET_64BIT)
 	fputs (ASSEMBLER_DIALECT == ASM_ATT ?
-	       "@GOTTPOFF(%rip)" : "@GOTTPOFF[rip]", file);
-      else
-	fputs ("@GOTNTPOFF", file);
+	       "@gottpoff(%rip)" : "@gottpoff[rip]", file);
+      else
+	fputs ("@gotntpoff", file);
       break;
     case UNSPEC_INDNTPOFF:
       output_addr_const (file, op);
-      fputs ("@INDNTPOFF", file);
+      fputs ("@indntpoff", file);
       break;
 #if TARGET_MACHO
     case UNSPEC_MACHOPIC_OFFSET:
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/config/i386/i386.h
--- a/gcc/config/i386/i386.h	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/config/i386/i386.h	Wed Feb 17 14:19:49 2010 +0100
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GCC for IA-32.
    Copyright (C) 1988, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -429,7 +429,7 @@
 #define TARGET_GNU_TLS		(ix86_tls_dialect == TLS_DIALECT_GNU)
 #define TARGET_GNU2_TLS		(ix86_tls_dialect == TLS_DIALECT_GNU2)
 #define TARGET_ANY_GNU_TLS	(TARGET_GNU_TLS || TARGET_GNU2_TLS)
-#define TARGET_SUN_TLS		(ix86_tls_dialect == TLS_DIALECT_SUN)
+#define TARGET_SUN_TLS		0
 
 extern int ix86_isa_flags;
 
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/config/i386/i386.md
--- a/gcc/config/i386/i386.md	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/config/i386/i386.md	Wed Feb 17 14:19:49 2010 +0100
@@ -1,6 +1,6 @@
 ;; GCC machine description for IA-32 and x86-64.
 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;; Free Software Foundation, Inc.
 ;; Mostly by William Schelter.
 ;; x86_64 support added by Jan Hubicka
@@ -14490,25 +14490,10 @@
    (clobber (match_scratch:SI 5 "=c"))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_64BIT && TARGET_GNU_TLS"
-  "lea{l}\t{%a2@TLSGD(,%1,1), %0|%0, %a2@TLSGD[%1*1]}\;call\t%P3"
+  "lea{l}\t{%a2@tlsgd(,%1,1), %0|%0, %a2@tlsgd[%1*1]}\;call\t%P3"
   [(set_attr "type" "multi")
    (set_attr "length" "12")])
 
-(define_insn "*tls_global_dynamic_32_sun"
-  [(set (match_operand:SI 0 "register_operand" "=a")
-	(unspec:SI [(match_operand:SI 1 "register_operand" "b")
-		    (match_operand:SI 2 "tls_symbolic_operand" "")
-		    (match_operand:SI 3 "call_insn_operand" "")]
-		    UNSPEC_TLS_GD))
-   (clobber (match_scratch:SI 4 "=d"))
-   (clobber (match_scratch:SI 5 "=c"))
-   (clobber (reg:CC FLAGS_REG))]
-  "!TARGET_64BIT && TARGET_SUN_TLS"
-  "lea{l}\t{%a2@DTLNDX(%1), %4|%4, %a2@DTLNDX[%1]}
-	push{l}\t%4\;call\t%a2@TLSPLT\;pop{l}\t%4\;nop"
-  [(set_attr "type" "multi")
-   (set_attr "length" "14")])
-
 (define_expand "tls_global_dynamic_32"
   [(parallel [(set (match_operand:SI 0 "register_operand" "")
 		   (unspec:SI
@@ -14544,7 +14529,7 @@
    (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
 	      UNSPEC_TLS_GD)]
   "TARGET_64BIT"
-  { return ASM_BYTE "0x66\n\tlea{q}\t{%a1@TLSGD(%%rip), %%rdi|rdi, %a1@TLSGD[rip]}\n" ASM_SHORT "0x6666\n\trex64\n\tcall\t%P2"; }
+  { return ASM_BYTE "0x66\n\tlea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}\n" ASM_SHORT "0x6666\n\trex64\n\tcall\t%P2"; }
   [(set_attr "type" "multi")
    (set_attr "length" "16")])
 
@@ -14573,24 +14558,10 @@
    (clobber (match_scratch:SI 4 "=c"))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_64BIT && TARGET_GNU_TLS"
-  "lea{l}\t{%&@TLSLDM(%1), %0|%0, %&@TLSLDM[%1]}\;call\t%P2"
+  "lea{l}\t{%&@tlsldm(%1), %0|%0, %&@tlsldm[%1]}\;call\t%P2"
   [(set_attr "type" "multi")
    (set_attr "length" "11")])
 
-(define_insn "*tls_local_dynamic_base_32_sun"
-  [(set (match_operand:SI 0 "register_operand" "=a")
-	(unspec:SI [(match_operand:SI 1 "register_operand" "b")
-                    (match_operand:SI 2 "call_insn_operand" "")]
-		   UNSPEC_TLS_LD_BASE))
-   (clobber (match_scratch:SI 3 "=d"))
-   (clobber (match_scratch:SI 4 "=c"))
-   (clobber (reg:CC FLAGS_REG))]
-  "!TARGET_64BIT && TARGET_SUN_TLS"
-  "lea{l}\t{%&@TMDNX(%1), %3|%3, %&@TMDNX[%1]}
-	push{l}\t%3\;call\t%&@TLSPLT\;pop{l}\t%3"
-  [(set_attr "type" "multi")
-   (set_attr "length" "13")])
-
 (define_expand "tls_local_dynamic_base_32"
   [(parallel [(set (match_operand:SI 0 "register_operand" "")
 		   (unspec:SI [(match_dup 1) (match_dup 2)]
@@ -14622,7 +14593,7 @@
 		 (match_operand:DI 2 "" "")))
    (unspec:DI [(const_int 0)] UNSPEC_TLS_LD_BASE)]
   "TARGET_64BIT"
-  "lea{q}\t{%&@TLSLD(%%rip), %%rdi|rdi, %&@TLSLD[rip]}\;call\t%P1"
+  "lea{q}\t{%&@tlsld(%%rip), %%rdi|rdi, %&@tlsld[rip]}\;call\t%P1"
   [(set_attr "type" "multi")
    (set_attr "length" "12")])
 
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/config/i386/sol2-10.h
--- a/gcc/config/i386/sol2-10.h	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/config/i386/sol2-10.h	Wed Feb 17 14:19:49 2010 +0100
@@ -50,6 +50,21 @@
   } while (0)
 #endif
 
+/* As in sol2.h, override the default from i386/x86-64.h to work around
+   Sun as TLS bug.  */
+#undef  ASM_OUTPUT_ALIGNED_COMMON
+#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
+  do									\
+    {									\
+      if (TARGET_SUN_TLS						\
+	  && in_section							\
+	  && ((in_section->common.flags & (SECTION_TLS | SECTION_BSS))	\
+	      == (SECTION_TLS | SECTION_BSS)))				\
+	switch_to_section (bss_section);				\
+      x86_elf_aligned_common (FILE, NAME, SIZE, ALIGN);			\
+    }									\
+  while  (0)
+
 #undef NO_PROFILE_COUNTERS
 
 #undef MCOUNT_NAME
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/config/i386/sol2-gas.h
--- a/gcc/config/i386/sol2-gas.h	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/config/i386/sol2-gas.h	Wed Feb 17 14:19:49 2010 +0100
@@ -26,3 +26,6 @@
 
 /* Undefine this so that BNSYM/ENSYM pairs are emitted by STABS+.  */
 #undef NO_DBX_BNSYM_ENSYM
+
+/* Restore default; gas doesn't understand Sun as .tcomm.  */
+#undef TLS_COMMON_ASM_OP
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/config/i386/sol2.h
--- a/gcc/config/i386/sol2.h	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/config/i386/sol2.h	Wed Feb 17 14:19:49 2010 +0100
@@ -91,6 +91,43 @@
       }							\
   } while (0)
 
+/* Follow Sun requirements for TLS code sequences and use Sun assembler TLS
+   syntax.  */
+#undef TARGET_SUN_TLS
+#define TARGET_SUN_TLS 1
+
+/* The Sun assembler uses .tcomm for TLS common sections.  */
+#define TLS_COMMON_ASM_OP ".tcomm"
+
+/* Similar to the Sun assembler on SPARC, the native assembler requires
+   TLS objects to be declared as @tls_obj (not @tls_object).  Unlike SPARC,
+   gas doesn't understand this variant.  */
+#ifndef USE_GAS
+#undef  ASM_DECLARE_OBJECT_NAME
+#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)		\
+  do								\
+    {								\
+      HOST_WIDE_INT size;					\
+								\
+      if (targetm.have_tls && DECL_THREAD_LOCAL_P (DECL))	\
+	ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "tls_obj");	\
+      else							\
+	ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");	\
+								\
+      size_directive_output = 0;				\
+      if (!flag_inhibit_size_directive				\
+	  && (DECL) && DECL_SIZE (DECL))			\
+	{							\
+	  size_directive_output = 1;				\
+	  size = int_size_in_bytes (TREE_TYPE (DECL));		\
+	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);		\
+	}							\
+								\
+      ASM_OUTPUT_LABEL (FILE, NAME);				\
+    }								\
+  while (0)
+#endif
+
 /* The Solaris assembler cannot grok .stabd directives.  */
 #undef NO_DBX_BNSYM_ENSYM
 #define NO_DBX_BNSYM_ENSYM 1
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/config/sol2.h
--- a/gcc/config/sol2.h	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/config/sol2.h	Wed Feb 17 14:19:49 2010 +0100
@@ -1,6 +1,7 @@
 /* Operating system specific defines to be used when targeting GCC for any
    Solaris 2 system.
-   Copyright 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -265,6 +266,24 @@
     }								\
   while (0)
 
+/* Solaris 'as' has a bug: a .common directive in .tbss section
+   behaves as .tls_common rather than normal non-TLS .common.  */
+#undef  ASM_OUTPUT_ALIGNED_COMMON
+#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
+  do									\
+    {									\
+      if (TARGET_SUN_TLS						\
+	  && in_section							\
+	  && ((in_section->common.flags & (SECTION_TLS | SECTION_BSS))	\
+	      == (SECTION_TLS | SECTION_BSS)))				\
+	switch_to_section (bss_section);				\
+      fprintf ((FILE), "%s", COMMON_ASM_OP);				\
+      assemble_name ((FILE), (NAME));					\
+      fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",		\
+	       (SIZE), (ALIGN) / BITS_PER_UNIT);			\
+    }									\
+  while (0)
+
 extern GTY(()) tree solaris_pending_aligns;
 extern GTY(()) tree solaris_pending_inits;
 extern GTY(()) tree solaris_pending_finis;
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/config/sparc/sol2.h
--- a/gcc/config/sparc/sol2.h	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/config/sparc/sol2.h	Wed Feb 17 14:19:49 2010 +0100
@@ -182,22 +182,4 @@
     }								\
   while (0)
 
-/* Solaris 'as' has a bug: a .common directive in .tbss section
-   behaves as .tls_common rather than normal non-TLS .common.  */
-#undef  ASM_OUTPUT_ALIGNED_COMMON
-#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
-  do									\
-    {									\
-      if (TARGET_SUN_TLS						\
-	  && in_section							\
-	  && ((in_section->common.flags & (SECTION_TLS | SECTION_BSS))	\
-	      == (SECTION_TLS | SECTION_BSS)))				\
-	switch_to_section (bss_section);				\
-      fprintf ((FILE), "%s", COMMON_ASM_OP);				\
-      assemble_name ((FILE), (NAME));					\
-      fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",		\
-	       (SIZE), (ALIGN) / BITS_PER_UNIT);			\
-    }									\
-  while (0)
-
 #define MD_UNWIND_SUPPORT "config/sparc/sol2-unwind.h"
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/configure
--- a/gcc/configure	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/configure	Wed Feb 17 14:19:49 2010 +0100
@@ -21946,25 +21946,52 @@
 	tls_first_minor=17
 	;;
   i[34567]86-*-*)
-    conftest_s='
-	.section ".tdata","awT",@progbits
+    case "$target" in
+      i[34567]86-*-solaris2.[56789]*)
+	# TLS was introduced in the Solaris 9 4/04 release but
+	# we do not enable it by default on Solaris 9 either.
+	if test "x$enable_tls" = xyes ; then
+	  on_solaris=yes
+	else
+	  enable_tls=no;
+	fi
+	;;
+      i[34567]86-*-solaris2.*)
+	on_solaris=yes
+	;;
+      *)
+	on_solaris=no
+	;;
+    esac
+    if test x$on_solaris = xyes && test x$gas_flag = xno; then
+      conftest_s='
+	.section .tdata,"awt",@progbits'
+      tls_first_major=0
+      tls_first_minor=0
+      # See below for the definition of TLS_SECTION_ASM_FLAG.  autoconf chokes
+      # if it is moved here.
+    else
+      conftest_s='
+	.section ".tdata","awT",@progbits'
+      tls_first_major=2
+      tls_first_minor=14
+      tls_as_opt="--fatal-warnings"
+    fi
+    conftest_s="$conftest_s
 foo:	.long	25
 	.text
 	movl	%gs:0, %eax
-	leal	foo@TLSGD(,%ebx,1), %eax
-	leal	foo@TLSLDM(%ebx), %eax
-	leal	foo@DTPOFF(%eax), %edx
-	movl	foo@GOTTPOFF(%ebx), %eax
-	subl	foo@GOTTPOFF(%ebx), %eax
-	addl	foo@GOTNTPOFF(%ebx), %eax
-	movl	foo@INDNTPOFF, %eax
-	movl	$foo@TPOFF, %eax
-	subl	$foo@TPOFF, %eax
-	leal	foo@NTPOFF(%ecx), %eax'
-	tls_first_major=2
-	tls_first_minor=14
-	tls_as_opt=--fatal-warnings
-	;;
+	leal	foo@tlsgd(,%ebx,1), %eax
+	leal	foo@tlsldm(%ebx), %eax
+	leal	foo@dtpoff(%eax), %edx
+	movl	foo@gottpoff(%ebx), %eax
+	subl	foo@gottpoff(%ebx), %eax
+	addl	foo@gotntpoff(%ebx), %eax
+	movl	foo@indntpoff, %eax
+	movl	\$foo@tpoff, %eax
+	subl	\$foo@tpoff, %eax
+	leal	foo@ntpoff(%ecx), %eax"
+    ;;
   x86_64-*-*)
     conftest_s='
 	.section ".tdata","awT",@progbits
@@ -22266,6 +22293,17 @@
   set_have_as_tls=yes
 fi
 fi
+# Strictly belongs to the i[34567]86-*-solaris2* section above, but autoconf
+# chokes on that.
+if test x$on_solaris = xyes && test x$gas_flag = xno; then
+  case "$target" in
+    i[34567]86-*-solaris2*)
+
+$as_echo "#define TLS_SECTION_ASM_FLAG 't'" >>confdefs.h
+
+      ;;
+  esac
+fi
 if test $set_have_as_tls = yes ; then
 
 $as_echo "#define HAVE_AS_TLS 1" >>confdefs.h
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/configure.ac
--- a/gcc/configure.ac	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/configure.ac	Wed Feb 17 14:19:49 2010 +0100
@@ -2,7 +2,7 @@
 # Process this file with autoconf to generate a configuration script.
 
 # Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-# 2007, 2008, 2009 Free Software Foundation, Inc.
+# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 #This file is part of GCC.
 
@@ -2579,25 +2579,52 @@
 	tls_first_minor=17
 	;;
   i[34567]86-*-*)
-    conftest_s='
-	.section ".tdata","awT",@progbits
+    case "$target" in
+      i[34567]86-*-solaris2.[56789]*)
+	# TLS was introduced in the Solaris 9 4/04 release but
+	# we do not enable it by default on Solaris 9 either.
+	if test "x$enable_tls" = xyes ; then
+	  on_solaris=yes
+	else
+	  enable_tls=no;
+	fi
+	;;
+      i[34567]86-*-solaris2.*)
+	on_solaris=yes
+	;;
+      *)
+	on_solaris=no
+	;;
+    esac
+    if test x$on_solaris = xyes && test x$gas_flag = xno; then
+      conftest_s='
+	.section .tdata,"awt",@progbits'
+      tls_first_major=0
+      tls_first_minor=0
+      # See below for the definition of TLS_SECTION_ASM_FLAG.  autoconf chokes
+      # if it is moved here.
+    else
+      conftest_s='
+	.section ".tdata","awT",@progbits'
+      tls_first_major=2
+      tls_first_minor=14
+      tls_as_opt="--fatal-warnings"
+    fi
+    conftest_s="$conftest_s
 foo:	.long	25
 	.text
 	movl	%gs:0, %eax
-	leal	foo@TLSGD(,%ebx,1), %eax
-	leal	foo@TLSLDM(%ebx), %eax
-	leal	foo@DTPOFF(%eax), %edx
-	movl	foo@GOTTPOFF(%ebx), %eax
-	subl	foo@GOTTPOFF(%ebx), %eax
-	addl	foo@GOTNTPOFF(%ebx), %eax
-	movl	foo@INDNTPOFF, %eax
-	movl	$foo@TPOFF, %eax
-	subl	$foo@TPOFF, %eax
-	leal	foo@NTPOFF(%ecx), %eax'
-	tls_first_major=2
-	tls_first_minor=14
-	tls_as_opt=--fatal-warnings
-	;;
+	leal	foo@tlsgd(,%ebx,1), %eax
+	leal	foo@tlsldm(%ebx), %eax
+	leal	foo@dtpoff(%eax), %edx
+	movl	foo@gottpoff(%ebx), %eax
+	subl	foo@gottpoff(%ebx), %eax
+	addl	foo@gotntpoff(%ebx), %eax
+	movl	foo@indntpoff, %eax
+	movl	\$foo@tpoff, %eax
+	subl	\$foo@tpoff, %eax
+	leal	foo@ntpoff(%ecx), %eax"
+    ;;
   x86_64-*-*)
     conftest_s='
 	.section ".tdata","awT",@progbits
@@ -2871,6 +2898,16 @@
   [$tls_first_major,$tls_first_minor,0], [$tls_as_opt], [$conftest_s],,
   [set_have_as_tls=yes])
 fi
+# Strictly belongs to the i[34567]86-*-solaris2* section above, but autoconf
+# chokes on that.
+if test x$on_solaris = xyes && test x$gas_flag = xno; then
+  case "$target" in
+    i[[34567]]86-*-solaris2*)
+      AC_DEFINE(TLS_SECTION_ASM_FLAG, 't',
+[Define to the flag used to mark TLS sections if the default (`T') doesn't work.])
+      ;;
+  esac
+fi
 if test $set_have_as_tls = yes ; then
   AC_DEFINE(HAVE_AS_TLS, 1,
 	    [Define if your assembler supports thread-local storage.])
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/defaults.h
--- a/gcc/defaults.h	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/defaults.h	Wed Feb 17 14:19:49 2010 +0100
@@ -1,6 +1,6 @@
 /* Definitions of various defaults for tm.h macros.
    Copyright (C) 1992, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2007, 2008, 2009
+   2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Ron Guilmette (rfg@monkeys.com)
 
@@ -118,11 +118,15 @@
 #endif
 #endif
 
+#ifndef TLS_COMMON_ASM_OP
+#define TLS_COMMON_ASM_OP ".tls_common"
+#endif
+
 #if defined (HAVE_AS_TLS) && !defined (ASM_OUTPUT_TLS_COMMON)
 #define ASM_OUTPUT_TLS_COMMON(FILE, DECL, NAME, SIZE)			\
   do									\
     {									\
-      fprintf ((FILE), "\t.tls_common\t");				\
+      fprintf ((FILE), "\t%s\t", TLS_COMMON_ASM_OP);			\
       assemble_name ((FILE), (NAME));					\
       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",		\
 	       (SIZE), DECL_ALIGN (DECL) / BITS_PER_UNIT);		\
diff -r 07a4c477186c -r 12f2e6ffa730 gcc/varasm.c
--- a/gcc/varasm.c	Wed Feb 17 09:08:19 2010 +0100
+++ b/gcc/varasm.c	Wed Feb 17 14:19:49 2010 +0100
@@ -6029,6 +6029,10 @@
   gcc_unreachable ();
 }
 
+#ifndef TLS_SECTION_ASM_FLAG
+#define TLS_SECTION_ASM_FLAG 'T'
+#endif
+
 void
 default_elf_asm_named_section (const char *name, unsigned int flags,
 			       tree decl ATTRIBUTE_UNUSED)
@@ -6059,7 +6063,7 @@
   if (flags & SECTION_STRINGS)
     *f++ = 'S';
   if (flags & SECTION_TLS)
-    *f++ = 'T';
+    *f++ = TLS_SECTION_ASM_FLAG;
   if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
     *f++ = 'G';
   *f = '\0';


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]