This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Re: PATCH: PR 414: Linker crashes with mixed TLS/non-TLS symbols


On Fri, Oct 01, 2004 at 01:03:47PM -0700, H. J. Lu wrote:
> On Fri, Oct 01, 2004 at 08:42:20PM +0930, Alan Modra wrote:
> > On Fri, Oct 01, 2004 at 11:48:14AM +0930, Alan Modra wrote:
> > > HJ's patch brought to light some errors in the ld testsuite.
> > 
> > Some more.
> > 
> > 	* ld-s390/tlsbin.s: Set tls type for undefined syms.
> > 	* ld-s390/tlsbin_64.s: Likewise.
> > 	* ld-s390/tlsbinpic.s: Likewise.
> > 	* ld-s390/tlsbinpic_64.s: Likewise.
> > 	* ld-s390/tlspic1.s: Likewise.
> > 	* ld-s390/tlspic1_64.s: Likewise.
> > 	* ld-sparc/tlssunbin32.s: Likewise.
> > 	* ld-sparc/tlssunbinpic32.s: Likewise.
> > 	* ld-sparc/tlssunnopic32.s: Likewise.
> > 	* ld-sparc/tlssunpic32.s: Likewise.
> > 
> 
> Those testsuite changes aren't needed. We should fix the assembler
> instead. Here is a patch. I will check in my testsuite change first.
> If there is no objection to my assembler change, I will check it in
> later.
> 
> 
> 
> H.J.
> ---
> gas/
> 
> 2004-10-01  H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	* config/tc-ppc.c (md_apply_fix3): Call S_SET_THREAD_LOCAL for
> 	TLS relocations.
> 	* config/tc-s390.c (md_apply_fix3): Likewise.
> 	* config/tc-sparc.c (md_apply_fix3): Likewise.
> 


Apparently, BFD_RELOC_PPC_TLS isn't a real TLS relocation. Also there
are no TLS relocations for Sparc instructions.


H.J.
----
2004-10-01  H.J. Lu  <hongjiu.lu@intel.com>

	* config/tc-ppc.c (md_apply_fix3): Call S_SET_THREAD_LOCAL for
	TLS relocations.
	* config/tc-s390.c (md_apply_fix3): Likewise.
	* config/tc-sparc.c (md_apply_fix3): Likewise.

--- gas/config/tc-ppc.c.tls	2004-08-20 07:55:40.000000000 -0700
+++ gas/config/tc-ppc.c	2004-10-01 14:30:46.000000000 -0700
@@ -5846,6 +5846,8 @@ md_apply_fix3 (fixP, valP, seg)
 	  break;
 
 	case BFD_RELOC_PPC_TLS:
+	  break;
+
 	case BFD_RELOC_PPC_DTPMOD:
 	case BFD_RELOC_PPC_TPREL16:
 	case BFD_RELOC_PPC_TPREL16_LO:
@@ -5885,6 +5887,7 @@ md_apply_fix3 (fixP, valP, seg)
 	case BFD_RELOC_PPC64_DTPREL16_HIGHERA:
 	case BFD_RELOC_PPC64_DTPREL16_HIGHEST:
 	case BFD_RELOC_PPC64_DTPREL16_HIGHESTA:
+	  S_SET_THREAD_LOCAL (fixP->fx_addsy);
 	  break;
 #endif
 	  /* Because SDA21 modifies the register field, the size is set to 4
--- gas/config/tc-s390.c.tls	2004-06-21 14:05:34.000000000 -0700
+++ gas/config/tc-s390.c	2004-10-01 13:00:32.000000000 -0700
@@ -2217,10 +2217,12 @@ md_apply_fix3 (fixP, valP, seg)
 	case BFD_RELOC_390_TLS_DTPMOD:
 	case BFD_RELOC_390_TLS_DTPOFF:
 	case BFD_RELOC_390_TLS_TPOFF:
+	  S_SET_THREAD_LOCAL (fixP->fx_addsy);
 	  /* Fully resolved at link time.  */
 	  break;
 	case BFD_RELOC_390_TLS_IEENT:
 	  /* Fully resolved at link time.  */
+	  S_SET_THREAD_LOCAL (fixP->fx_addsy);
 	  value += 2;
 	  break;
 
--- gas/config/tc-sparc.c.tls	2004-03-15 10:51:08.000000000 -0800
+++ gas/config/tc-sparc.c	2004-10-01 14:35:43.000000000 -0700
@@ -3012,7 +3012,41 @@ md_apply_fix3 (fixP, valP, segment)
 #ifdef OBJ_ELF
   /* SPARC ELF relocations don't use an addend in the data field.  */
   if (fixP->fx_addsy != NULL)
-    return;
+    {
+      switch (fixP->fx_r_type)
+	{
+	case BFD_RELOC_SPARC_TLS_GD_HI22:
+	case BFD_RELOC_SPARC_TLS_GD_LO10:
+	case BFD_RELOC_SPARC_TLS_GD_ADD:
+	case BFD_RELOC_SPARC_TLS_GD_CALL:
+	case BFD_RELOC_SPARC_TLS_LDM_HI22:
+	case BFD_RELOC_SPARC_TLS_LDM_LO10:
+	case BFD_RELOC_SPARC_TLS_LDM_ADD:
+	case BFD_RELOC_SPARC_TLS_LDM_CALL:
+	case BFD_RELOC_SPARC_TLS_LDO_HIX22:
+	case BFD_RELOC_SPARC_TLS_LDO_LOX10:
+	case BFD_RELOC_SPARC_TLS_LDO_ADD:
+	case BFD_RELOC_SPARC_TLS_IE_HI22:
+	case BFD_RELOC_SPARC_TLS_IE_LO10:
+	case BFD_RELOC_SPARC_TLS_IE_LD:
+	case BFD_RELOC_SPARC_TLS_IE_LDX:
+	case BFD_RELOC_SPARC_TLS_IE_ADD:
+	case BFD_RELOC_SPARC_TLS_LE_HIX22:
+	case BFD_RELOC_SPARC_TLS_LE_LOX10:
+	case BFD_RELOC_SPARC_TLS_DTPMOD32:
+	case BFD_RELOC_SPARC_TLS_DTPMOD64:
+	case BFD_RELOC_SPARC_TLS_DTPOFF32:
+	case BFD_RELOC_SPARC_TLS_DTPOFF64:
+	case BFD_RELOC_SPARC_TLS_TPOFF32:
+	case BFD_RELOC_SPARC_TLS_TPOFF64:
+	  S_SET_THREAD_LOCAL (fixP->fx_addsy);
+
+	default:
+	  break;
+	}
+
+      return;
+    }
 #endif
 
   /* This is a hack.  There should be a better way to


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