This is the mail archive of the binutils@sourceware.org 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]

[PATCH] S/390: Avoid TLS_LE* -> TLS_TPOFF translation for PIE


Hi,

for S/390 there is code which is supposed to handle non-pic objects
being linked to a shared lib.  For TLS this code replaces the TLS_LE*
relocs with a runtime reloc.  The code is triggered by the `shared`
flag and therefore also for PIE.  But for PIE no runtime reloc is
needed since the TLS offsets are always link-time computable.

(Btw. for s390x that special handling is anyway rather questionable
since non-pic code will not work in a shared lib for various other
reasons.)

Fixed with the attached patch.

No regressions on s390 and s390x.

bfd/

2014-09-09  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* elf32-s390.c: Don't replace R_390_TLS_LE32 with R_390_TLS_TPOFF
	for PIE.
	* elf64-s390.c: Don't replace R_390_TLS_LE64 with R_390_TLS_TPOFF
	for PIE.

diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 11c726f..ebcb028 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -1250,6 +1250,12 @@ elf_s390_check_relocs (bfd *abfd,
 	  /* Fall through.  */
 
 	case R_390_TLS_LE32:
+	  /* For static linking and executables this reloc will be
+	     calculated at linktime otherwise a TLS_TPOFF runtime
+	     reloc will be generated.  */
+	  if (r_type == R_390_TLS_LE32 && info->pie)
+	    break;
+
 	  if (!info->shared)
 	    break;
 	  info->flags |= DF_STATIC_TLS;
@@ -3104,7 +3110,7 @@ elf_s390_relocate_section (bfd *output_bfd,
 	  break;
 
 	case R_390_TLS_LE32:
-	  if (info->shared)
+	  if (info->shared && !info->pie)
 	    {
 	      /* Linking a shared library with non-fpic code requires
 		 a R_390_TLS_TPOFF relocation.  */
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index d7b2f08..b2f1aa5 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -1183,6 +1183,12 @@ elf_s390_check_relocs (bfd *abfd,
 	  /* Fall through */
 
 	case R_390_TLS_LE64:
+	  /* For static linking and executables this reloc will be
+	     calculated at linktime otherwise a TLS_TPOFF runtime
+	     reloc will be generated.  */
+	  if (r_type == R_390_TLS_LE64 && info->pie)
+	    break;
+
 	  if (!info->shared)
 	    break;
 	  info->flags |= DF_STATIC_TLS;
@@ -3074,7 +3080,7 @@ elf_s390_relocate_section (bfd *output_bfd,
 	  break;
 
 	case R_390_TLS_LE64:
-	  if (info->shared)
+	  if (info->shared && !info->pie)
 	    {
 	      /* Linking a shared library with non-fpic code requires
 		 a R_390_TLS_TPOFF relocation.  */


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