about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-01-07 11:36:07 +0000
committerUlrich Drepper <drepper@redhat.com>2005-01-07 11:36:07 +0000
commit8222199266b283514206a99247f8e3d3b63e2037 (patch)
tree2ba16e8cdd9f73cd977715c3277326f1220e58f0
parentea0034f3bf8e5e3733f8193e708db83452cf15c0 (diff)
downloadglibc-8222199266b283514206a99247f8e3d3b63e2037.tar.gz
glibc-8222199266b283514206a99247f8e3d3b63e2037.tar.xz
glibc-8222199266b283514206a99247f8e3d3b63e2037.zip
Update.
2005-01-07  Ulrich Drepper  <drepper@redhat.com>

	* elf/rtld.c [!DONT_USE_BOOTSTRAP_MAP] (_dl_start_final): Initialize
	l_relocated of rtld map.
	* sysdeps/powerpc/powerpc64/dl-trampoline.S: New file.
	* sysdeps/powerpc/powerpc64/dl-machine.h: Remove trampoline code here.
	Define ARCH_LA_PLTENTER and ARCH_LA_PLTEXIT.
	* sysdeps/generic/ldsodefs.h (struct audif_ifaces): Add ppc64 variants.
	* elf/tst-auditmod1.c: Add ppc64 support.
	* sysdeps/powerpc/powerpc64/bits/link.h: New file.
