This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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: new ppc32 GOT/PLT support


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


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