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]

Re: PPC32 TLS GD and LD force old GOT/PLT layout


On Fri, Mar 10, 2006 at 12:40:56AM -0300, Alexandre Oliva wrote:
> It's not that it fails at run time, it's just that it causes the
> linker to decide that the dynamic libraries need the old GOT and PLT
> layouts, that require executable code in .got and .plt in the data
> segment, rendering the entire data segment executable.  This defeats
> the whole point of -msecure-plt.

Apologies for not getting back to you earlier on this one.  The linker
is at fault here.  A REL32 reloc to .got shouldn't be a problem.  I was
testing REL32 relocs to detect old -fPIC code as this comment says:

	      /* Old -fPIC gcc code has .long LCTOC1-LCFx just before
		 the start of a function, which assembles to a REL32
		 reference to .got2.  If we detect one of these, then
		 force the old PLT layout because the linker cannot
		 reliably deduce the GOT pointer value needed for
		 PLT call stubs.  */

The reason the linker can't deduce the GOT pointer is that we may be
mixing -fPIC code (r30 points into .got2) with -fpic code (r30 points
into .got, at __GLOBAL_OFFSET_TABLE__).  ld -r may have even combined
multiple .got2 sections, so the value in r30 might not be .got2+32768
for -fPIC.  We get around this problem by having new -fPIC gcc plt calls
sneakily encode the .got2 offset in the PLRREL24 reloc addend.  We also
make sure that any function making plt calls has a GOT pointer in r30.
Old gcc code doesn't meet either of these conditions.

	* elf32-ppc.c (ppc_elf_check_relocs): Don't fall into REL24
	checks from REL32.

Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.192
diff -u -p -r1.192 elf32-ppc.c
--- bfd/elf32-ppc.c	2 Mar 2006 09:44:23 -0000	1.192
+++ bfd/elf32-ppc.c	15 Mar 2006 13:03:27 -0000
@@ -3335,7 +3335,9 @@ ppc_elf_check_relocs (bfd *abfd,
 	      if (s == got2)
 		htab->plt_type = PLT_OLD;
 	    }
-	  /* fall through */
+	  if (h == NULL)
+	    break;
+	  goto dodyn;
 
 	case R_PPC_REL24:
 	case R_PPC_REL14:

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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