-rw-r--r--ChangeLog11
-rw-r--r--elf/rtld.c1
-rw-r--r--elf/tst-auditmod1.c24
-rw-r--r--sysdeps/generic/ldsodefs.h14
-rw-r--r--sysdeps/powerpc/powerpc64/bits/link.h70
-rw-r--r--sysdeps/powerpc/powerpc64/dl-machine.h93
-rw-r--r--sysdeps/powerpc/powerpc64/dl-trampoline.S118
7 files changed, 243 insertions, 88 deletions
diff --git a/ChangeLog b/ChangeLog
index e96ca82443..3d20f37a8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-01-07  Ulrich Drepper  <drepper@redhat.com>
+
+	* elf/rtld.c [!DONT_USE_BOOTSTRAP_MAP] (_dl_start_final): Initialize
+	l_relocated of rtld map.
+	* sysdeps/powerpc/powerpc64/dl-trampoline.S: New file.
+	* sysdeps/powerpc/powerpc64/dl-machine.h: Remove trampoline code here.
+	Define ARCH_LA_PLTENTER and ARCH_LA_PLTEXIT.
+	* sysdeps/generic/ldsodefs.h (struct audif_ifaces): Add ppc64 variants.
+	* elf/tst-auditmod1.c: Add ppc64 support.
+	* sysdeps/powerpc/powerpc64/bits/link.h: New file.
+
 2005-01-06  Roland McGrath  <roland@redhat.com>
 
 	[BZ #633]
diff --git a/elf/rtld.c b/elf/rtld.c
index 1d08c932f2..c9ed64a7a8 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -263,6 +263,7 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
   memcpy (GL(dl_rtld_map).l_info, info->l.l_info,
 	  sizeof GL(dl_rtld_map).l_info);
   GL(dl_rtld_map).l_mach = info->l.l_mach;
+  GL(dl_rtld_map).l_relocated = 1;
 #endif
   _dl_setup_hash (&GL(dl_rtld_map));
   GL(dl_rtld_map).l_real = &GL(dl_rtld_map);
diff --git a/elf/tst-auditmod1.c b/elf/tst-auditmod1.c
index 7d39857d59..987a548067 100644
--- a/elf/tst-auditmod1.c
+++ b/elf/tst-auditmod1.c
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <bits/wordsize.h>
 #include <gnu/lib-names.h>
 
 
@@ -147,6 +148,29 @@ la_x86_64_gnu_pltexit (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
 
   return 0;
 }
+#elif defined __powerpc__ && __WORDSIZE == 64
+uintptr_t
+la_ppc64_gnu_pltenter (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
+		       uintptr_t *defcook, La_ppc64_regs *regs,
+		       unsigned int *flags, const char *symname,
+		       long int *framesizep)
+{
+  printf ("ppc64_pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
+	  symname, (long int) sym->st_value, ndx, *flags);
+
+  return sym->st_value;
+}
+
+unsigned int
+la_ppc64_gnu_pltexit (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
+		      uintptr_t *defcook, const La_ppc64_regs *inregs,
+		      La_ppc64_retval *outregs, const char *symname)
+{
+  printf ("ppc64_pltexit: symname=%s, st_value=%#lx, ndx=%u, retval=%tu\n",
+	  symname, (long int) sym->st_value, ndx, outregs->lrv_r3);
+
+  return 0;
+}
 #else
 # error "architecture specific code needed"
 #endif
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 4a181f4009..108b63b186 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -1,5 +1,5 @@
 /* Run-time dynamic linker data structures for loaded ELF shared objects.
-   Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1995-2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -179,6 +179,8 @@ struct La_i86_regs;
 struct La_i86_retval;
 struct La_x86_64_regs;
 struct La_x86_64_retval;
+struct La_ppc64_regs;
+struct La_ppc64_retval;
 
 
 struct audit_ifaces
@@ -205,6 +207,11 @@ struct audit_ifaces
 				      const struct La_x86_64_regs *,
 				      unsigned int *, const char *name,
 				      long int *framesizep);
+    uintptr_t (*ppc64_gnu_pltenter) (Elf64_Sym *, unsigned int, uintptr_t *,
+				     uintptr_t *,
+				     const struct La_ppc64_regs *,
+				     unsigned int *, const char *name,
+				     long int *framesizep);
   };
   union
   {
@@ -216,6 +223,11 @@ struct audit_ifaces
 					const struct La_x86_64_regs *,
 					struct La_x86_64_retval *,
 					const char *);
+    unsigned int (*ppc64_gnu_pltexit) (Elf64_Sym *, unsigned int, uintptr_t *,
+				       uintptr_t *,
+				       const struct La_ppc64_regs *,
+				       struct La_ppc64_retval *,
+				       const char *);
   };
   unsigned int (*objclose) (uintptr_t *);
 
diff --git a/sysdeps/powerpc/powerpc64/bits/link.h b/sysdeps/powerpc/powerpc64/bits/link.h
new file mode 100644
index 0000000000..e4988fef53
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/bits/link.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef	_LINK_H
+# error "Never include <bits/link.h> directly; use <link.h> instead."
+#endif
+
+
+#if __ELF_NATIVE_CLASS == 32
+
+#error "fill in ppc32 data"
+
+#else
+
+/* Registers for entry into PLT on x86-64.  */
+typedef struct La_ppc64_regs
+{
+  uint64_t lr_reg[8];
+  double lr_fp[13];
+  uint32_t lr_vreg[12][4];
+  uint64_t lr_r1;
+  uint64_t lr_lr;
+} La_ppc64_regs;
+
+/* Return values for calls from PLT on x86-64.  */
+typedef struct La_ppc64_retval
+{
+  uint64_t lrv_r3;
+  uint64_t lrv_r4;
+  double lrv_fp[8];
+  uint32_t lrv_v2[4];
+} La_ppc64_retval;
+
+
+__BEGIN_DECLS
+
+extern Elf64_Addr la_ppc64_gnu_pltenter (Elf64_Sym *__sym,
+					 unsigned int __ndx,
+					 uintptr_t *__refcook,
+					 uintptr_t *__defcook,
+					 La_ppc64_regs *__regs,
+					 unsigned int *__flags,
+					 const char *__symname,
+					 long int *__framesizep);
+extern unsigned int la_ppc64_gnu_pltexit (Elf64_Sym *__sym,
+					  unsigned int __ndx,
+					  uintptr_t *__refcook,
+					  uintptr_t *__defcook,
+					  const La_ppc64_regs *__inregs,
+					  La_ppc64_retval *__outregs,
+					  const char *symname);
+
+__END_DECLS
+
+#endif
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
index 3fcf77df71..80c7d9f4ec 100644
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
@@ -1,6 +1,6 @@
 /* Machine-dependent ELF dynamic relocation inline functions.
    PowerPC64 version.
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -107,92 +107,6 @@ elf_machine_dynamic (void)
 /* The PLT uses Elf64_Rela relocs.  */
 #define elf_machine_relplt elf_machine_rela
 
-/* This code gets called via a .glink stub which loads PLT0.  It is
-   used in dl-runtime.c to call the `fixup' function and then redirect
-   to the address `fixup' returns.
-
-   Enter with r0 = plt reloc index,
-   r2 = ld.so tocbase,
-   r11 = ld.so link map.  */
-
-#define TRAMPOLINE_TEMPLATE(tramp_name, fixup_name) \
-  asm (".section \".text\"\n"						\
-"	.align	2\n"							\
-"	.type	" BODY_PREFIX #tramp_name ",@function\n"		\
-"	.section \".opd\",\"aw\"\n"					\
-"	.align	3\n"							\
-"	.globl	" #tramp_name "\n"					\
-"	" ENTRY_2(tramp_name) "\n"					\
-#tramp_name ":\n"							\
-"	" OPD_ENT(tramp_name) "\n"					\
-"	.previous\n"							\
-BODY_PREFIX #tramp_name ":\n"						\
-/* We need to save the registers used to pass parameters, ie. r3 thru	\
-   r10; the registers are saved in a stack frame.  */			\
-"	stdu	1,-128(1)\n"						\
-"	std	3,48(1)\n"						\
-"	mr	3,11\n"							\
-"	std	4,56(1)\n"						\
-"	sldi	4,0,1\n"						\
-"	std	5,64(1)\n"						\
-"	add	4,4,0\n"						\
-"	std	6,72(1)\n"						\
-"	sldi	4,4,3\n"						\
-"	std	7,80(1)\n"						\
-"	mflr	0\n"							\
-"	std	8,88(1)\n"						\
-/* Store the LR in the LR Save area of the previous frame.  */    	\
-"	std	0,128+16(1)\n"						\
-"	mfcr	0\n"							\
-"	std	9,96(1)\n"						\
-"	std	10,104(1)\n"						\
-/* I'm almost certain we don't have to save cr...  be safe.  */    	\
-"	std	0,8(1)\n"						\
-"	bl	" DOT_PREFIX #fixup_name "\n"				\
-/* Put the registers back.  */						\
-"	ld	0,128+16(1)\n"						\
-"	ld	10,104(1)\n"						\
-"	ld	9,96(1)\n"						\
-"	ld	8,88(1)\n"						\
-"	ld	7,80(1)\n"						\
-"	mtlr	0\n"							\
-"	ld	0,8(1)\n"						\
-"	ld	6,72(1)\n"						\
-"	ld	5,64(1)\n"						\
-"	ld	4,56(1)\n"						\
-"	mtcrf	0xFF,0\n"						\
-/* Load the target address, toc and static chain reg from the function  \
-   descriptor returned by fixup.  */					\
-"	ld	0,0(3)\n"						\
-"	ld	2,8(3)\n"						\
-"	mtctr	0\n"							\
-"	ld	11,16(3)\n"						\
-"	ld	3,48(1)\n"						\
-/* Unwind the stack frame, and jump.  */				\
-"	addi	1,1,128\n"						\
-"	bctr\n"								\
-".LT_" #tramp_name ":\n"						\
-"	.long 0\n"							\
-"	.byte 0x00,0x0c,0x24,0x40,0x00,0x00,0x00,0x00\n"		\
-"	.long .LT_" #tramp_name "-" BODY_PREFIX #tramp_name "\n"	\
-"	.short .LT_" #tramp_name "_name_end-.LT_" #tramp_name "_name_start\n" \
-".LT_" #tramp_name "_name_start:\n"					\
-"	.ascii \"" #tramp_name "\"\n"					\
-".LT_" #tramp_name "_name_end:\n"					\
-"	.align 2\n"							\
-"	" END_2(tramp_name) "\n"					\
-"	.previous");
-
-#ifndef PROF
-#define ELF_MACHINE_RUNTIME_TRAMPOLINE			\
-  TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup);	\
-  TRAMPOLINE_TEMPLATE (_dl_profile_resolve, profile_fixup);
-#else
-#define ELF_MACHINE_RUNTIME_TRAMPOLINE			\
-  TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup);	\
-  void _dl_runtime_resolve (void);			\
-  strong_alias (_dl_runtime_resolve, _dl_profile_resolve);
-#endif
 
 #ifdef HAVE_INLINED_SYSCALLS
 /* We do not need _dl_starting_up.  */
