abe59f
commit 8c0664e2b861fd3789602cc0b0b1922b0e20cb3a
abe59f
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
abe59f
Date:   Thu Jul 22 18:02:42 2021 -0300
abe59f
abe59f
    elf: Add _dl_audit_pltexit
abe59f
    
abe59f
    It consolidates the code required to call la_pltexit audit
abe59f
    callback.
abe59f
    
abe59f
    Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
abe59f
    
abe59f
    Reviewed-by: Florian Weimer <fweimer@redhat.com>
abe59f
abe59f
Conflicts:
abe59f
	nptl/tst-atfork4mod.c
abe59f
	sysdeps/powerpc/fpu/s_fmaf.S
abe59f
	sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
abe59f
	sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S
abe59f
		Without d6d89608ac8cf2b37c75debad1fff653f6939f90 we
abe59f
		don't have dl-machine-rel.h so git picks a match for
abe59f
		all four files above, instead we modify dl-machine.h
abe59f
		for the targets:
abe59f
			sysdeps/i386/dl-machine.h
abe59f
			sysdeps/arm/dl-machine.h
abe59f
			sysdeps/mips/dl-machine.h
abe59f
		The fourth is the generic file and without it we
abe59f
		add the PLTREL macro to each target:
abe59f
			sysdeps/aarch64/dl-machine.h
abe59f
			sysdeps/powerpc/powerpc32/dl-machine.h
abe59f
			sysdeps/powerpc/powerpc64/dl-machine.h
abe59f
			sysdeps/s390/s390-32/dl-machine.h
abe59f
			sysdeps/s390/s390-64/dl-machine.h
abe59f
			sysdeps/x86_64/dl-machine.h
abe59f
	sysdeps/s390/s390-32/dl-trampoline.h
abe59f
	sysdeps/s390/s390-64/dl-trampoline.h
abe59f
abe59f
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
abe59f
index 15250c67e8ac1658..152712b12fed6de2 100644
abe59f
--- a/elf/dl-audit.c
abe59f
+++ b/elf/dl-audit.c
abe59f
@@ -20,6 +20,8 @@
abe59f
 #include <link.h>
abe59f
 #include <ldsodefs.h>
abe59f
 #include <dl-machine.h>
abe59f
+#include <dl-runtime.h>
abe59f
+#include <dl-fixup-attribute.h>
abe59f
 
abe59f
 void
abe59f
 _dl_audit_activity_map (struct link_map *l, int action)
abe59f
@@ -320,3 +322,48 @@ _dl_audit_pltenter (struct link_map *l, struct reloc_result *reloc_result,
abe59f
 
abe59f
   *value = DL_FIXUP_ADDR_VALUE (sym.st_value);
abe59f
 }
abe59f
+
abe59f
+void
abe59f
+DL_ARCH_FIXUP_ATTRIBUTE
abe59f
+_dl_audit_pltexit (struct link_map *l, ElfW(Word) reloc_arg,
abe59f
+		   const void *inregs, void *outregs)
abe59f
+{
abe59f
+  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
abe59f
+
abe59f
+  /* This is the address in the array where we store the result of previous
abe59f
+     relocations.  */
abe59f
+  // XXX Maybe the bound information must be stored on the stack since
abe59f
+  // XXX with bind_not a new value could have been stored in the meantime.
abe59f
+  struct reloc_result *reloc_result =
abe59f
+    &l->l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))];
abe59f
+  ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
abe59f
+					    l_info[DT_SYMTAB])
abe59f
+		       + reloc_result->boundndx);
abe59f
+
abe59f
+  /* Set up the sym parameter.  */
abe59f
+  ElfW(Sym) sym = *defsym;
abe59f
+  sym.st_value = DL_FIXUP_VALUE_ADDR (reloc_result->addr);
abe59f
+
abe59f
+  /* Get the symbol name.  */
abe59f
+  const char *strtab = (const void *) D_PTR (reloc_result->bound,
abe59f
+					     l_info[DT_STRTAB]);
abe59f
+  const char *symname = strtab + sym.st_name;
abe59f
+
abe59f
+  struct audit_ifaces *afct = GLRO(dl_audit);
abe59f
+  for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
abe59f
+    {
abe59f
+      if (afct->ARCH_LA_PLTEXIT != NULL
abe59f
+	  && (reloc_result->enterexit
abe59f
+	      & (LA_SYMB_NOPLTEXIT >> (2 * cnt))) == 0)
abe59f
+	{
abe59f
+	  struct auditstate *l_state = link_map_audit_state (l, cnt);
abe59f
+	  struct auditstate *bound_state
abe59f
+	    = link_map_audit_state (reloc_result->bound, cnt);
abe59f
+	  afct->ARCH_LA_PLTEXIT (&sym, reloc_result->boundndx,
abe59f
+				 &l_state->cookie, &bound_state->cookie,
abe59f
+				 inregs, outregs, symname);
abe59f
+	}
abe59f
+
abe59f
+      afct = afct->next;
abe59f
+    }
abe59f
+}
abe59f
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
abe59f
index b46f7d7376e65361..ec0b2164825fa538 100644
abe59f
--- a/elf/dl-runtime.c
abe59f
+++ b/elf/dl-runtime.c
abe59f
@@ -16,8 +16,6 @@
abe59f
    License along with the GNU C Library; if not, see
abe59f
    <http://www.gnu.org/licenses/>.  */
abe59f
 
abe59f
-#define IN_DL_RUNTIME 1		/* This can be tested in dl-machine.h.  */
abe59f
-
abe59f
 #include <alloca.h>
abe59f
 #include <stdlib.h>
abe59f
 #include <unistd.h>
abe59f
@@ -30,19 +28,6 @@
abe59f
 #include <dl-runtime.h>
abe59f
 
abe59f
 
