This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: new ppc32 GOT/PLT support
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Alan Modra <amodra at bigpond dot net dot au>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Fri, 10 Jun 2005 17:56:22 +0200
- Subject: Re: new ppc32 GOT/PLT support
- References: <20050517143353.GO27573@bubble.grove.modra.org> <20050525142810.GF11771@bubble.grove.modra.org> <20050607060032.GR7663@sunsite.mff.cuni.cz>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Jun 07, 2005 at 08:00:32AM +0200, Jakub Jelinek wrote:
> On Wed, May 25, 2005 at 11:58:10PM +0930, Alan Modra wrote:
> > Revised ppc32 non-exec PLT/GOT support, which applies on top of
> > http://sources.redhat.com/ml/libc-alpha/2005-05/msg00047.html, which
> > hasn't yet been applied.
> >
> > Changes from the last patch: Removed PIC-ccflag fudge as -fPIC and
> > -mdata-plt now work together. CGOTSETUP and CGOTRESTORE defines in
> > sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h to handle
> > init of r30 for plt calls to __librt_{en,dis}able_asynccancel.
> >
> > Tested with no "make check" regressions on nptl enabled powerpc-linux,
> > both with new and old ABI compilers.
>
> Seems to work for me.
Oh, and for prelink we need this patch as well on top of yours.
I'll release prelink that can handle both old and new style ppc32 PLT
momentarily.
2005-06-10 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_runtime_setup):
Handle prelinked libraries and binaries with new style PLT.
--- libc/sysdeps/powerpc/powerpc32/dl-machine.h.jj 2005-06-06 14:47:23.000000000 +0200
+++ libc/sysdeps/powerpc/powerpc32/dl-machine.h 2005-06-10 16:59:33.000000000 +0200
@@ -182,7 +182,7 @@ elf_machine_runtime_setup (struct link_m
map->l_info[DT_PPC(GOT)]->d_un.d_ptr += map->l_addr;
if (lazy)
{
- Elf32_Addr *plt, *got;
+ Elf32_Addr *plt, *got, glink;
Elf32_Word num_plt_entries;
void (*dlrr) (void);
extern void _dl_runtime_resolve (void);
@@ -198,6 +198,7 @@ elf_machine_runtime_setup (struct link_m
dlrr = _dl_prof_resolve;
}
got = (Elf32_Addr *) map->l_info[DT_PPC(GOT)]->d_un.d_ptr;
+ glink = got[1];
got[1] = (Elf32_Addr) dlrr;
got[2] = (Elf32_Addr) map;
@@ -205,8 +206,20 @@ elf_machine_runtime_setup (struct link_m
plt = (Elf32_Addr *) D_PTR (map, l_info[DT_PLTGOT]);
num_plt_entries = (map->l_info[DT_PLTRELSZ]->d_un.d_val
/ sizeof (Elf32_Rela));
- while (num_plt_entries-- != 0)
- *plt++ += map->l_addr;
+
+ /* If a library is prelinked but we have to relocate anyway,
+ we have to be able to undo the prelinking of .plt section.
+ The prelinker saved us at got[1] address of .glink
+ section's start. */
+ if (glink)
+ {
+ glink += map->l_addr;
+ while (num_plt_entries-- != 0)
+ *plt++ = glink, glink += 4;
+ }
+ else
+ while (num_plt_entries-- != 0)
+ *plt++ += map->l_addr;
}
return lazy;
}
Jakub