PATCH: PR ld/9938: TLS transition from R_386_TLS_GD to R_386_TLS_IE_32 error

H.J. Lu hongjiu.lu@intel.com
Thu Mar 12 17:13:00 GMT 2009


On Solaris, ___tls_get_addr is versioned, ___tls_get_addr@@SUNWprivate_1.1.
strcmp will fail.  I am checking in this patch to use strncmp instead.

Thanks.


H.J.
----
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.4495
diff -u -p -r1.4495 ChangeLog
--- ChangeLog	12 Mar 2009 10:57:18 -0000	1.4495
+++ ChangeLog	12 Mar 2009 17:11:28 -0000
@@ -1,3 +1,12 @@
+2009-03-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR ld/9938
+	* elf32-i386.c (elf_i386_check_tls_transition): Use strncmp
+	to check ___tls_get_addr.
+
+	* elf64-x86-64.c (elf64_x86_64_check_tls_transition): Use
+	strncmp to check __tls_get_addr.
+
 2009-03-12  Andrew Stubbs  <ams@codesourcery.com>
 
 	* dwarf2.c (read_section): Always check the offset, even when the
Index: elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.192
diff -u -p -r1.192 elf32-i386.c
--- elf32-i386.c	11 Mar 2009 16:42:23 -0000	1.192
+++ elf32-i386.c	12 Mar 2009 17:11:28 -0000
@@ -1007,11 +1007,14 @@ elf_i386_check_tls_transition (bfd *abfd
 	return FALSE;
 
       h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+      /* Use strncmp to check ___tls_get_addr since ___tls_get_addr
+	 may be versioned.  */
       return (h != NULL
 	      && h->root.root.string != NULL
 	      && (ELF32_R_TYPE (rel[1].r_info) == R_386_PC32
 		  || ELF32_R_TYPE (rel[1].r_info) == R_386_PLT32)
-	      && (strcmp (h->root.root.string, "___tls_get_addr") == 0));
+	      && (strncmp (h->root.root.string, "___tls_get_addr",
+			   15) == 0));
 
     case R_386_TLS_IE:
       /* Check transition from IE access model:
Index: elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.151
diff -u -p -r1.151 elf64-x86-64.c
--- elf64-x86-64.c	23 Dec 2008 09:01:45 -0000	1.151
+++ elf64-x86-64.c	12 Mar 2009 17:11:28 -0000
@@ -810,11 +810,14 @@ elf64_x86_64_check_tls_transition (bfd *
 	return FALSE;
 
       h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+      /* Use strncmp to check __tls_get_addr since __tls_get_addr
+	 may be versioned.  */ 
       return (h != NULL
 	      && h->root.root.string != NULL
 	      && (ELF64_R_TYPE (rel[1].r_info) == R_X86_64_PC32
 		  || ELF64_R_TYPE (rel[1].r_info) == R_X86_64_PLT32)
-	      && (strcmp (h->root.root.string, "__tls_get_addr") == 0));
+	      && (strncmp (h->root.root.string,
+			   "__tls_get_addr", 14) == 0));
 
     case R_X86_64_GOTTPOFF:
       /* Check transition from IE access model:



More information about the Binutils mailing list