This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: powerpc linker broken for -fPIC
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sources dot redhat dot com
- Date: Tue, 24 May 2005 01:51:09 +0930
- Subject: Re: powerpc linker broken for -fPIC
- References: <20050520023539.GE27573@bubble.grove.modra.org>
For old -fPIC code, we need to force the old PLT layout. We can't just
assume that if REL16 relocs are present then the code is all new-style.
* elf32-ppc.c (ppc_elf_check_relocs): For old gcc -fPIC code
force old plt layout.
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.162
diff -u -p -r1.162 elf32-ppc.c
--- bfd/elf32-ppc.c 20 May 2005 21:57:10 -0000 1.162
+++ bfd/elf32-ppc.c 23 May 2005 16:11:57 -0000
@@ -3160,14 +3160,32 @@ ppc_elf_check_relocs (bfd *abfd,
info->flags |= DF_STATIC_TLS;
goto dodyn;
- /* When creating a shared object, we must copy these
- relocs into the output file. We create a reloc
- section in dynobj and make room for the reloc. */
+ case R_PPC_REL32:
+ if (h == NULL
+ && got2 != NULL
+ && (sec->flags & SEC_CODE) != 0
+ && (info->shared || info->pie)
+ && !htab->old_plt)
+ {
+ /* 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. */
+ asection *s;
+
+ s = bfd_section_from_r_symndx (abfd, &htab->sym_sec, sec,
+ r_symndx);
+ if (s == got2)
+ htab->old_plt = 1;
+ }
+ /* fall through */
+
case R_PPC_REL24:
case R_PPC_REL14:
case R_PPC_REL14_BRTAKEN:
case R_PPC_REL14_BRNTAKEN:
- case R_PPC_REL32:
if (h == NULL)
break;
if (h == htab->elf.hgot)
--
Alan Modra
IBM OzLabs - Linux Technology Centre