From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 5D7153858C56 for ; Tue, 12 Apr 2022 18:42:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D7153858C56 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-172-ix1uxQ4EN2euRRspBFqDTA-1; Tue, 12 Apr 2022 14:42:38 -0400 X-MC-Unique: ix1uxQ4EN2euRRspBFqDTA-1 Received: by mail-qv1-f69.google.com with SMTP id kk19-20020a056214509300b004460dad5312so1332258qvb.23 for ; Tue, 12 Apr 2022 11:42:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RFrKphsO1FlnhmNIWqaAv0axyw+9Gknpxi767VtGars=; b=TPH0QRKVWGdzJLE1GFMn62talduBhE0sz3VFz/Xoi14Eg/8QAocuj5YCB0nz801Z6n j2/EBEmcTTXlndNZyobTSopGKhaAB4r6xVQdzLBj5AMivSsfkNxeAWzHgQZidi9yuwGP vqKlbHvW7aRGibB0eZagbpjq7jYtXcYWH1ZRWAvQAEwzP15lZYXQrWNUax4XY1lY/cXi GTWYZCcMuV5pqyN2zaJ1PpXtcTJKujkfBBe09TzKH8vNKGGReikl6X6jjRK6AHuJgs6/ +c7d1j5x/vsR0thlTYzNZTz9SrH6oI95hakgeOO9LWRXqjNIhlRbNXRtfWCfuoRXm5ur rmaQ== X-Gm-Message-State: AOAM530Lwu7eUKq/d7/59Iewlu6+jNJQwq7QVYJUfKb3LmEm7MfPEea2 j0vxHB7zGtgN+d3GIjunI2xbbEf24XDe40W3RkschpBGEcaQiBGNctxZH1eiVaX5Bg5FP5InFVf NaHmPGSf1IGapqzEPJJJtZ/UlEaXVpAVWMSxHTNqtsmN35/OI390zFtmiQW3oqfEQ7DEjwhk= X-Received: by 2002:a05:620a:4104:b0:67d:9261:4800 with SMTP id j4-20020a05620a410400b0067d92614800mr4026716qko.289.1649788957097; Tue, 12 Apr 2022 11:42:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/pdWd3dQpB/8AZb4njdKqsjnneycHMI6jgZ9nw2d/KLMD7spexIhPISTFdwsaaAOkx9hAFQ== X-Received: by 2002:a05:620a:4104:b0:67d:9261:4800 with SMTP id j4-20020a05620a410400b0067d92614800mr4026673qko.289.1649788956238; Tue, 12 Apr 2022 11:42:36 -0700 (PDT) Received: from athas.redhat.com (135-23-175-80.cpe.pppoe.ca. [135.23.175.80]) by smtp.gmail.com with ESMTPSA id j19-20020a05622a039300b002ecc2ebfd87sm10953840qtx.32.2022.04.12.11.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 11:42:35 -0700 (PDT) From: Carlos O'Donell To: libc-stable@sourceware.org Cc: Adhemerval Zanella , Florian Weimer Subject: [PATCH 15/27] elf: Add _dl_audit_pltexit Date: Tue, 12 Apr 2022 14:41:53 -0400 Message-Id: <20220412184205.3343677-16-carlos@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412184205.3343677-1-carlos@redhat.com> References: <20220412184205.3343677-1-carlos@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: application/octet-stream; x-default=true X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2022 18:42:40 -0000 From: Adhemerval Zanella 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 (cherry picked from commit 8c0664e2b861fd3789602cc0b0b1922b0e20cb3a) Resolved conflicts: sysdeps/hppa/dl-runtime.c --- elf/dl-audit.c | 47 +++++++++++++++ elf/dl-runtime.c | 69 +---------------------- elf/dl-support.c | 8 +++ sysdeps/aarch64/dl-trampoline.S | 2 +- sysdeps/alpha/dl-trampoline.S | 8 +-- sysdeps/arm/dl-machine-rel.h | 2 + sysdeps/arm/dl-trampoline.S | 2 +- sysdeps/generic/dl-fixup-attribute.h | 24 ++++++++ sysdeps/generic/dl-machine-rel.h | 2 + sysdeps/generic/ldsodefs.h | 6 ++ sysdeps/hppa/dl-runtime.c | 2 +- sysdeps/hppa/dl-trampoline.S | 6 +- 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 +- sysdeps/ia64/dl-trampoline.S | 16 +++--- sysdeps/m68k/dl-trampoline.S | 2 +- sysdeps/mips/dl-machine-rel.h | 1 + sysdeps/powerpc/powerpc64/dl-trampoline.S | 4 +- sysdeps/s390/s390-32/dl-trampoline.h | 4 +- sysdeps/s390/s390-64/dl-trampoline.h | 2 +- sysdeps/sh/dl-trampoline.S | 4 +- sysdeps/sparc/sparc32/dl-trampoline.S | 2 +- sysdeps/sparc/sparc64/dl-trampoline.S | 2 +- sysdeps/x86_64/dl-runtime.h | 2 +- sysdeps/x86_64/dl-trampoline.h | 6 +- 27 files changed, 158 insertions(+), 122 deletions(-) create mode 100644 sysdeps/generic/dl-fixup-attribute.h create mode 100644 sysdeps/i386/dl-fixup-attribute.h diff --git a/elf/dl-audit.c b/elf/dl-audit.c index 15250c67e8..152712b12f 100644 --- a/elf/dl-audit.c +++ b/elf/dl-audit.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include void _dl_audit_activity_map (struct link_map *l, int action) @@ -320,3 +322,48 @@ _dl_audit_pltenter (struct link_map *l, struct reloc_result *reloc_result, *value = DL_FIXUP_ADDR_VALUE (sym.st_value); } + +void +DL_ARCH_FIXUP_ATTRIBUTE +_dl_audit_pltexit (struct link_map *l, ElfW(Word) reloc_arg, + const void *inregs, void *outregs) +{ + const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]); + + /* This is the address in the array where we store the result of previous + relocations. */ + // XXX Maybe the bound information must be stored on the stack since + // XXX with bind_not a new value could have been stored in the meantime. + struct reloc_result *reloc_result = + &l->l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))]; + ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound, + l_info[DT_SYMTAB]) + + reloc_result->boundndx); + + /* Set up the sym parameter. */ + ElfW(Sym) sym = *defsym; + sym.st_value = DL_FIXUP_VALUE_ADDR (reloc_result->addr); + + /* Get the symbol name. */ + const char *strtab = (const void *) D_PTR (reloc_result->bound, + l_info[DT_STRTAB]); + const char *symname = strtab + sym.st_name; + + struct audit_ifaces *afct = GLRO(dl_audit); + for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) + { + if (afct->ARCH_LA_PLTEXIT != NULL + && (reloc_result->enterexit + & (LA_SYMB_NOPLTEXIT >> (2 * cnt))) == 0) + { + struct auditstate *l_state = link_map_audit_state (l, cnt); + struct auditstate *bound_state + = link_map_audit_state (reloc_result->bound, cnt); + afct->ARCH_LA_PLTEXIT (&sym, reloc_result->boundndx, + &l_state->cookie, &bound_state->cookie, + inregs, outregs, symname); + } + + afct = afct->next; + } +} diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c index dfedeaf2dd..e42f6e8b8d 100644 --- a/elf/dl-runtime.c +++ b/elf/dl-runtime.c @@ -16,8 +16,6 @@ License along with the GNU C Library; if not, see . */ -#define IN_DL_RUNTIME 1 /* This can be tested in dl-machine.h. */ - #include #include #include @@ -31,19 +29,6 @@ #include -#if (!ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \ - || ELF_MACHINE_NO_REL -# define PLTREL ElfW(Rela) -#else -# define PLTREL ElfW(Rel) -#endif - -/* The fixup functions might have need special attributes. If none - are provided define the macro as empty. */ -#ifndef ARCH_FIXUP_ATTRIBUTE -# define ARCH_FIXUP_ATTRIBUTE -#endif - /* This function is called through a special trampoline from the PLT the first time each PLT entry is called. We must perform the relocation specified in the PLT of the given shared object, and return the resolved @@ -52,7 +37,7 @@ function. */ DL_FIXUP_VALUE_TYPE -attribute_hidden __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE +attribute_hidden __attribute ((noinline)) DL_ARCH_FIXUP_ATTRIBUTE _dl_fixup ( # ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS ELF_MACHINE_RUNTIME_FIXUP_ARGS, @@ -148,7 +133,8 @@ _dl_fixup ( #ifndef PROF DL_FIXUP_VALUE_TYPE -__attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE +__attribute ((noinline)) +DL_ARCH_FIXUP_ATTRIBUTE _dl_profile_fixup ( #ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS ELF_MACHINE_RUNTIME_FIXUP_ARGS, @@ -332,52 +318,3 @@ _dl_profile_fixup ( } #endif /* PROF */ - - -#include -void -ARCH_FIXUP_ATTRIBUTE -_dl_call_pltexit (struct link_map *l, ElfW(Word) reloc_arg, - const void *inregs, void *outregs) -{ -#ifdef SHARED - const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]); - - /* This is the address in the array where we store the result of previous - relocations. */ - // XXX Maybe the bound information must be stored on the stack since - // XXX with bind_not a new value could have been stored in the meantime. - struct reloc_result *reloc_result = - &l->l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))]; - ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound, - l_info[DT_SYMTAB]) - + reloc_result->boundndx); - - /* Set up the sym parameter. */ - ElfW(Sym) sym = *defsym; - sym.st_value = DL_FIXUP_VALUE_ADDR (reloc_result->addr); - - /* Get the symbol name. */ - const char *strtab = (const void *) D_PTR (reloc_result->bound, - l_info[DT_STRTAB]); - const char *symname = strtab + sym.st_name; - - struct audit_ifaces *afct = GLRO(dl_audit); - for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) - { - if (afct->ARCH_LA_PLTEXIT != NULL - && (reloc_result->enterexit - & (LA_SYMB_NOPLTEXIT >> (2 * cnt))) == 0) - { - struct auditstate *l_state = link_map_audit_state (l, cnt); - struct auditstate *bound_state - = link_map_audit_state (reloc_result->bound, cnt); - afct->ARCH_LA_PLTEXIT (&sym, reloc_result->boundndx, - &l_state->cookie, &bound_state->cookie, - inregs, outregs, symname); - } - - afct = afct->next; - } -#endif -} diff --git a/elf/dl-support.c b/elf/dl-support.c index d8c06ba7eb..8aedfb25a9 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -435,3 +435,11 @@ _dl_get_dl_main_map (void) return &_dl_main_map; } #endif + +/* This is used by _dl_runtime_profile, not used on static code. */ +void +DL_ARCH_FIXUP_ATTRIBUTE +_dl_audit_pltexit (struct link_map *l, ElfW(Word) reloc_arg, + const void *inregs, void *outregs) +{ +} diff --git a/sysdeps/aarch64/dl-trampoline.S b/sysdeps/aarch64/dl-trampoline.S index a7e9267c1c..9b352b1d0f 100644 --- a/sysdeps/aarch64/dl-trampoline.S +++ b/sysdeps/aarch64/dl-trampoline.S @@ -293,7 +293,7 @@ _dl_runtime_profile: ldp x0, x1, [x29, #OFFSET_SAVED_CALL_X0] add x2, x29, #OFFSET_RG add x3, x29, #OFFSET_RV - bl _dl_call_pltexit + bl _dl_audit_pltexit ldp x0, x1, [x29, #OFFSET_RV + DL_OFFSET_RV_X0] ldp d0, d1, [x29, #OFFSET_RV + DL_OFFSET_RV_D0 + 16*0] diff --git a/sysdeps/alpha/dl-trampoline.S b/sysdeps/alpha/dl-trampoline.S index 9dfce5b083..55380d48ad 100644 --- a/sysdeps/alpha/dl-trampoline.S +++ b/sysdeps/alpha/dl-trampoline.S @@ -187,7 +187,7 @@ _dl_runtime_profile_new: jsr $26, ($27), 0 ldgp $29, 0($26) - /* Set up for call to _dl_call_pltexit. */ + /* Set up for call to _dl_audit_pltexit. */ ldq $16, 16*8($15) ldq $17, 17*8($15) stq $0, 16*8($15) @@ -196,7 +196,7 @@ _dl_runtime_profile_new: lda $19, 16*8($15) stt $f0, 18*8($15) stt $f1, 19*8($15) - bsr $26, _dl_call_pltexit !samegp + bsr $26, _dl_audit_pltexit !samegp mov $15, $30 cfi_def_cfa_register (30) @@ -518,7 +518,7 @@ _dl_runtime_profile_old: jsr $26, ($27), 0 ldgp $29, 0($26) - /* Set up for call to _dl_call_pltexit. */ + /* Set up for call to _dl_audit_pltexit. */ ldq $16, 48*8($15) ldq $17, 49*8($15) stq $0, 46*8($15) @@ -527,7 +527,7 @@ _dl_runtime_profile_old: lda $19, 46*8($15) stt $f0, 48*8($15) stt $f1, 49*8($15) - bsr $26, _dl_call_pltexit !samegp + bsr $26, _dl_audit_pltexit !samegp mov $15, $30 cfi_def_cfa_register (30) diff --git a/sysdeps/arm/dl-machine-rel.h b/sysdeps/arm/dl-machine-rel.h index bec114706c..a9ee25a6b1 100644 --- a/sysdeps/arm/dl-machine-rel.h +++ b/sysdeps/arm/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/arm/dl-trampoline.S b/sysdeps/arm/dl-trampoline.S index 70105308ca..a2d322706d 100644 --- a/sysdeps/arm/dl-trampoline.S +++ b/sysdeps/arm/dl-trampoline.S @@ -194,7 +194,7 @@ _dl_runtime_profile: ldmia ip, {r0,r1} add r2, r7, #72 add r3, r7, #0 - bl _dl_call_pltexit + bl _dl_audit_pltexit @ Return to caller. ldmia r7, {r0-r3} diff --git a/sysdeps/generic/dl-fixup-attribute.h b/sysdeps/generic/dl-fixup-attribute.h new file mode 100644 index 0000000000..aa92169b70 --- /dev/null +++ b/sysdeps/generic/dl-fixup-attribute.h @@ -0,0 +1,24 @@ +/* ABI specifics for lazy resolution functions. + 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 + . */ + +#ifndef _DL_FIXUP_ATTRIBUTE_H +#define _DL_FIXUP_ATTRIBUTE_H + +#define DL_ARCH_FIXUP_ATTRIBUTE + +#endif diff --git a/sysdeps/generic/dl-machine-rel.h b/sysdeps/generic/dl-machine-rel.h index 9167a1dffc..9d5b7bb749 100644 --- a/sysdeps/generic/dl-machine-rel.h +++ b/sysdeps/generic/dl-machine-rel.h @@ -23,5 +23,7 @@ #define ELF_MACHINE_NO_REL 1 /* Defined if the architecture supports Elf{32,64}_Rela relocations. */ #define ELF_MACHINE_NO_RELA 0 +/* Used to calculate the index of link_map l_reloc_result. */ +#define PLTREL ElfW(Rela) #endif diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 524cbaaa7f..14a306c306 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -1403,6 +1404,11 @@ void _dl_audit_pltenter (struct link_map *l, struct reloc_result *reloc_result, DL_FIXUP_VALUE_TYPE *value, void *regs, long int *framesize) attribute_hidden; +void DL_ARCH_FIXUP_ATTRIBUTE _dl_audit_pltexit (struct link_map *l, + ElfW(Word) reloc_arg, + const void *inregs, + void *outregs) + attribute_hidden; #endif /* SHARED */ #if PTHREAD_IN_LIBC && defined SHARED diff --git a/sysdeps/hppa/dl-runtime.c b/sysdeps/hppa/dl-runtime.c index a71b5b2013..8699171930 100644 --- a/sysdeps/hppa/dl-runtime.c +++ b/sysdeps/hppa/dl-runtime.c @@ -25,7 +25,7 @@ return that to the caller. The caller will continue on to call _dl_fixup with the relocation offset. */ -ElfW(Word) __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE +ElfW(Word) __attribute ((noinline)) DL_ARCH_FIXUP_ATTRIBUTE _dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l) { Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type; diff --git a/sysdeps/hppa/dl-trampoline.S b/sysdeps/hppa/dl-trampoline.S index cb18ea7eab..c54879bae0 100644 --- a/sysdeps/hppa/dl-trampoline.S +++ b/sysdeps/hppa/dl-trampoline.S @@ -300,7 +300,7 @@ L(cont): ldw -4(%sp),%r1 copy %r1, %sp - /* Arguments to _dl_call_pltexit */ + /* Arguments to _dl_audit_pltexit */ ldw -116(%sp), %r26 /* (1) got[1] == struct link_map */ ldw -120(%sp), %r25 /* (2) reloc offsets */ ldo -56(%sp), %r24 /* (3) *La_hppa_regs */ @@ -312,8 +312,8 @@ L(cont): ldo -128(%sp), %r1 fstd %fr4,0(%r1) - /* Call _dl_call_pltexit */ - bl _dl_call_pltexit,%rp + /* Call _dl_audit_pltexit */ + bl _dl_audit_pltexit,%rp nop /* Restore *La_hppa_retval */ diff --git a/sysdeps/i386/dl-fixup-attribute.h b/sysdeps/i386/dl-fixup-attribute.h new file mode 100644 index 0000000000..c10e9936f4 --- /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 + . */ + +#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 7ac46f78a6..bb3480d454 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 c55c9a3d64..5483e903d8 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -122,29 +122,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 b5ec0326df..3a33051c52 100644 --- a/sysdeps/i386/dl-trampoline.S +++ b/sysdeps/i386/dl-trampoline.S @@ -265,7 +265,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) diff --git a/sysdeps/ia64/dl-trampoline.S b/sysdeps/ia64/dl-trampoline.S index 3053405a3a..11e86932c7 100644 --- a/sysdeps/ia64/dl-trampoline.S +++ b/sysdeps/ia64/dl-trampoline.S @@ -133,7 +133,7 @@ END(_dl_runtime_resolve) /* The fourth argument to _dl_profile_fixup and the third one to - _dl_call_pltexit are a pointer to La_ia64_regs: + _dl_audit_pltexit are a pointer to La_ia64_regs: 8byte r8 8byte r9 @@ -159,7 +159,7 @@ END(_dl_runtime_resolve) 8byte sp The fifth argument to _dl_profile_fixup is a pointer to long int. - The fourth argument to _dl_call_pltexit is a pointer to + The fourth argument to _dl_audit_pltexit is a pointer to La_ia64_retval: 8byte r8 @@ -261,7 +261,7 @@ ENTRY(_dl_runtime_profile) } { .mii mov r18 = ar.unat /* save it in La_ia64_regs */ - mov loc7 = out3 /* save it for _dl_call_pltexit */ + mov loc7 = out3 /* save it for _dl_audit_pltexit */ mov loc5 = r11 /* preserve language specific register */ } { .mmi @@ -272,7 +272,7 @@ ENTRY(_dl_runtime_profile) } { .mii mov ar.unat = r17 /* restore it for function call */ - mov loc8 = r16 /* save it for _dl_call_pltexit */ + mov loc8 = r16 /* save it for _dl_audit_pltexit */ nop.i 0x0 } { .mmi @@ -291,7 +291,7 @@ ENTRY(_dl_runtime_profile) { .mmi stf.spill [r2] = f14, 32 stf.spill [r3] = f15, 24 - mov loc9 = out1 /* save it for _dl_call_pltexit */ + mov loc9 = out1 /* save it for _dl_audit_pltexit */ ;; } { .mmb @@ -426,7 +426,7 @@ ENTRY(_dl_runtime_profile) br.call.sptk.many b0 = b6 } { .mii - /* Prepare stack for _dl_call_pltexit. Loc10 has the original + /* Prepare stack for _dl_audit_pltexit. Loc10 has the original stack pointer. */ adds r12 = -PLTEXIT_FRAME_SIZE, loc10 adds r2 = -(PLTEXIT_FRAME_SIZE - 16), loc10 @@ -461,14 +461,14 @@ ENTRY(_dl_runtime_profile) { .mmi stf.spill [r2] = f12, 32 stf.spill [r3] = f13, 32 - /* We need to restore gp for _dl_call_pltexit. */ + /* We need to restore gp for _dl_audit_pltexit. */ mov gp = loc11 ;; } { .mmb stf.spill [r2] = f14 stf.spill [r3] = f15 - br.call.sptk.many b0 = _dl_call_pltexit + br.call.sptk.many b0 = _dl_audit_pltexit } { .mmi /* Load all the non-floating and floating return values. Skip diff --git a/sysdeps/m68k/dl-trampoline.S b/sysdeps/m68k/dl-trampoline.S index a51a5f7f57..72bde664c3 100644 --- a/sysdeps/m68k/dl-trampoline.S +++ b/sysdeps/m68k/dl-trampoline.S @@ -202,7 +202,7 @@ _dl_runtime_profile: cfi_adjust_cfa_offset (4) move.l (32+FPSPACE)(%sp), -(%sp) cfi_adjust_cfa_offset (4) - jbsr _dl_call_pltexit + jbsr _dl_audit_pltexit lea 16(%sp), %sp cfi_adjust_cfa_offset (-16) move.l (%sp)+, %d0 diff --git a/sysdeps/mips/dl-machine-rel.h b/sysdeps/mips/dl-machine-rel.h index ed39618041..3d0dfec01f 100644 --- a/sysdeps/mips/dl-machine-rel.h +++ b/sysdeps/mips/dl-machine-rel.h @@ -22,5 +22,6 @@ #define ELF_MACHINE_PLT_REL 1 #define ELF_MACHINE_NO_REL 0 #define ELF_MACHINE_NO_RELA 0 +#define PLTREL ElfW(Rel) #endif diff --git a/sysdeps/powerpc/powerpc64/dl-trampoline.S b/sysdeps/powerpc/powerpc64/dl-trampoline.S index 61bd8571fc..97f0105ce7 100644 --- a/sysdeps/powerpc/powerpc64/dl-trampoline.S +++ b/sysdeps/powerpc/powerpc64/dl-trampoline.S @@ -197,7 +197,7 @@ END(_dl_runtime_resolve) #ifndef PROF ENTRY (_dl_profile_resolve, 4) /* Spill r30, r31 to preserve the link_map* and reloc_addr, in case we - need to call _dl_call_pltexit. */ + need to call _dl_audit_pltexit. */ std r31,-8(r1) std r30,-16(r1) /* We need to save the registers used to pass parameters, ie. r3 thru @@ -452,7 +452,7 @@ L(restoreFXR2): L(callpltexit): addi r5,r1,INT_PARMS addi r6,r1,INT_RTN - bl JUMPTARGET(_dl_call_pltexit) + bl JUMPTARGET(_dl_audit_pltexit) #ifndef SHARED nop #endif diff --git a/sysdeps/s390/s390-32/dl-trampoline.h b/sysdeps/s390/s390-32/dl-trampoline.h index c224a2b928..9e4cd1055f 100644 --- a/sysdeps/s390/s390-32/dl-trampoline.h +++ b/sysdeps/s390/s390-32/dl-trampoline.h @@ -282,7 +282,7 @@ _dl_runtime_profile: basr %r1,0 5: l %r14,7f-5b(%r1) la %r5,CFA_OFF+RETVAL_OFF(%r12) # struct La_s390_32_retval * - bas %r14,0(%r14,%r1) # call _dl_call_pltexit + bas %r14,0(%r14,%r1) # call _dl_audit_pltexit lr %r15,%r12 # remove stack frame # undef FRAME_SIZE @@ -301,7 +301,7 @@ _dl_runtime_profile: br %r14 6: .long _dl_profile_fixup - 0b -7: .long _dl_call_pltexit - 5b +7: .long _dl_audit_pltexit - 5b cfi_endproc .size _dl_runtime_profile, .-_dl_runtime_profile # undef SIZEOF_STRUCT_LA_S390_32_REGS diff --git a/sysdeps/s390/s390-64/dl-trampoline.h b/sysdeps/s390/s390-64/dl-trampoline.h index ae741a3bad..6e5bad4045 100644 --- a/sysdeps/s390/s390-64/dl-trampoline.h +++ b/sysdeps/s390/s390-64/dl-trampoline.h @@ -284,7 +284,7 @@ _dl_runtime_profile: lmg %r2,%r4,CFA_OFF+PLT1_OFF(%r12) # r2, r3: args saved by PLT # r4: struct La_s390_64_regs * la %r5,CFA_OFF+RETVAL_OFF(%r12) # struct La_s390_64_retval * - brasl %r14,_dl_call_pltexit + brasl %r14,_dl_audit_pltexit lgr %r15,%r12 # remove stack frame # undef FRAME_SIZE diff --git a/sysdeps/sh/dl-trampoline.S b/sysdeps/sh/dl-trampoline.S index 824ac84ba1..f9038cd10e 100644 --- a/sysdeps/sh/dl-trampoline.S +++ b/sysdeps/sh/dl-trampoline.S @@ -423,8 +423,8 @@ _dl_runtime_profile: .align 2 #ifdef SHARED 7: .long _GLOBAL_OFFSET_TABLE_ -8: .long _dl_call_pltexit@GOTOFF +8: .long _dl_audit_pltexit@GOTOFF #else -8: .long _dl_call_pltexit +8: .long _dl_audit_pltexit #endif .size _dl_runtime_profile, .-_dl_runtime_profile diff --git a/sysdeps/sparc/sparc32/dl-trampoline.S b/sysdeps/sparc/sparc32/dl-trampoline.S index 426f90c99a..2f64809731 100644 --- a/sysdeps/sparc/sparc32/dl-trampoline.S +++ b/sysdeps/sparc/sparc32/dl-trampoline.S @@ -127,7 +127,7 @@ _dl_profile_invoke: mov %l5, %o0 mov %l6, %o1 add %sp, (11 * 8), %o2 - call _dl_call_pltexit + call _dl_audit_pltexit add %sp, ( 9 * 8), %o3 ldd [%sp + ( 9 * 8)], %i0 diff --git a/sysdeps/sparc/sparc64/dl-trampoline.S b/sysdeps/sparc/sparc64/dl-trampoline.S index 8d59fa6720..86605e37ac 100644 --- a/sysdeps/sparc/sparc64/dl-trampoline.S +++ b/sysdeps/sparc/sparc64/dl-trampoline.S @@ -196,7 +196,7 @@ _dl_profile_invoke: mov %l5, %o0 mov %l6, %o1 add %sp, STACK_BIAS + (24 * 8), %o2 - call _dl_call_pltexit + call _dl_audit_pltexit add %sp, STACK_BIAS + (16 * 8), %o3 ldx [%sp + STACK_BIAS + (16 * 8)], %i0 diff --git a/sysdeps/x86_64/dl-runtime.h b/sysdeps/x86_64/dl-runtime.h index 9c8d3977ee..19ba33ef30 100644 --- a/sysdeps/x86_64/dl-runtime.h +++ b/sysdeps/x86_64/dl-runtime.h @@ -18,7 +18,7 @@ 02111-1307 USA. */ /* The ABI calls for the PLT stubs to pass the index of the relocation - and not its offset. In _dl_profile_fixup and _dl_call_pltexit we + and not its offset. In _dl_profile_fixup and _dl_audit_pltexit we also use the index. Therefore it is wasteful to compute the offset in the trampoline just to reverse the operation immediately afterwards. */ diff --git a/sysdeps/x86_64/dl-trampoline.h b/sysdeps/x86_64/dl-trampoline.h index b9a12970cd..b5de7efff7 100644 --- a/sysdeps/x86_64/dl-trampoline.h +++ b/sysdeps/x86_64/dl-trampoline.h @@ -388,7 +388,7 @@ _dl_runtime_profile: jns 3f /* There's nothing in the frame size, so there - will be no call to the _dl_call_pltexit. */ + will be no call to the _dl_audit_pltexit. */ /* Get back registers content. */ movq LR_RCX_OFFSET(%rsp), %rcx @@ -436,7 +436,7 @@ _dl_runtime_profile: mov 24(%rbx), %RSP_LP # Drop the copied stack content /* Now we have to prepare the La_x86_64_retval structure for the - _dl_call_pltexit. The La_x86_64_regs is being pointed by rsp now, + _dl_audit_pltexit. The La_x86_64_regs is being pointed by rsp now, so we just need to allocate the sizeof(La_x86_64_retval) space on the stack, since the alignment has already been taken care of. */ # ifdef RESTORE_AVX @@ -491,7 +491,7 @@ _dl_runtime_profile: movq 24(%rbx), %rdx # La_x86_64_regs argument to %rdx. movq 40(%rbx), %rsi # Copy args pushed by PLT in register. movq 32(%rbx), %rdi # %rdi: link_map, %rsi: reloc_index - call _dl_call_pltexit + call _dl_audit_pltexit /* Restore return registers. */ movq LRV_RAX_OFFSET(%rsp), %rax -- 2.35.1