abe59f
-#if (!ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
abe59f
-    || ELF_MACHINE_NO_REL
abe59f
-# define PLTREL  ElfW(Rela)
abe59f
-#else
abe59f
-# define PLTREL  ElfW(Rel)
abe59f
-#endif
abe59f
-
abe59f
-/* The fixup functions might have need special attributes.  If none
abe59f
-   are provided define the macro as empty.  */
abe59f
-#ifndef ARCH_FIXUP_ATTRIBUTE
abe59f
-# define ARCH_FIXUP_ATTRIBUTE
abe59f
-#endif
abe59f
-
abe59f
 /* This function is called through a special trampoline from the PLT the
abe59f
    first time each PLT entry is called.  We must perform the relocation
abe59f
    specified in the PLT of the given shared object, and return the resolved
abe59f
@@ -51,7 +36,7 @@
abe59f
    function.  */
abe59f
 
abe59f
 DL_FIXUP_VALUE_TYPE
abe59f
-attribute_hidden __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
abe59f
+attribute_hidden __attribute ((noinline)) DL_ARCH_FIXUP_ATTRIBUTE
abe59f
 _dl_fixup (
abe59f
 # ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
abe59f
 	   ELF_MACHINE_RUNTIME_FIXUP_ARGS,
abe59f
@@ -147,7 +132,8 @@ _dl_fixup (
abe59f
 
abe59f
 #ifndef PROF
abe59f
 DL_FIXUP_VALUE_TYPE
abe59f
-__attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
abe59f
+__attribute ((noinline))
abe59f
+DL_ARCH_FIXUP_ATTRIBUTE
abe59f
 _dl_profile_fixup (
abe59f
 #ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
abe59f
 		   ELF_MACHINE_RUNTIME_FIXUP_ARGS,
abe59f
@@ -331,52 +317,3 @@ _dl_profile_fixup (
abe59f
 }
abe59f
 
abe59f
 #endif /* PROF */
abe59f
-
abe59f
-
abe59f
-#include <stdio.h>
abe59f
-void
abe59f
-ARCH_FIXUP_ATTRIBUTE
abe59f
-_dl_call_pltexit (struct link_map *l, ElfW(Word) reloc_arg,
abe59f
-		  const void *inregs, void *outregs)
abe59f
-{
abe59f
-#ifdef SHARED
abe59f
-  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
abe59f
-
abe59f
-  /* This is the address in the array where we store the result of previous
abe59f
-     relocations.  */
abe59f
-  // XXX Maybe the bound information must be stored on the stack since
abe59f
-  // XXX with bind_not a new value could have been stored in the meantime.
abe59f
-  struct reloc_result *reloc_result =
abe59f
-    &l->l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))];
abe59f
-  ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
abe59f
-					    l_info[DT_SYMTAB])
abe59f
-		       + reloc_result->boundndx);
abe59f
-
abe59f
-  /* Set up the sym parameter.  */
abe59f
-  ElfW(Sym) sym = *defsym;
abe59f
-  sym.st_value = DL_FIXUP_VALUE_ADDR (reloc_result->addr);
abe59f
-
abe59f
-  /* Get the symbol name.  */
abe59f
-  const char *strtab = (const void *) D_PTR (reloc_result->bound,
abe59f
-					     l_info[DT_STRTAB]);
abe59f
-  const char *symname = strtab + sym.st_name;
abe59f
-
abe59f
-  struct audit_ifaces *afct = GLRO(dl_audit);
abe59f
-  for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
abe59f
-    {
abe59f
-      if (afct->ARCH_LA_PLTEXIT != NULL
abe59f
-	  && (reloc_result->enterexit
abe59f
-	      & (LA_SYMB_NOPLTEXIT >> (2 * cnt))) == 0)
abe59f
-	{
abe59f
-	  struct auditstate *l_state = link_map_audit_state (l, cnt);
abe59f
-	  struct auditstate *bound_state
abe59f
-	    = link_map_audit_state (reloc_result->bound, cnt);
abe59f
-	  afct->ARCH_LA_PLTEXIT (&sym, reloc_result->boundndx,
abe59f
-				 &l_state->cookie, &bound_state->cookie,
abe59f
-				 inregs, outregs, symname);
abe59f
-	}
abe59f
-
abe59f
-      afct = afct->next;
abe59f
-    }
abe59f
-#endif
abe59f
-}
abe59f
diff --git a/elf/dl-support.c b/elf/dl-support.c
abe59f
index 3e5531138eaa18f8..e9943e889ef447ad 100644
abe59f
--- a/elf/dl-support.c
abe59f
+++ b/elf/dl-support.c
abe59f
@@ -399,3 +399,11 @@ _dl_get_dl_main_map (void)
abe59f
   return &_dl_main_map;
abe59f
 }
abe59f
 #endif
abe59f
+
abe59f
+/* This is used by _dl_runtime_profile, not used on static code.  */
abe59f
+void
abe59f
+DL_ARCH_FIXUP_ATTRIBUTE
abe59f
+_dl_audit_pltexit (struct link_map *l, ElfW(Word) reloc_arg,
abe59f
+		   const void *inregs, void *outregs)
abe59f
+{
abe59f
+}
abe59f
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
abe59f
index 5eab544afe2717f7..c13d896a57811c7d 100644
abe59f
--- a/sysdeps/aarch64/dl-machine.h
abe59f
+++ b/sysdeps/aarch64/dl-machine.h
abe59f
@@ -196,6 +196,7 @@ _dl_start_user:								\n\
abe59f
 /* AArch64 uses RELA not REL */
abe59f
 #define ELF_MACHINE_NO_REL 1
abe59f
 #define ELF_MACHINE_NO_RELA 0
abe59f
+#define PLTREL ElfW(Rela)
abe59f
 
abe59f
 #define DL_PLATFORM_INIT dl_platform_init ()
abe59f
 