@@ -545,6 +459,11 @@ elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
   return value + reloc->r_addend;
 }
 
+
+/* Names of the architecture-specific auditing callback functions.  */
+#define ARCH_LA_PLTENTER ppc64_gnu_pltenter
+#define ARCH_LA_PLTEXIT ppc64_gnu_pltexit
+
 #endif /* dl_machine_h */
 
 #ifdef RESOLVE_MAP
diff --git a/sysdeps/powerpc/powerpc64/dl-trampoline.S b/sysdeps/powerpc/powerpc64/dl-trampoline.S
new file mode 100644
index 0000000000..71d16f2dba
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/dl-trampoline.S
@@ -0,0 +1,118 @@
+/* PLT trampolines.  PPC64 version.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sysdep.h>
+
+	.section ".text"
+
+EALIGN(_dl_runtime_resolve, 4, 0)
+/* We need to save the registers used to pass parameters, ie. r3 thru
+   r10; the registers are saved in a stack frame.  */
+	stdu	1,-128(1)
+	std	3,48(1)
+	mr	3,11
+	std	4,56(1)
+	sldi	4,0,1
+	std	5,64(1)
+	add	4,4,0
+	std	6,72(1)
+	sldi	4,4,3
+	std	7,80(1)
+	mflr	0
+	std	8,88(1)
+/* Store the LR in the LR Save area of the previous frame.  */
+	std	0,128+16(1)
+	mfcr	0
+	std	9,96(1)
+	std	10,104(1)
+/* I'm almost certain we don't have to save cr...  be safe.  */
+	std	0,8(1)
+	bl	JUMPTARGET(_dl_fixup)
+/* Put the registers back.  */
+	ld	0,128+16(1)
+	ld	10,104(1)
+	ld	9,96(1)
+	ld	8,88(1)
+	ld	7,80(1)
+	mtlr	0
+	ld	0,8(1)
+	ld	6,72(1)
+	ld	5,64(1)
+	ld	4,56(1)
+	mtcrf	0xFF,0
+/* Load the target address, toc and static chain reg from the function
+   descriptor returned by fixup.  */
+	ld	0,0(3)
+	ld	2,8(3)
+	mtctr	0
+	ld	11,16(3)
+	ld	3,48(1)
+/* Unwind the stack frame, and jump.  */
+	addi	1,1,128
+	bctr
+END(_dl_runtime_resolve)
+
+
+
+EALIGN(_dl_profile_resolve, 4, 0)
+/* We need to save the registers used to pass parameters, ie. r3 thru
+   r10; the registers are saved in a stack frame.  */
+	stdu	1,-128(1)
+	std	3,48(1)
+	mr	3,11
+	std	4,56(1)
+	sldi	4,0,1
+	std	5,64(1)
+	add	4,4,0
+	std	6,72(1)
+	sldi	4,4,3
+	std	7,80(1)
+	mflr	0
+	std	8,88(1)
+/* Store the LR in the LR Save area of the previous frame.  */
+	std	0,128+16(1)
+	mfcr	0
+	std	9,96(1)
+	std	10,104(1)
+/* I'm almost certain we don't have to save cr...  be safe.  */
+	std	0,8(1)
+	bl	JUMPTARGET(_dl_profile_fixup)
+/* Put the registers back.  */
+	ld	0,128+16(1)
+	ld	10,104(1)
+	ld	9,96(1)
+	ld	8,88(1)
+	ld	7,80(1)
+	mtlr	0
+	ld	0,8(1)
+	ld	6,72(1)
+	ld	5,64(1)
+	ld	4,56(1)
+	mtcrf	0xFF,0
+/* Load the target address, toc and static chain reg from the function
+   descriptor returned by fixup.  */
+	ld	0,0(3)
+	ld	2,8(3)
+	mtctr	0
+	ld	11,16(3)
+	ld	3,48(1)
+/* Unwind the stack frame, and jump.  */
+	addi	1,1,128
+	bctr
+END(_dl_profile_resolve)