From 8c0664e2b861fd3789602cc0b0b1922b0e20cb3a Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Thu, 22 Jul 2021 18:02:42 -0300 Subject: elf: Add _dl_audit_pltexit It consolidates the code required to call la_pltexit audit callback. Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com> --- sysdeps/i386/dl-fixup-attribute.h | 30 ++++++++++++++++++++++++++++++ sysdeps/i386/dl-machine-rel.h | 2 ++ sysdeps/i386/dl-machine.h | 23 ----------------------- sysdeps/i386/dl-trampoline.S | 2 +- 4 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 sysdeps/i386/dl-fixup-attribute.h (limited to 'sysdeps/i386') diff --git a/sysdeps/i386/dl-fixup-attribute.h b/sysdeps/i386/dl-fixup-attribute.h new file mode 100644 index 0000000..c10e9936 --- /dev/null +++ b/sysdeps/i386/dl-fixup-attribute.h @@ -0,0 +1,30 @@ +/* ABI specifics for lazy resolution functions. i386 version. + Copyright (C) 2021 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, see + <https://www.gnu.org/licenses/>. */ + +#ifndef _DL_FIXUP_ATTRIBUTE_H +#define _DL_FIXUP_ATTRIBUTE_H + +/* We cannot use this scheme for profiling because the _mcount call destroys + the passed register information. */ +#ifndef PROF +# define DL_ARCH_FIXUP_ATTRIBUTE __attribute__ ((regparm (3), stdcall, unused)) +#else +# define DL_ARCH_FIXUP_ATTRIBUTE +#endif + +#endif diff --git a/sysdeps/i386/dl-machine-rel.h b/sysdeps/i386/dl-machine-rel.h index 7ac46f7..bb3480d 100644 --- a/sysdeps/i386/dl-machine-rel.h +++ b/sysdeps/i386/dl-machine-rel.h @@ -28,4 +28,6 @@ Prelinked libraries may use Elf32_Rela though. */ #define ELF_MACHINE_PLT_REL 1 +#define PLTREL ElfW(Rel) + #endif diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 169bed5..2f0dbc2 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -115,29 +115,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], return lazy; } -#ifdef IN_DL_RUNTIME - -# ifndef PROF -/* We add a declaration of this function here so that in dl-runtime.c - the ELF_MACHINE_RUNTIME_TRAMPOLINE macro really can pass the parameters - in registers. - - We cannot use this scheme for profiling because the _mcount call - destroys the passed register information. */ -#define ARCH_FIXUP_ATTRIBUTE __attribute__ ((regparm (3), stdcall, unused)) - -extern ElfW(Addr) _dl_fixup (struct link_map *l, - ElfW(Word) reloc_offset) - ARCH_FIXUP_ATTRIBUTE; -extern ElfW(Addr) _dl_profile_fixup (struct link_map *l, - ElfW(Word) reloc_offset, - ElfW(Addr) retaddr, void *regs, - long int *framesizep) - ARCH_FIXUP_ATTRIBUTE; -# endif - -#endif - /* Mask identifying addresses reserved for the user program, where the dynamic linker should not map anything. */ #define ELF_MACHINE_USER_ADDRESS_MASK 0xf0000000UL diff --git a/sysdeps/i386/dl-trampoline.S b/sysdeps/i386/dl-trampoline.S index 5669ab1..1e555de 100644 --- a/sysdeps/i386/dl-trampoline.S +++ b/sysdeps/i386/dl-trampoline.S @@ -252,7 +252,7 @@ _dl_runtime_profile: movl (LRV_SIZE + 4 + LR_SIZE)(%esp), %eax # PLT1 movl (LRV_SIZE + 4 + LR_SIZE + 4)(%esp), %edx - call _dl_call_pltexit + call _dl_audit_pltexit movl LRV_EAX_OFFSET(%esp), %eax movl LRV_EDX_OFFSET(%esp), %edx fldt LRV_ST1_OFFSET(%esp) -- cgit v1.1