abe59f
diff --git a/sysdeps/aarch64/dl-trampoline.S b/sysdeps/aarch64/dl-trampoline.S
abe59f
index a86d0722d4a0415b..18740398e63fdf97 100644
abe59f
--- a/sysdeps/aarch64/dl-trampoline.S
abe59f
+++ b/sysdeps/aarch64/dl-trampoline.S
abe59f
@@ -277,7 +277,7 @@ _dl_runtime_profile:
abe59f
 	ldp	x0, x1, [x29, #OFFSET_SAVED_CALL_X0]
abe59f
 	add	x2, x29, #OFFSET_RG
abe59f
 	add	x3, x29, #OFFSET_RV
abe59f
-	bl	_dl_call_pltexit
abe59f
+	bl	_dl_audit_pltexit
abe59f
 
abe59f
 	ldp	x0, x1, [x29, #OFFSET_RV + DL_OFFSET_RV_X0]
abe59f
 	ldp	d0, d1, [x29, #OFFSET_RV + DL_OFFSET_RV_D0 + 16*0]
abe59f
diff --git a/sysdeps/alpha/dl-trampoline.S b/sysdeps/alpha/dl-trampoline.S
abe59f
index b326b37acedb5eaa..3acf5dec8d9585da 100644
abe59f
--- a/sysdeps/alpha/dl-trampoline.S
abe59f
+++ b/sysdeps/alpha/dl-trampoline.S
abe59f
@@ -187,7 +187,7 @@ _dl_runtime_profile_new:
abe59f
 	jsr	$26, ($27), 0
abe59f
 	ldgp	$29, 0($26)
abe59f
 
abe59f
-	/* Set up for call to _dl_call_pltexit.  */
abe59f
+	/* Set up for call to _dl_audit_pltexit.  */
abe59f
 	ldq	$16, 16*8($15)
abe59f
 	ldq	$17, 17*8($15)
abe59f
 	stq	$0, 16*8($15)
abe59f
@@ -196,7 +196,7 @@ _dl_runtime_profile_new:
abe59f
 	lda	$19, 16*8($15)
abe59f
 	stt	$f0, 18*8($15)
abe59f
 	stt	$f1, 19*8($15)
abe59f
-	bsr	$26, _dl_call_pltexit	!samegp
abe59f
+	bsr	$26, _dl_audit_pltexit	!samegp
abe59f
 
abe59f
 	mov	$15, $30
abe59f
 	cfi_def_cfa_register (30)
abe59f
@@ -518,7 +518,7 @@ _dl_runtime_profile_old:
abe59f
 	jsr	$26, ($27), 0
abe59f
 	ldgp	$29, 0($26)
abe59f
 
abe59f
-	/* Set up for call to _dl_call_pltexit.  */
abe59f
+	/* Set up for call to _dl_audit_pltexit.  */
abe59f
 	ldq	$16, 48*8($15)
abe59f
 	ldq	$17, 49*8($15)
abe59f
 	stq	$0, 46*8($15)
abe59f
@@ -527,7 +527,7 @@ _dl_runtime_profile_old:
abe59f
 	lda	$19, 46*8($15)
abe59f
 	stt	$f0, 48*8($15)
abe59f
 	stt	$f1, 49*8($15)
abe59f
-	bsr	$26, _dl_call_pltexit	!samegp
abe59f
+	bsr	$26, _dl_audit_pltexit	!samegp
abe59f
 
abe59f
 	mov	$15, $30
abe59f
 	cfi_def_cfa_register (30)
abe59f
diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
abe59f
index 1a4fd3f17b6df7da..9b5d0567df984c5d 100644
abe59f
--- a/sysdeps/arm/dl-machine.h
abe59f
+++ b/sysdeps/arm/dl-machine.h
abe59f
@@ -260,6 +260,8 @@ _dl_start_user:\n\
abe59f
    Prelinked libraries may use Elf32_Rela though.  */
abe59f
 #define ELF_MACHINE_PLT_REL 1
abe59f
 
abe59f
+#define PLTREL ElfW(Rel)
abe59f
+
abe59f
 /* We define an initialization functions.  This is called very early in
abe59f
    _dl_sysdep_start.  */
abe59f
 #define DL_PLATFORM_INIT dl_platform_init ()
abe59f
diff --git a/sysdeps/arm/dl-trampoline.S b/sysdeps/arm/dl-trampoline.S
abe59f
index c731b012869a9cbc..ced1b1cb1017d677 100644
abe59f
--- a/sysdeps/arm/dl-trampoline.S
abe59f
+++ b/sysdeps/arm/dl-trampoline.S
abe59f
@@ -194,7 +194,7 @@ _dl_runtime_profile:
abe59f
 	ldmia	ip, {r0,r1}
abe59f
 	add	r2, r7, #72
abe59f
 	add	r3, r7, #0
abe59f
-	bl	_dl_call_pltexit
abe59f
+	bl	_dl_audit_pltexit
abe59f
 
abe59f
 	@ Return to caller.
abe59f
 	ldmia	r7, {r0-r3}
abe59f
diff --git a/sysdeps/generic/dl-fixup-attribute.h b/sysdeps/generic/dl-fixup-attribute.h
abe59f
new file mode 100644
abe59f
index 0000000000000000..aa92169b709b3fea
abe59f
--- /dev/null
abe59f
+++ b/sysdeps/generic/dl-fixup-attribute.h
abe59f
@@ -0,0 +1,24 @@
abe59f
+/* ABI specifics for lazy resolution functions.
abe59f
+   Copyright (C) 2021 Free Software Foundation, Inc.
abe59f
+   This file is part of the GNU C Library.
abe59f
+
abe59f
+   The GNU C Library is free software; you can redistribute it and/or
abe59f
+   modify it under the terms of the GNU Lesser General Public
abe59f
+   License as published by the Free Software Foundation; either
abe59f
+   version 2.1 of the License, or (at your option) any later version.
abe59f
+
abe59f
+   The GNU C Library is distributed in the hope that it will be useful,
abe59f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
abe59f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
abe59f
+   Lesser General Public License for more details.
abe59f
+
abe59f
+   You should have received a copy of the GNU Lesser General Public
abe59f
+   License along with the GNU C Library; if not, see
abe59f
+   <https://www.gnu.org/licenses/>.  */
abe59f
+
abe59f
+#ifndef _DL_FIXUP_ATTRIBUTE_H
abe59f
+#define _DL_FIXUP_ATTRIBUTE_H
abe59f
+
abe59f
+#define DL_ARCH_FIXUP_ATTRIBUTE
abe59f
+
abe59f
+#endif
abe59f
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
abe59f
index 47a9dee5b1c0ca63..29b77b35175c1116 100644
abe59f
--- a/sysdeps/generic/ldsodefs.h
abe59f
+++ b/sysdeps/generic/ldsodefs.h
abe59f
@@ -35,6 +35,7 @@
abe59f
 #include <link.h>
abe59f
 #include <dl-lookupcfg.h>
abe59f
 #include <dl-sysdep.h>
abe59f
+#include <dl-fixup-attribute.h>
abe59f
 #include <libc-lock.h>
abe59f
 #include <hp-timing.h>
abe59f
 #include <tls.h>
abe59f
@@ -1311,6 +1312,11 @@ void _dl_audit_pltenter (struct link_map *l, struct reloc_result *reloc_result,
abe59f
 			 DL_FIXUP_VALUE_TYPE *value, void *regs,
abe59f
 			 long int *framesize)
abe59f
   attribute_hidden;
abe59f
+void DL_ARCH_FIXUP_ATTRIBUTE _dl_audit_pltexit (struct link_map *l,
abe59f
+						ElfW(Word) reloc_arg,
abe59f
+						const void *inregs,
abe59f
+						void *outregs)
abe59f
+  attribute_hidden;
abe59f
 #endif /* SHARED */
abe59f
 
abe59f
 __END_DECLS
abe59f
diff --git a/sysdeps/hppa/dl-runtime.c b/sysdeps/hppa/dl-runtime.c
abe59f
index 2d061b150f0602c1..4c323131f937094b 100644
abe59f
--- a/sysdeps/hppa/dl-runtime.c
abe59f
+++ b/sysdeps/hppa/dl-runtime.c
abe59f
@@ -26,7 +26,7 @@
abe59f
    _dl_fixup with the relocation offset.  */
abe59f
 
abe59f
 ElfW(Word)
abe59f
-attribute_hidden __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
abe59f
+attribute_hidden __attribute ((noinline)) DL_ARCH_FIXUP_ATTRIBUTE
abe59f
 _dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l)
abe59f
 {
abe59f
   Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type;
abe59f
diff --git a/sysdeps/hppa/dl-trampoline.S b/sysdeps/hppa/dl-trampoline.S
abe59f
index 7ee4331cc2e7deff..3c83c8542f4fc63f 100644
abe59f
--- a/sysdeps/hppa/dl-trampoline.S
abe59f
+++ b/sysdeps/hppa/dl-trampoline.S
abe59f
@@ -275,7 +275,7 @@ L(cont):
abe59f
 	ldw	-4(%sp),%r1
abe59f
 	copy	%r1, %sp
abe59f
 
abe59f
-	/* Arguments to _dl_call_pltexit */
abe59f
+	/* Arguments to _dl_audit_pltexit */
abe59f
 	ldw	-116(%sp), %r26		/* (1) got[1] == struct link_map */
abe59f
 	ldw	-120(%sp), %r25		/* (2) reloc offsets */
abe59f
 	ldo	-56(%sp), %r24		/* (3) *La_hppa_regs */
abe59f
@@ -287,8 +287,8 @@ L(cont):
abe59f
 	ldo	-128(%sp), %r1
abe59f
 	fstd	%fr4,0(%r1)
abe59f
 
abe59f
-	/* Call _dl_call_pltexit */
abe59f
-	bl	_dl_call_pltexit,%rp
abe59f
+	/* Call _dl_audit_pltexit */
abe59f
+	bl	_dl_audit_pltexit,%rp
abe59f
 	nop
abe59f
 
abe59f
 	/* Restore *La_hppa_retval */
abe59f
diff --git a/sysdeps/i386/dl-fixup-attribute.h b/sysdeps/i386/dl-fixup-attribute.h
abe59f
new file mode 100644
abe59f
index 0000000000000000..c10e9936f4db7254
abe59f
--- /dev/null
abe59f
+++ b/sysdeps/i386/dl-fixup-attribute.h
abe59f
@@ -0,0 +1,30 @@
abe59f
+/* ABI specifics for lazy resolution functions.  i386 version.
abe59f
+   Copyright (C) 2021 Free Software Foundation, Inc.
abe59f
+   This file is part of the GNU C Library.
abe59f
+
abe59f
+   The GNU C Library is free software; you can redistribute it and/or
abe59f
+   modify it under the terms of the GNU Lesser General Public
abe59f
+   License as published by the Free Software Foundation; either
abe59f
+   version 2.1 of the License, or (at your option) any later version.
abe59f
+
abe59f
+   The GNU C Library is distributed in the hope that it will be useful,
abe59f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
abe59f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
abe59f
+   Lesser General Public License for more details.
abe59f
+
abe59f
+   You should have received a copy of the GNU Lesser General Public
abe59f
+   License along with the GNU C Library; if not, see
abe59f
+   <https://www.gnu.org/licenses/>.  */
abe59f
+
abe59f
+#ifndef _DL_FIXUP_ATTRIBUTE_H
abe59f
+#define _DL_FIXUP_ATTRIBUTE_H
abe59f
+
abe59f
+/* We cannot use this scheme for profiling because the _mcount call destroys
abe59f
+   the passed register information.  */
abe59f
+#ifndef PROF
abe59f
+# define DL_ARCH_FIXUP_ATTRIBUTE __attribute__ ((regparm (3), stdcall, unused))
abe59f
+#else
abe59f
+# define DL_ARCH_FIXUP_ATTRIBUTE
abe59f
+#endif
abe59f
+
abe59f
+#endif
abe59f
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
abe59f
index 5ba95b9e4af49942..30c3464fc4ac19d8 100644
abe59f
--- a/sysdeps/i386/dl-machine.h
abe59f
+++ b/sysdeps/i386/dl-machine.h
abe59f
@@ -119,29 +119,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
abe59f
   return lazy;
abe59f
 }
abe59f
 
abe59f
-#ifdef IN_DL_RUNTIME
abe59f
-
abe59f
-# ifndef PROF
abe59f
-/* We add a declaration of this function here so that in dl-runtime.c
abe59f
-   the ELF_MACHINE_RUNTIME_TRAMPOLINE macro really can pass the parameters
abe59f
-   in registers.
abe59f
-
abe59f
-   We cannot use this scheme for profiling because the _mcount call
abe59f
-   destroys the passed register information.  */
abe59f
-#define ARCH_FIXUP_ATTRIBUTE __attribute__ ((regparm (3), stdcall, unused))
abe59f
-
abe59f
-extern ElfW(Addr) _dl_fixup (struct link_map *l,
abe59f
-			     ElfW(Word) reloc_offset)
abe59f
-     ARCH_FIXUP_ATTRIBUTE;
abe59f
-extern ElfW(Addr) _dl_profile_fixup (struct link_map *l,
abe59f
-				     ElfW(Word) reloc_offset,
abe59f
-				     ElfW(Addr) retaddr, void *regs,
abe59f
-				     long int *framesizep)
abe59f
-     ARCH_FIXUP_ATTRIBUTE;
abe59f
-# endif
abe59f
-
abe59f
-#endif
abe59f
-
abe59f
 /* Mask identifying addresses reserved for the user program,
abe59f
    where the dynamic linker should not map anything.  */
abe59f
 #define ELF_MACHINE_USER_ADDRESS_MASK	0xf8000000UL
abe59f
@@ -240,6 +217,8 @@ _dl_start_user:\n\
abe59f
    Prelinked libraries may use Elf32_Rela though.  */
abe59f
 #define ELF_MACHINE_PLT_REL 1
abe59f
 
abe59f
+#define PLTREL ElfW(Rel)
abe59f
+
abe59f
 /* We define an initialization functions.  This is called very early in
abe59f
    _dl_sysdep_start.  */
abe59f
 #define DL_PLATFORM_INIT dl_platform_init ()
abe59f
diff --git a/sysdeps/i386/dl-trampoline.S b/sysdeps/i386/dl-trampoline.S
abe59f
index 6dc03192168ae2f3..a738b291a79bf8c2 100644
abe59f
--- a/sysdeps/i386/dl-trampoline.S
abe59f
+++ b/sysdeps/i386/dl-trampoline.S
abe59f
@@ -265,7 +265,7 @@ _dl_runtime_profile:
abe59f
 	movl (LRV_SIZE + 4 + LR_SIZE)(%esp), %eax
abe59f
 	# PLT1
abe59f
 	movl (LRV_SIZE + 4 + LR_SIZE + 4)(%esp), %edx
abe59f
-	call _dl_call_pltexit
abe59f
+	call _dl_audit_pltexit
abe59f
 	movl LRV_EAX_OFFSET(%esp), %eax
abe59f
 	movl LRV_EDX_OFFSET(%esp), %edx
abe59f
 	fldt LRV_ST1_OFFSET(%esp)
abe59f
diff --git a/sysdeps/ia64/dl-trampoline.S b/sysdeps/ia64/dl-trampoline.S
abe59f
index fc24c425bfe6907b..caeca3afcd7db6b6 100644
abe59f
--- a/sysdeps/ia64/dl-trampoline.S
abe59f
+++ b/sysdeps/ia64/dl-trampoline.S
abe59f
@@ -133,7 +133,7 @@ END(_dl_runtime_resolve)
abe59f
 
abe59f
 
abe59f
 /* The fourth argument to _dl_profile_fixup and the third one to
abe59f
-   _dl_call_pltexit are a pointer to La_ia64_regs:
abe59f
+   _dl_audit_pltexit are a pointer to La_ia64_regs:
abe59f
 
abe59f
    8byte r8
abe59f
    8byte r9
abe59f
@@ -159,7 +159,7 @@ END(_dl_runtime_resolve)
abe59f
    8byte sp
abe59f
 
abe59f
    The fifth argument to _dl_profile_fixup is a pointer to long int.
abe59f
-   The fourth argument to _dl_call_pltexit is a pointer to
abe59f
+   The fourth argument to _dl_audit_pltexit is a pointer to
abe59f
    La_ia64_retval:
abe59f
 
abe59f
    8byte r8
abe59f
@@ -261,7 +261,7 @@ ENTRY(_dl_runtime_profile)
abe59f
 	}
abe59f
 	{ .mii
abe59f
 	  mov r18 = ar.unat	/* save it in La_ia64_regs */
abe59f
-	  mov loc7 = out3	/* save it for _dl_call_pltexit */
abe59f
+	  mov loc7 = out3	/* save it for _dl_audit_pltexit */
abe59f
 	  mov loc5 = r11	/* preserve language specific register */
abe59f
 	}
abe59f
 	{ .mmi
abe59f
@@ -272,7 +272,7 @@ ENTRY(_dl_runtime_profile)
abe59f
 	}
abe59f
 	{ .mii
abe59f
 	  mov ar.unat = r17	/* restore it for function call */
abe59f
-	  mov loc8 = r16	/* save it for _dl_call_pltexit */
abe59f
+	  mov loc8 = r16	/* save it for _dl_audit_pltexit */
abe59f
 	  nop.i 0x0
abe59f
 	}
abe59f
 	{ .mmi
abe59f
@@ -291,7 +291,7 @@ ENTRY(_dl_runtime_profile)
abe59f
 	{ .mmi
abe59f
 	  stf.spill [r2] = f14, 32
abe59f
 	  stf.spill [r3] = f15, 24
abe59f
-	  mov loc9 = out1	/* save it for _dl_call_pltexit */
abe59f
+	  mov loc9 = out1	/* save it for _dl_audit_pltexit */
abe59f
 	  ;;
abe59f
 	}
abe59f
 	{ .mmb
abe59f
@@ -426,7 +426,7 @@ ENTRY(_dl_runtime_profile)
abe59f
 	  br.call.sptk.many b0 = b6
abe59f
 	}
abe59f
 	{ .mii
abe59f
-	  /* Prepare stack for _dl_call_pltexit. Loc10 has the original
abe59f
+	  /* Prepare stack for _dl_audit_pltexit. Loc10 has the original
abe59f
 	     stack pointer.  */
abe59f
 	  adds r12 = -PLTEXIT_FRAME_SIZE, loc10
abe59f
 	  adds r2 = -(PLTEXIT_FRAME_SIZE - 16), loc10
abe59f
@@ -461,14 +461,14 @@ ENTRY(_dl_runtime_profile)
abe59f
 	{ .mmi
abe59f
 	  stf.spill [r2] = f12, 32
abe59f
 	  stf.spill [r3] = f13, 32
abe59f
-	  /* We need to restore gp for _dl_call_pltexit. */
abe59f
+	  /* We need to restore gp for _dl_audit_pltexit. */
abe59f
 	  mov gp = loc11
abe59f
 	  ;;
abe59f
 	}
abe59f
 	{ .mmb
abe59f
 	  stf.spill [r2] = f14
abe59f
 	  stf.spill [r3] = f15
abe59f
-	  br.call.sptk.many b0 = _dl_call_pltexit
abe59f
+	  br.call.sptk.many b0 = _dl_audit_pltexit
abe59f
 	}
abe59f
 	{ .mmi
abe59f
 	  /* Load all the non-floating and floating return values. Skip
abe59f
diff --git a/sysdeps/m68k/dl-trampoline.S b/sysdeps/m68k/dl-trampoline.S
abe59f
index 7e1eace26b4a519d..27282ca8a6b1dada 100644
abe59f
--- a/sysdeps/m68k/dl-trampoline.S
abe59f
+++ b/sysdeps/m68k/dl-trampoline.S
abe59f
@@ -202,7 +202,7 @@ _dl_runtime_profile:
abe59f
 	cfi_adjust_cfa_offset (4)
abe59f
 	move.l (32+FPSPACE)(%sp), -(%sp)
abe59f
 	cfi_adjust_cfa_offset (4)
abe59f
-	jbsr _dl_call_pltexit
abe59f
+	jbsr _dl_audit_pltexit
abe59f
 	lea 16(%sp), %sp
abe59f
 	cfi_adjust_cfa_offset (-16)
abe59f
 	move.l (%sp)+, %d0
abe59f
diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
abe59f
index b41e10647d81843b..d4bd8b62f4b036a3 100644
abe59f
--- a/sysdeps/mips/dl-machine.h
abe59f
+++ b/sysdeps/mips/dl-machine.h
abe59f
@@ -63,6 +63,7 @@
abe59f
 #define ELF_MACHINE_PLT_REL 1
abe59f
 #define ELF_MACHINE_NO_REL 0
abe59f
 #define ELF_MACHINE_NO_RELA 0
abe59f
+#define PLTREL ElfW(Rel)
abe59f
 
abe59f
 /* Translate a processor specific dynamic tag to the index
abe59f
    in l_info array.  */
abe59f
diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h
abe59f
index 31c7f3f95a2ce1b2..84322595793dc8bb 100644
abe59f
--- a/sysdeps/powerpc/powerpc32/dl-machine.h
abe59f
+++ b/sysdeps/powerpc/powerpc32/dl-machine.h
abe59f
@@ -150,6 +150,7 @@ __elf_preferred_address(struct link_map *loader, size_t maplength,
abe59f
 /* The PowerPC never uses REL relocations.  */
abe59f
 #define ELF_MACHINE_NO_REL 1
abe59f
 #define ELF_MACHINE_NO_RELA 0
abe59f
+#define PLTREL ElfW(Rela)
abe59f
 
abe59f
 /* We define an initialization function to initialize HWCAP/HWCAP2 and
abe59f
    platform data so it can be copied into the TCB later.  This is called
abe59f
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
abe59f
index 35996bb9173da231..3af1f708378f9a3c 100644
abe59f
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
abe59f
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
abe59f
@@ -297,6 +297,7 @@ BODY_PREFIX "_dl_start_user:\n"						\
abe59f
 /* The PowerPC never uses REL relocations.  */
abe59f
 #define ELF_MACHINE_NO_REL 1
abe59f
 #define ELF_MACHINE_NO_RELA 0
abe59f
+#define PLTREL ElfW(Rela)
abe59f
 
abe59f
 /* We define an initialization function to initialize HWCAP/HWCAP2 and
abe59f
    platform data so it can be copied into the TCB later.  This is called
abe59f
diff --git a/sysdeps/powerpc/powerpc64/dl-trampoline.S b/sysdeps/powerpc/powerpc64/dl-trampoline.S
abe59f
index aa141dc44b980d9b..23290d32360507fd 100644
abe59f
--- a/sysdeps/powerpc/powerpc64/dl-trampoline.S
abe59f
+++ b/sysdeps/powerpc/powerpc64/dl-trampoline.S
abe59f
@@ -197,7 +197,7 @@ END(_dl_runtime_resolve)
abe59f
 #ifndef PROF
abe59f
 ENTRY (_dl_profile_resolve, 4)
abe59f
 /* Spill r30, r31 to preserve the link_map* and reloc_addr, in case we
abe59f
-   need to call _dl_call_pltexit.  */
abe59f
+   need to call _dl_audit_pltexit.  */
abe59f
 	std	r31,-8(r1)
abe59f
 	std	r30,-16(r1)
abe59f
 /* We need to save the registers used to pass parameters, ie. r3 thru
abe59f
@@ -452,7 +452,7 @@ L(restoreFXR2):
abe59f
 L(callpltexit):
abe59f
 	addi	r5,r1,INT_PARMS
abe59f
 	addi	r6,r1,INT_RTN
abe59f
-	bl	JUMPTARGET(_dl_call_pltexit)
abe59f
+	bl	JUMPTARGET(_dl_audit_pltexit)
abe59f
 #ifndef SHARED
abe59f
 	nop
abe59f
 #endif
abe59f
diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h
abe59f
index ded41adff80346b6..2f3bb085ae2b6794 100644
abe59f
--- a/sysdeps/s390/s390-32/dl-machine.h
abe59f
+++ b/sysdeps/s390/s390-32/dl-machine.h
abe59f
@@ -279,6 +279,7 @@ _dl_start_user:\n\
abe59f
 /* The S390 never uses Elf32_Rel relocations.  */
abe59f
 #define ELF_MACHINE_NO_REL 1
abe59f
 #define ELF_MACHINE_NO_RELA 0
abe59f
+#define PLTREL ElfW(Rela)
abe59f
 
abe59f
 /* We define an initialization functions.  This is called very early in
abe59f
    _dl_sysdep_start.  */
abe59f
diff --git a/sysdeps/s390/s390-32/dl-trampoline.h b/sysdeps/s390/s390-32/dl-trampoline.h
abe59f
index d36c002743bf2f0c..c447a41f067c462b 100644
abe59f
--- a/sysdeps/s390/s390-32/dl-trampoline.h
abe59f
+++ b/sysdeps/s390/s390-32/dl-trampoline.h
abe59f
@@ -207,7 +207,7 @@ _dl_runtime_profile:
abe59f
 	basr   %r1,0
abe59f
 5:	l      %r14,7f-5b(%r1)
abe59f
 	la     %r5,40(%r12)		# pointer to struct La_s390_32_retval
abe59f
-	bas    %r14,0(%r14,%r1)		# call _dl_call_pltexit
abe59f
+	bas    %r14,0(%r14,%r1)		# call _dl_audit_pltexit
abe59f
 
abe59f
 	lr     %r15,%r12		# remove stack frame
abe59f
 	cfi_def_cfa_register (15)
abe59f
@@ -224,7 +224,7 @@ _dl_runtime_profile:
abe59f
 	br     %r14
abe59f
 
abe59f
 6:	.long  _dl_profile_fixup - 0b
abe59f
-7:	.long  _dl_call_pltexit - 5b
abe59f
+7:	.long  _dl_audit_pltexit - 5b
abe59f
 	cfi_endproc
abe59f
 	.size _dl_runtime_profile, .-_dl_runtime_profile
abe59f
 #endif
abe59f
diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h
abe59f
index 36327c40a1972dd7..033e7c9916e751f4 100644
abe59f
--- a/sysdeps/s390/s390-64/dl-machine.h
abe59f
+++ b/sysdeps/s390/s390-64/dl-machine.h
abe59f
@@ -228,6 +228,7 @@ _dl_start_user:\n\
abe59f
 /* The 64 bit S/390 never uses Elf64_Rel relocations.  */
abe59f
 #define ELF_MACHINE_NO_REL 1
abe59f
 #define ELF_MACHINE_NO_RELA 0
abe59f
+#define PLTREL ElfW(Rela)
abe59f
 
abe59f
 /* We define an initialization functions.  This is called very early in
abe59f
    _dl_sysdep_start.  */
abe59f
diff --git a/sysdeps/s390/s390-64/dl-trampoline.h b/sysdeps/s390/s390-64/dl-trampoline.h
abe59f
index d313fd521db0b859..18534d629ebc00e2 100644
abe59f
--- a/sysdeps/s390/s390-64/dl-trampoline.h
abe59f
+++ b/sysdeps/s390/s390-64/dl-trampoline.h
abe59f
@@ -203,7 +203,7 @@ _dl_runtime_profile:
abe59f
 	lmg    %r2,%r4,48(%r12)		# r2, r3: load arguments saved by PLT
abe59f
 					# r4: pointer to struct La_s390_64_regs
abe59f
 	la     %r5,72(%r12)		# pointer to struct La_s390_64_retval
abe59f
-	brasl  %r14,_dl_call_pltexit
abe59f
+	brasl  %r14,_dl_audit_pltexit
abe59f
 
abe59f
 	lgr    %r15,%r12		# remove stack frame
abe59f
 	cfi_def_cfa_register (15)
abe59f
diff --git a/sysdeps/sh/dl-trampoline.S b/sysdeps/sh/dl-trampoline.S
abe59f
index 0c8f84d26d3015ca..73f865f2af4e2d48 100644
abe59f
--- a/sysdeps/sh/dl-trampoline.S
abe59f
+++ b/sysdeps/sh/dl-trampoline.S
abe59f
@@ -423,8 +423,8 @@ _dl_runtime_profile:
abe59f
 	.align 2
abe59f
 #ifdef SHARED
abe59f
 7:	.long _GLOBAL_OFFSET_TABLE_
abe59f
-8:	.long _dl_call_pltexit@GOTOFF
abe59f
+8:	.long _dl_audit_pltexit@GOTOFF
abe59f
 #else
abe59f
-8:	.long _dl_call_pltexit
abe59f
+8:	.long _dl_audit_pltexit
abe59f
 #endif
abe59f
 	.size _dl_runtime_profile, .-_dl_runtime_profile
abe59f
diff --git a/sysdeps/sparc/sparc32/dl-trampoline.S b/sysdeps/sparc/sparc32/dl-trampoline.S
abe59f
index 098ffcfacc55d0b6..18ef2f0d3655b3de 100644
abe59f
--- a/sysdeps/sparc/sparc32/dl-trampoline.S
abe59f
+++ b/sysdeps/sparc/sparc32/dl-trampoline.S
abe59f
@@ -127,7 +127,7 @@ _dl_profile_invoke:
abe59f
 	mov	%l5, %o0
abe59f
 	mov	%l6, %o1
abe59f
 	add	%sp, (11 * 8), %o2
abe59f
-	call	_dl_call_pltexit
abe59f
+	call	_dl_audit_pltexit
abe59f
 	 add	%sp, ( 9 * 8), %o3
abe59f
 
abe59f
 	ldd	[%sp + ( 9 * 8)], %i0
abe59f
diff --git a/sysdeps/sparc/sparc64/dl-trampoline.S b/sysdeps/sparc/sparc64/dl-trampoline.S
abe59f
index 4948b88b9640691d..9c18ceb131c9a25b 100644
abe59f
--- a/sysdeps/sparc/sparc64/dl-trampoline.S
abe59f
+++ b/sysdeps/sparc/sparc64/dl-trampoline.S
abe59f
@@ -196,7 +196,7 @@ _dl_profile_invoke:
abe59f
 	mov	%l5, %o0
abe59f
 	mov	%l6, %o1
abe59f
 	add	%sp, STACK_BIAS + (24 * 8), %o2
abe59f
-	call	_dl_call_pltexit
abe59f
+	call	_dl_audit_pltexit
abe59f
 	 add	%sp, STACK_BIAS + (16 * 8), %o3
abe59f
 
abe59f
 	ldx	[%sp + STACK_BIAS + (16 * 8)], %i0
abe59f
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
abe59f
index 5262aa69c06aa8db..d30317980882ac51 100644
abe59f
--- a/sysdeps/x86_64/dl-machine.h
abe59f
+++ b/sysdeps/x86_64/dl-machine.h
abe59f
@@ -210,6 +210,7 @@ _dl_start_user:\n\
abe59f
 /* The x86-64 never uses Elf64_Rel/Elf32_Rel relocations.  */
abe59f
 #define ELF_MACHINE_NO_REL 1
abe59f
 #define ELF_MACHINE_NO_RELA 0
abe59f
+#define PLTREL ElfW(Rela)
abe59f
 
abe59f
 /* We define an initialization function.  This is called very early in
abe59f
    _dl_sysdep_start.  */
abe59f
diff --git a/sysdeps/x86_64/dl-runtime.h b/sysdeps/x86_64/dl-runtime.h
abe59f
index 3fa61d7a4697cf3f..379f8bd4dea8ef97 100644
abe59f
--- a/sysdeps/x86_64/dl-runtime.h
abe59f
+++ b/sysdeps/x86_64/dl-runtime.h
abe59f
@@ -18,7 +18,7 @@
abe59f
    02111-1307 USA.  */
abe59f
 
abe59f
 /* The ABI calls for the PLT stubs to pass the index of the relocation
abe59f
-   and not its offset.  In _dl_profile_fixup and _dl_call_pltexit we
abe59f
+   and not its offset.  In _dl_profile_fixup and _dl_audit_pltexit we
abe59f
    also use the index.  Therefore it is wasteful to compute the offset
abe59f
    in the trampoline just to reverse the operation immediately
abe59f
    afterwards.  */
abe59f
diff --git a/sysdeps/x86_64/dl-trampoline.h b/sysdeps/x86_64/dl-trampoline.h
abe59f
index a28b1e73a4b187ba..256dfbb64df9f03d 100644
abe59f
--- a/sysdeps/x86_64/dl-trampoline.h
abe59f
+++ b/sysdeps/x86_64/dl-trampoline.h
abe59f
@@ -388,7 +388,7 @@ _dl_runtime_profile:
abe59f
 	jns 3f
abe59f
 
abe59f
 	/* There's nothing in the frame size, so there
abe59f
-	   will be no call to the _dl_call_pltexit. */
abe59f
+	   will be no call to the _dl_audit_pltexit. */
abe59f
 
abe59f
 	/* Get back registers content.  */
abe59f
 	movq LR_RCX_OFFSET(%rsp), %rcx
abe59f
@@ -436,7 +436,7 @@ _dl_runtime_profile:
abe59f
 	mov 24(%rbx), %RSP_LP	# Drop the copied stack content
abe59f
 
abe59f
 	/* Now we have to prepare the La_x86_64_retval structure for the
abe59f
-	   _dl_call_pltexit.  The La_x86_64_regs is being pointed by rsp now,
abe59f
+	   _dl_audit_pltexit.  The La_x86_64_regs is being pointed by rsp now,
abe59f
 	   so we just need to allocate the sizeof(La_x86_64_retval) space on
abe59f
 	   the stack, since the alignment has already been taken care of. */
abe59f
 # ifdef RESTORE_AVX
abe59f
@@ -491,7 +491,7 @@ _dl_runtime_profile:
abe59f
 	movq 24(%rbx), %rdx	# La_x86_64_regs argument to %rdx.
abe59f
 	movq 40(%rbx), %rsi	# Copy args pushed by PLT in register.
abe59f
 	movq 32(%rbx), %rdi	# %rdi: link_map, %rsi: reloc_index
abe59f
-	call _dl_call_pltexit
abe59f
+	call _dl_audit_pltexit
abe59f
 
abe59f
 	/* Restore return registers.  */
abe59f
 	movq LRV_RAX_OFFSET(%rsp), %rax