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]

fix ppc32 -msecure-plt TLS relaxation GD->LE


Code compiled with -msecure-plt generates calls to __tls_get_addr with
a nonzero addend, that ends up making to the lower part of the TP
offset computed for the TL variable when Global Dynamic is relaxed to
Local Exec.  This patch fixes it, by arranging for us to refer to the
same location in both relocations.  We already did that for LD->LE,
but not GD->LE.  [LG[D->IE cancels out the second relocation, so its
addend doesn't matter, so I left it along even though it's still
conceptually wrong.

Tested on amd64-linux-gnu-x-ppc64-linux-gnu.  Ok to install?

for binutils/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* elf32-ppc.c (ppc_elf_relocate_section): Copy addend from
	first relocation to the second when relaxing TLS GD to LE.

for ld/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* ld-powerpc/tls32.s: Verify that +32768 @plt addend is
	discarded.

Index: bfd/elf32-ppc.c
===================================================================
--- bfd/elf32-ppc.c.orig	2006-03-09 23:23:41.000000000 -0300
+++ bfd/elf32-ppc.c	2006-03-09 23:25:57.000000000 -0300
@@ -5799,13 +5799,13 @@ ppc_elf_relocate_section (bfd *output_bf
 			  /* Was an LD reloc.  */
 			  r_symndx = 0;
 			  rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
-			  rel[1].r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
 			}
 		      r_type = R_PPC_TPREL16_HA;
 		      rel->r_info = ELF32_R_INFO (r_symndx, r_type);
 		      rel[1].r_info = ELF32_R_INFO (r_symndx,
 						    R_PPC_TPREL16_LO);
 		      rel[1].r_offset += 2;
+		      rel[1].r_addend = rel->r_addend;
 		    }
 		  bfd_put_32 (output_bfd, insn1, contents + rel->r_offset - 2);
 		  bfd_put_32 (output_bfd, insn2, contents + offset);
Index: ld/testsuite/ld-powerpc/tls32.s
===================================================================
--- ld/testsuite/ld-powerpc/tls32.s.orig	2006-03-09 23:31:33.000000000 -0300
+++ ld/testsuite/ld-powerpc/tls32.s	2006-03-09 23:31:52.000000000 -0300
@@ -33,11 +33,11 @@ _start:
 #global syms
 #GD
  addi 3,31,gd0@got@tlsgd	#R_PPC_GOT_TLSGD16	gd0
- bl __tls_get_addr@plt		#R_PPC_PLTREL24		__tls_get_addr
+ bl __tls_get_addr+0x8000@plt	#R_PPC_PLTREL24		__tls_get_addr
 
 #LD
  addi 3,31,ld0@got@tlsld	#R_PPC_GOT_TLSLD16	ld0
- bl __tls_get_addr@plt		#R_PPC_PLTREL24		__tls_get_addr
+ bl __tls_get_addr+0x8000@plt	#R_PPC_PLTREL24		__tls_get_addr
 
  addi 9,3,ld0@dtprel		#R_PPC_DTPREL16		ld0
 
-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Secretary for FSF Latin America        http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

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