1996-06-12 04:51:27 +00:00
|
|
|
/* Machine-dependent ELF dynamic relocation inline functions. Alpha version.
|
2021-01-02 19:32:25 +00:00
|
|
|
Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
1996-12-04 01:41:27 +00:00
|
|
|
This file is part of the GNU C Library.
|
1996-06-12 04:51:27 +00:00
|
|
|
|
1996-12-04 01:41:27 +00:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:56:23 +00:00
|
|
|
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.
|
1996-06-12 04:51:27 +00:00
|
|
|
|
1996-12-04 01:41:27 +00:00
|
|
|
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
|
2001-07-06 04:56:23 +00:00
|
|
|
Lesser General Public License for more details.
|
1996-06-12 04:51:27 +00:00
|
|
|
|
2001-07-06 04:56:23 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-03-09 23:56:38 +00:00
|
|
|
License along with the GNU C Library. If not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
1996-06-12 04:51:27 +00:00
|
|
|
|
1996-07-16 06:12:11 +00:00
|
|
|
/* This was written in the absence of an ABI -- don't expect
|
1996-06-12 04:51:27 +00:00
|
|
|
it to remain unchanged. */
|
|
|
|
|
1996-07-16 06:12:11 +00:00
|
|
|
#ifndef dl_machine_h
|
|
|
|
#define dl_machine_h 1
|
|
|
|
|
1996-06-12 04:51:27 +00:00
|
|
|
#define ELF_MACHINE_NAME "alpha"
|
|
|
|
|
|
|
|
#include <string.h>
|
elf: Fix dynamic-link.h usage on rtld.c
The 4af6982e4c fix does not fully handle RTLD_BOOTSTRAP usage on
rtld.c due two issues:
1. RTLD_BOOTSTRAP is also used on dl-machine.h on various
architectures and it changes the semantics of various machine
relocation functions.
2. The elf_get_dynamic_info() change was done sideways, previously
to 490e6c62aa get-dynamic-info.h was included by the first
dynamic-link.h include *without* RTLD_BOOTSTRAP being defined.
It means that the code within elf_get_dynamic_info() that uses
RTLD_BOOTSTRAP is in fact unused.
To fix 1. this patch now includes dynamic-link.h only once with
RTLD_BOOTSTRAP defined. The ELF_DYNAMIC_RELOCATE call will now have
the relocation fnctions with the expected semantics for the loader.
And to fix 2. part of 4af6982e4c is reverted (the check argument
elf_get_dynamic_info() is not required) and the RTLD_BOOTSTRAP
pieces are removed.
To reorganize the includes the static TLS definition is moved to
its own header to avoid a circular dependency (it is defined on
dynamic-link.h and dl-machine.h requires it at same time other
dynamic-link.h definition requires dl-machine.h defitions).
Also ELF_MACHINE_NO_REL, ELF_MACHINE_NO_RELA, and ELF_MACHINE_PLT_REL
are moved to its own header. Only ancient ABIs need special values
(arm, i386, and mips), so a generic one is used as default.
The powerpc Elf64_FuncDesc is also moved to its own header, since
csu code required its definition (which would require either include
elf/ folder or add a full path with elf/).
Checked on x86_64, i686, aarch64, armhf, powerpc64, powerpc32,
and powerpc64le.
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2021-10-13 12:49:34 +00:00
|
|
|
#include <dl-static-tls.h>
|
|
|
|
#include <dl-machine-rel.h>
|
1996-06-12 04:51:27 +00:00
|
|
|
|
|
|
|
|
2002-04-24 18:17:02 +00:00
|
|
|
/* Mask identifying addresses reserved for the user program,
|
|
|
|
where the dynamic linker should not map anything. */
|
|
|
|
#define ELF_MACHINE_USER_ADDRESS_MASK 0x120000000UL
|
|
|
|
|
2005-05-28 23:40:09 +00:00
|
|
|
/* Translate a processor specific dynamic tag to the index in l_info array. */
|
|
|
|
#define DT_ALPHA(x) (DT_ALPHA_##x - DT_LOPROC + DT_NUM)
|
|
|
|
|
2000-10-20 17:04:28 +00:00
|
|
|
/* Return nonzero iff ELF header is compatible with the running host. */
|
1996-06-12 04:51:27 +00:00
|
|
|
static inline int
|
2000-10-20 17:04:28 +00:00
|
|
|
elf_machine_matches_host (const Elf64_Ehdr *ehdr)
|
1996-06-12 04:51:27 +00:00
|
|
|
{
|
2000-10-20 17:04:28 +00:00
|
|
|
return ehdr->e_machine == EM_ALPHA;
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
|
|
|
|
1996-12-04 01:41:27 +00:00
|
|
|
/* Return the link-time address of _DYNAMIC. The multiple-got-capable
|
|
|
|
linker no longer allocates the first .got entry for this. But not to
|
|
|
|
worry, no special tricks are needed. */
|
|
|
|
static inline Elf64_Addr
|
|
|
|
elf_machine_dynamic (void)
|
1996-06-12 04:51:27 +00:00
|
|
|
{
|
1997-02-02 01:49:47 +00:00
|
|
|
#ifndef NO_AXP_MULTI_GOT_LD
|
1996-12-04 01:41:27 +00:00
|
|
|
return (Elf64_Addr) &_DYNAMIC;
|
1997-01-06 22:07:18 +00:00
|
|
|
#else
|
|
|
|
register Elf64_Addr *gp __asm__ ("$29");
|
|
|
|
return gp[-4096];
|
|
|
|
#endif
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the run-time load address of the shared object. */
|
2005-05-28 23:40:09 +00:00
|
|
|
|
1996-06-12 04:51:27 +00:00
|
|
|
static inline Elf64_Addr
|
|
|
|
elf_machine_load_address (void)
|
|
|
|
{
|
2005-05-28 23:40:09 +00:00
|
|
|
/* This relies on the compiler using gp-relative addresses for static symbols. */
|
|
|
|
static void *dot = ˙
|
|
|
|
return (void *)&dot - dot;
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
|
|
|
|
1996-07-16 06:12:11 +00:00
|
|
|
/* Set up the loaded object described by L so its unrelocated PLT
|
|
|
|
entries will jump to the on-demand fixup code in dl-runtime.c. */
|
|
|
|
|
1997-05-24 02:10:36 +00:00
|
|
|
static inline int
|
elf: Avoid nested functions in the loader [BZ #27220]
dynamic-link.h is included more than once in some elf/ files (rtld.c,
dl-conflict.c, dl-reloc.c, dl-reloc-static-pie.c) and uses GCC nested
functions. This harms readability and the nested functions usage
is the biggest obstacle prevents Clang build (Clang doesn't support GCC
nested functions).
The key idea for unnesting is to add extra parameters (struct link_map
*and struct r_scope_elm *[]) to RESOLVE_MAP,
ELF_MACHINE_BEFORE_RTLD_RELOC, ELF_DYNAMIC_RELOCATE, elf_machine_rel[a],
elf_machine_lazy_rel, and elf_machine_runtime_setup. (This is inspired
by Stan Shebs' ppc64/x86-64 implementation in the
google/grte/v5-2.27/master which uses mixed extra parameters and static
variables.)
Future simplification:
* If mips elf_machine_runtime_setup no longer needs RESOLVE_GOTSYM,
elf_machine_runtime_setup can drop the `scope` parameter.
* If TLSDESC no longer need to be in elf_machine_lazy_rel,
elf_machine_lazy_rel can drop the `scope` parameter.
Tested on aarch64, i386, x86-64, powerpc64le, powerpc64, powerpc32,
sparc64, sparcv9, s390x, s390, hppa, ia64, armhf, alpha, and mips64.
In addition, tested build-many-glibcs.py with {arc,csky,microblaze,nios2}-linux-gnu
and riscv64-linux-gnu-rv64imafdc-lp64d.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-10-07 18:55:02 +00:00
|
|
|
elf_machine_runtime_setup (struct link_map *map, struct r_scope_elem *scope[],
|
|
|
|
int lazy, int profile)
|
1996-07-16 06:12:11 +00:00
|
|
|
{
|
2005-05-28 23:40:09 +00:00
|
|
|
extern char _dl_runtime_resolve_new[] attribute_hidden;
|
|
|
|
extern char _dl_runtime_profile_new[] attribute_hidden;
|
|
|
|
extern char _dl_runtime_resolve_old[] attribute_hidden;
|
|
|
|
extern char _dl_runtime_profile_old[] attribute_hidden;
|
|
|
|
|
|
|
|
struct pltgot {
|
|
|
|
char *resolve;
|
|
|
|
struct link_map *link;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pltgot *pg;
|
|
|
|
long secureplt;
|
|
|
|
char *resolve;
|
|
|
|
|
|
|
|
if (map->l_info[DT_JMPREL] == 0 || !lazy)
|
|
|
|
return lazy;
|
|
|
|
|
|
|
|
/* Check to see if we're using the read-only plt form. */
|
|
|
|
secureplt = map->l_info[DT_ALPHA(PLTRO)] != 0;
|
|
|
|
|
|
|
|
/* If the binary uses the read-only secure plt format, PG points to
|
|
|
|
the .got.plt section, which is the right place for ld.so to place
|
|
|
|
its hooks. Otherwise, PG is currently pointing at the start of
|
|
|
|
the plt; the hooks go at offset 16. */
|
|
|
|
pg = (struct pltgot *) D_PTR (map, l_info[DT_PLTGOT]);
|
|
|
|
pg += !secureplt;
|
|
|
|
|
|
|
|
/* This function will be called to perform the relocation. They're
|
|
|
|
not declared as functions to convince the compiler to use gp
|
|
|
|
relative relocations for them. */
|
|
|
|
if (secureplt)
|
|
|
|
resolve = _dl_runtime_resolve_new;
|
|
|
|
else
|
|
|
|
resolve = _dl_runtime_resolve_old;
|
|
|
|
|
|
|
|
if (__builtin_expect (profile, 0))
|
1996-07-16 06:12:11 +00:00
|
|
|
{
|
2005-05-28 23:40:09 +00:00
|
|
|
if (secureplt)
|
|
|
|
resolve = _dl_runtime_profile_new;
|
2005-01-23 08:02:38 +00:00
|
|
|
else
|
2005-05-28 23:40:09 +00:00
|
|
|
resolve = _dl_runtime_profile_old;
|
1997-05-24 02:10:36 +00:00
|
|
|
|
2005-05-28 23:40:09 +00:00
|
|
|
if (GLRO(dl_profile) && _dl_name_match_p (GLRO(dl_profile), map))
|
2001-12-12 00:10:27 +00:00
|
|
|
{
|
2005-05-28 23:40:09 +00:00
|
|
|
/* This is the object we are looking for. Say that we really
|
|
|
|
want profiling and the timers are started. */
|
|
|
|
GL(dl_profile_map) = map;
|
2001-12-12 00:10:27 +00:00
|
|
|
}
|
1996-07-16 06:12:11 +00:00
|
|
|
}
|
1997-05-24 02:10:36 +00:00
|
|
|
|
2005-05-28 23:40:09 +00:00
|
|
|
pg->resolve = resolve;
|
|
|
|
pg->link = map;
|
|
|
|
|
1997-05-24 02:10:36 +00:00
|
|
|
return lazy;
|
1996-07-16 06:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initial entry point code for the dynamic linker.
|
|
|
|
The C function `_dl_start' is the real entry point;
|
|
|
|
its return value is the user program's entry point. */
|
|
|
|
|
|
|
|
#define RTLD_START asm ("\
|
2002-02-27 18:10:53 +00:00
|
|
|
.section .text \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
.set at \n\
|
|
|
|
.globl _start \n\
|
|
|
|
.ent _start \n\
|
|
|
|
_start: \n\
|
2003-06-06 05:54:15 +00:00
|
|
|
.frame $31,0,$31,0 \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
br $gp, 0f \n\
|
|
|
|
0: ldgp $gp, 0($gp) \n\
|
|
|
|
.prologue 0 \n\
|
|
|
|
/* Pass pointer to argument block to _dl_start. */ \n\
|
|
|
|
mov $sp, $16 \n\
|
2002-11-08 02:19:00 +00:00
|
|
|
bsr $26, _dl_start !samegp \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
.end _start \n\
|
|
|
|
/* FALLTHRU */ \n\
|
|
|
|
.globl _dl_start_user \n\
|
|
|
|
.ent _dl_start_user \n\
|
|
|
|
_dl_start_user: \n\
|
2003-06-06 05:54:15 +00:00
|
|
|
.frame $31,0,$31,0 \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
.prologue 0 \n\
|
|
|
|
/* Save the user entry point address in s0. */ \n\
|
|
|
|
mov $0, $9 \n\
|
|
|
|
/* See if we were run as a command with the executable \n\
|
|
|
|
file name as an extra leading argument. */ \n\
|
2004-06-28 21:03:34 +00:00
|
|
|
ldah $1, _dl_skip_args($gp) !gprelhigh \n\
|
|
|
|
ldl $1, _dl_skip_args($1) !gprellow \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
bne $1, $fixup_stack \n\
|
|
|
|
$fixup_stack_ret: \n\
|
|
|
|
/* The special initializer gets called with the stack \n\
|
|
|
|
just as the application's entry point will see it; \n\
|
|
|
|
it can switch stacks if it moves these contents \n\
|
|
|
|
over. */ \n\
|
|
|
|
" RTLD_START_SPECIAL_INIT " \n\
|
|
|
|
/* Call _dl_init(_dl_loaded, argc, argv, envp) to run \n\
|
|
|
|
initializers. */ \n\
|
2002-11-08 02:19:00 +00:00
|
|
|
ldah $16, _rtld_local($gp) !gprelhigh \n\
|
|
|
|
ldq $16, _rtld_local($16) !gprellow \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
ldq $17, 0($sp) \n\
|
|
|
|
lda $18, 8($sp) \n\
|
|
|
|
s8addq $17, 8, $19 \n\
|
|
|
|
addq $19, $18, $19 \n\
|
2014-11-04 23:26:39 +00:00
|
|
|
bsr $26, _dl_init !samegp \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
/* Pass our finalizer function to the user in $0. */ \n\
|
2002-11-08 02:19:00 +00:00
|
|
|
ldah $0, _dl_fini($gp) !gprelhigh \n\
|
|
|
|
lda $0, _dl_fini($0) !gprellow \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
/* Jump to the user's entry point. */ \n\
|
|
|
|
mov $9, $27 \n\
|
|
|
|
jmp ($9) \n\
|
|
|
|
$fixup_stack: \n\
|
|
|
|
/* Adjust the stack pointer to skip _dl_skip_args words.\n\
|
|
|
|
This involves copying everything down, since the \n\
|
|
|
|
stack pointer must always be 16-byte aligned. */ \n\
|
2014-11-04 17:39:39 +00:00
|
|
|
ldah $7, __GI__dl_argv($gp) !gprelhigh \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
ldq $2, 0($sp) \n\
|
2014-11-04 17:39:39 +00:00
|
|
|
ldq $5, __GI__dl_argv($7) !gprellow \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
subq $31, $1, $6 \n\
|
|
|
|
subq $2, $1, $2 \n\
|
|
|
|
s8addq $6, $5, $5 \n\
|
|
|
|
mov $sp, $4 \n\
|
|
|
|
s8addq $1, $sp, $3 \n\
|
|
|
|
stq $2, 0($sp) \n\
|
2014-11-04 17:39:39 +00:00
|
|
|
stq $5, __GI__dl_argv($7) !gprellow \n\
|
2001-12-31 17:33:59 +00:00
|
|
|
/* Copy down argv. */ \n\
|
|
|
|
0: ldq $5, 8($3) \n\
|
|
|
|
addq $4, 8, $4 \n\
|
|
|
|
addq $3, 8, $3 \n\
|
|
|
|
stq $5, 0($4) \n\
|
|
|
|
bne $5, 0b \n\
|
|
|
|
/* Copy down envp. */ \n\
|
|
|
|
1: ldq $5, 8($3) \n\
|
|
|
|
addq $4, 8, $4 \n\
|
|
|
|
addq $3, 8, $3 \n\
|
|
|
|
stq $5, 0($4) \n\
|
|
|
|
bne $5, 1b \n\
|
|
|
|
/* Copy down auxiliary table. */ \n\
|
|
|
|
2: ldq $5, 8($3) \n\
|
|
|
|
ldq $6, 16($3) \n\
|
|
|
|
addq $4, 16, $4 \n\
|
|
|
|
addq $3, 16, $3 \n\
|
|
|
|
stq $5, -8($4) \n\
|
|
|
|
stq $6, 0($4) \n\
|
|
|
|
bne $5, 2b \n\
|
|
|
|
br $fixup_stack_ret \n\
|
|
|
|
.end _dl_start_user \n\
|
|
|
|
.set noat \n\
|
1997-08-27 19:58:41 +00:00
|
|
|
.previous");
|
1996-07-16 06:12:11 +00:00
|
|
|
|
2000-04-15 16:53:23 +00:00
|
|
|
#ifndef RTLD_START_SPECIAL_INIT
|
|
|
|
#define RTLD_START_SPECIAL_INIT /* nothing */
|
|
|
|
#endif
|
|
|
|
|
2003-01-17 19:18:51 +00:00
|
|
|
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry
|
|
|
|
or TLS variables, so undefined references should not be allowed
|
|
|
|
to define the value.
|
|
|
|
|
2015-03-05 16:26:21 +00:00
|
|
|
ELF_RTYPE_CLASS_COPY iff TYPE should not be allowed to resolve
|
2003-01-17 19:18:51 +00:00
|
|
|
to one of the main executable's symbols, as for a COPY reloc.
|
|
|
|
This is unused on Alpha. */
|
|
|
|
|
2006-10-27 23:11:45 +00:00
|
|
|
# define elf_machine_type_class(type) \
|
2003-01-17 19:18:51 +00:00
|
|
|
(((type) == R_ALPHA_JMP_SLOT \
|
|
|
|
|| (type) == R_ALPHA_DTPMOD64 \
|
|
|
|
|| (type) == R_ALPHA_DTPREL64 \
|
|
|
|
|| (type) == R_ALPHA_TPREL64) * ELF_RTYPE_CLASS_PLT)
|
1997-03-25 02:22:23 +00:00
|
|
|
|
|
|
|
/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
|
1997-09-27 00:19:38 +00:00
|
|
|
#define ELF_MACHINE_JMP_SLOT R_ALPHA_JMP_SLOT
|
1996-07-16 06:12:11 +00:00
|
|
|
|
2010-05-04 03:25:06 +00:00
|
|
|
/* We define an initialization functions. This is called very early in
|
|
|
|
* _dl_sysdep_start. */
|
|
|
|
#define DL_PLATFORM_INIT dl_platform_init ()
|
|
|
|
|
|
|
|
static inline void __attribute__ ((unused))
|
|
|
|
dl_platform_init (void)
|
|
|
|
{
|
|
|
|
if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
|
|
|
|
/* Avoid an empty string which would disturb us. */
|
|
|
|
GLRO(dl_platform) = NULL;
|
|
|
|
}
|
|
|
|
|
1996-06-12 04:51:27 +00:00
|
|
|
/* Fix up the instructions of a PLT entry to invoke the function
|
|
|
|
rather than the dynamic linker. */
|
2000-05-05 07:12:09 +00:00
|
|
|
static inline Elf64_Addr
|
2005-05-28 23:40:09 +00:00
|
|
|
elf_machine_fixup_plt (struct link_map *map, lookup_t t,
|
2017-06-14 01:17:25 +00:00
|
|
|
const ElfW(Sym) *refsym, const ElfW(Sym) *sym,
|
2000-05-05 07:12:09 +00:00
|
|
|
const Elf64_Rela *reloc,
|
|
|
|
Elf64_Addr *got_addr, Elf64_Addr value)
|
1996-06-12 04:51:27 +00:00
|
|
|
{
|
|
|
|
const Elf64_Rela *rela_plt;
|
|
|
|
Elf64_Word *plte;
|
2000-05-05 07:12:09 +00:00
|
|
|
long int edisp;
|
1996-06-12 04:51:27 +00:00
|
|
|
|
1997-09-27 00:19:38 +00:00
|
|
|
/* Store the value we are going to load. */
|
|
|
|
*got_addr = value;
|
|
|
|
|
2005-05-28 23:40:09 +00:00
|
|
|
/* If this binary uses the read-only secure plt format, we're done. */
|
|
|
|
if (map->l_info[DT_ALPHA(PLTRO)])
|
|
|
|
return value;
|
|
|
|
|
|
|
|
/* Otherwise we have to modify the plt entry in place to do the branch. */
|
|
|
|
|
1996-06-12 04:51:27 +00:00
|
|
|
/* Recover the PLT entry address by calculating reloc's index into the
|
|
|
|
.rela.plt, and finding that entry in the .plt. */
|
2005-05-28 23:40:09 +00:00
|
|
|
rela_plt = (const Elf64_Rela *) D_PTR (map, l_info[DT_JMPREL]);
|
|
|
|
plte = (Elf64_Word *) (D_PTR (map, l_info[DT_PLTGOT]) + 32);
|
1996-06-21 04:30:50 +00:00
|
|
|
plte += 3 * (reloc - rela_plt);
|
1996-06-12 04:51:27 +00:00
|
|
|
|
|
|
|
/* Find the displacement from the plt entry to the function. */
|
2000-05-05 07:12:09 +00:00
|
|
|
edisp = (long int) (value - (Elf64_Addr)&plte[3]) / 4;
|
1996-06-12 04:51:27 +00:00
|
|
|
|
1996-06-21 04:30:50 +00:00
|
|
|
if (edisp >= -0x100000 && edisp < 0x100000)
|
1996-06-12 04:51:27 +00:00
|
|
|
{
|
|
|
|
/* If we are in range, use br to perfect branch prediction and
|
1996-07-01 22:16:22 +00:00
|
|
|
elide the dependency on the address load. This case happens,
|
1996-06-12 04:51:27 +00:00
|
|
|
e.g., when a shared library call is resolved to the same library. */
|
1996-06-21 04:30:50 +00:00
|
|
|
|
|
|
|
int hi, lo;
|
|
|
|
hi = value - (Elf64_Addr)&plte[0];
|
2000-05-05 07:12:09 +00:00
|
|
|
lo = (short int) hi;
|
1996-06-21 04:30:50 +00:00
|
|
|
hi = (hi - lo) >> 16;
|
|
|
|
|
1997-09-27 00:19:38 +00:00
|
|
|
/* Emit "lda $27,lo($27)" */
|
1996-06-21 04:30:50 +00:00
|
|
|
plte[1] = 0x237b0000 | (lo & 0xffff);
|
|
|
|
|
|
|
|
/* Emit "br $31,function" */
|
|
|
|
plte[2] = 0xc3e00000 | (edisp & 0x1fffff);
|
1997-05-24 02:10:36 +00:00
|
|
|
|
|
|
|
/* Think about thread-safety -- the previous instructions must be
|
|
|
|
committed to memory before the first is overwritten. */
|
|
|
|
__asm__ __volatile__("wmb" : : : "memory");
|
|
|
|
|
1997-09-27 00:19:38 +00:00
|
|
|
/* Emit "ldah $27,hi($27)" */
|
1997-05-24 02:10:36 +00:00
|
|
|
plte[0] = 0x277b0000 | (hi & 0xffff);
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Don't bother with the hint since we already know the hint is
|
|
|
|
wrong. Eliding it prevents the wrong page from getting pulled
|
|
|
|
into the cache. */
|
1996-06-21 04:30:50 +00:00
|
|
|
|
|
|
|
int hi, lo;
|
1997-09-27 00:19:38 +00:00
|
|
|
hi = (Elf64_Addr)got_addr - (Elf64_Addr)&plte[0];
|
1996-06-21 04:30:50 +00:00
|
|
|
lo = (short)hi;
|
|
|
|
hi = (hi - lo) >> 16;
|
|
|
|
|
1997-09-27 00:19:38 +00:00
|
|
|
/* Emit "ldq $27,lo($27)" */
|
1996-06-21 04:30:50 +00:00
|
|
|
plte[1] = 0xa77b0000 | (lo & 0xffff);
|
|
|
|
|
|
|
|
/* Emit "jmp $31,($27)" */
|
|
|
|
plte[2] = 0x6bfb0000;
|
1997-05-24 02:10:36 +00:00
|
|
|
|
|
|
|
/* Think about thread-safety -- the previous instructions must be
|
|
|
|
committed to memory before the first is overwritten. */
|
|
|
|
__asm__ __volatile__("wmb" : : : "memory");
|
|
|
|
|
1997-09-27 00:19:38 +00:00
|
|
|
/* Emit "ldah $27,hi($27)" */
|
1997-05-24 02:10:36 +00:00
|
|
|
plte[0] = 0x277b0000 | (hi & 0xffff);
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
|
|
|
|
1996-08-12 02:04:57 +00:00
|
|
|
/* At this point, if we've been doing runtime resolution, Icache is dirty.
|
|
|
|
This will be taken care of in _dl_runtime_resolve. If instead we are
|
|
|
|
doing this as part of non-lazy startup relocation, that bit of code
|
|
|
|
hasn't made it into Icache yet, so there's nothing to clean up. */
|
2000-05-05 07:12:09 +00:00
|
|
|
|
|
|
|
return value;
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
|
|
|
|
1997-10-12 03:40:09 +00:00
|
|
|
/* Return the final value of a plt relocation. */
|
|
|
|
static inline Elf64_Addr
|
|
|
|
elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
|
|
|
|
Elf64_Addr value)
|
|
|
|
{
|
|
|
|
return value + reloc->r_addend;
|
|
|
|
}
|
|
|
|
|
2005-01-23 08:02:38 +00:00
|
|
|
/* Names of the architecture-specific auditing callback functions. */
|
|
|
|
#define ARCH_LA_PLTENTER alpha_gnu_pltenter
|
|
|
|
#define ARCH_LA_PLTEXIT alpha_gnu_pltexit
|
|
|
|
|
1997-09-27 00:19:38 +00:00
|
|
|
#endif /* !dl_machine_h */
|
|
|
|
|
2005-01-23 08:02:38 +00:00
|
|
|
#ifdef RESOLVE_MAP
|
1997-09-27 00:19:38 +00:00
|
|
|
|
1996-06-12 04:51:27 +00:00
|
|
|
/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
|
|
|
|
MAP is the object containing the reloc. */
|
elf: Avoid nested functions in the loader [BZ #27220]
dynamic-link.h is included more than once in some elf/ files (rtld.c,
dl-conflict.c, dl-reloc.c, dl-reloc-static-pie.c) and uses GCC nested
functions. This harms readability and the nested functions usage
is the biggest obstacle prevents Clang build (Clang doesn't support GCC
nested functions).
The key idea for unnesting is to add extra parameters (struct link_map
*and struct r_scope_elm *[]) to RESOLVE_MAP,
ELF_MACHINE_BEFORE_RTLD_RELOC, ELF_DYNAMIC_RELOCATE, elf_machine_rel[a],
elf_machine_lazy_rel, and elf_machine_runtime_setup. (This is inspired
by Stan Shebs' ppc64/x86-64 implementation in the
google/grte/v5-2.27/master which uses mixed extra parameters and static
variables.)
Future simplification:
* If mips elf_machine_runtime_setup no longer needs RESOLVE_GOTSYM,
elf_machine_runtime_setup can drop the `scope` parameter.
* If TLSDESC no longer need to be in elf_machine_lazy_rel,
elf_machine_lazy_rel can drop the `scope` parameter.
Tested on aarch64, i386, x86-64, powerpc64le, powerpc64, powerpc32,
sparc64, sparcv9, s390x, s390, hppa, ia64, armhf, alpha, and mips64.
In addition, tested build-many-glibcs.py with {arc,csky,microblaze,nios2}-linux-gnu
and riscv64-linux-gnu-rv64imafdc-lp64d.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-10-07 18:55:02 +00:00
|
|
|
static inline void
|
2005-03-15 Jakub Jelinek <jakub@redhat.com>
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rel_relative,
elf_machine_rela, elf_machine_rela_relative, elf_machine_lazy_rel):
Add inline keyword.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative, elf_machine_lazy_rel): Add always_inline
attribute.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative, elf_machine_lazy_rel): Likewise. Change
static inline into auto inline.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative, elf_machine_lazy_rel): Likewise.
* sysdeps/generic/dl-machine.h (elf_machine_rel, elf_machine_rela):
Likewise.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rel_relative,
elf_machine_rela, elf_machine_rela_relative, elf_machine_lazy_rel):
Likewise.
2005-03-15 22:57:26 +00:00
|
|
|
__attribute__ ((always_inline))
|
elf: Avoid nested functions in the loader [BZ #27220]
dynamic-link.h is included more than once in some elf/ files (rtld.c,
dl-conflict.c, dl-reloc.c, dl-reloc-static-pie.c) and uses GCC nested
functions. This harms readability and the nested functions usage
is the biggest obstacle prevents Clang build (Clang doesn't support GCC
nested functions).
The key idea for unnesting is to add extra parameters (struct link_map
*and struct r_scope_elm *[]) to RESOLVE_MAP,
ELF_MACHINE_BEFORE_RTLD_RELOC, ELF_DYNAMIC_RELOCATE, elf_machine_rel[a],
elf_machine_lazy_rel, and elf_machine_runtime_setup. (This is inspired
by Stan Shebs' ppc64/x86-64 implementation in the
google/grte/v5-2.27/master which uses mixed extra parameters and static
variables.)
Future simplification:
* If mips elf_machine_runtime_setup no longer needs RESOLVE_GOTSYM,
elf_machine_runtime_setup can drop the `scope` parameter.
* If TLSDESC no longer need to be in elf_machine_lazy_rel,
elf_machine_lazy_rel can drop the `scope` parameter.
Tested on aarch64, i386, x86-64, powerpc64le, powerpc64, powerpc32,
sparc64, sparcv9, s390x, s390, hppa, ia64, armhf, alpha, and mips64.
In addition, tested build-many-glibcs.py with {arc,csky,microblaze,nios2}-linux-gnu
and riscv64-linux-gnu-rv64imafdc-lp64d.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-10-07 18:55:02 +00:00
|
|
|
elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
|
1996-06-12 04:51:27 +00:00
|
|
|
const Elf64_Rela *reloc,
|
1997-02-15 04:31:01 +00:00
|
|
|
const Elf64_Sym *sym,
|
1997-07-28 22:06:27 +00:00
|
|
|
const struct r_found_version *version,
|
2011-10-05 09:50:05 +00:00
|
|
|
void *const reloc_addr_arg,
|
|
|
|
int skip_ifunc)
|
1996-06-12 04:51:27 +00:00
|
|
|
{
|
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Don't assume
reloc_addr is aligned.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/cris/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/hppa/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/ia64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/m68k/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/mips/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc64/dl-machine.h
(elf_machine_rela_relative, elf_machine_rela): Adjust.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative):
* sysdeps/sh/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
2003-07-31 06:33:52 +00:00
|
|
|
Elf64_Addr *const reloc_addr = reloc_addr_arg;
|
2000-05-05 07:12:09 +00:00
|
|
|
unsigned long int const r_type = ELF64_R_TYPE (reloc->r_info);
|
1996-07-16 06:12:11 +00:00
|
|
|
|
2002-02-01 01:32:06 +00:00
|
|
|
#if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC && !defined SHARED
|
1996-07-08 06:17:19 +00:00
|
|
|
/* This is defined in rtld.c, but nowhere in the static libc.a; make the
|
|
|
|
reference weak so static programs can still link. This declaration
|
|
|
|
cannot be done when compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP)
|
|
|
|
because rtld.c contains the common defn for _dl_rtld_map, which is
|
|
|
|
incompatible with a weak decl in the same file. */
|
|
|
|
weak_extern (_dl_rtld_map);
|
|
|
|
#endif
|
1996-06-12 04:51:27 +00:00
|
|
|
|
|
|
|
/* We cannot use a switch here because we cannot locate the switch
|
|
|
|
jump table until we've self-relocated. */
|
|
|
|
|
2001-08-30 23:09:10 +00:00
|
|
|
#if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
|
2001-08-24 08:43:21 +00:00
|
|
|
if (__builtin_expect (r_type == R_ALPHA_RELATIVE, 0))
|
1996-06-12 04:51:27 +00:00
|
|
|
{
|
2001-08-30 23:09:10 +00:00
|
|
|
# if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
|
1996-07-16 06:12:11 +00:00
|
|
|
/* Already done in dynamic linker. */
|
2002-02-01 01:32:06 +00:00
|
|
|
if (map != &GL(dl_rtld_map))
|
2001-08-30 23:09:10 +00:00
|
|
|
# endif
|
2000-09-29 06:50:53 +00:00
|
|
|
{
|
2002-10-02 20:24:20 +00:00
|
|
|
/* XXX Make some timings. Maybe it's preferable to test for
|
2000-09-29 06:50:53 +00:00
|
|
|
unaligned access and only do it the complex way if necessary. */
|
|
|
|
Elf64_Addr reloc_addr_val;
|
|
|
|
|
|
|
|
/* Load value without causing unaligned trap. */
|
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Don't assume
reloc_addr is aligned.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/cris/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/hppa/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/ia64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/m68k/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/mips/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc64/dl-machine.h
(elf_machine_rela_relative, elf_machine_rela): Adjust.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative):
* sysdeps/sh/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
2003-07-31 06:33:52 +00:00
|
|
|
memcpy (&reloc_addr_val, reloc_addr_arg, 8);
|
2000-09-29 06:50:53 +00:00
|
|
|
reloc_addr_val += map->l_addr;
|
|
|
|
|
|
|
|
/* Store value without causing unaligned trap. */
|
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Don't assume
reloc_addr is aligned.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/cris/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/hppa/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/ia64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/m68k/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/mips/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc64/dl-machine.h
(elf_machine_rela_relative, elf_machine_rela): Adjust.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative):
* sysdeps/sh/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
2003-07-31 06:33:52 +00:00
|
|
|
memcpy (reloc_addr_arg, &reloc_addr_val, 8);
|
2000-09-29 06:50:53 +00:00
|
|
|
}
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
|
|
|
else
|
2001-08-30 23:09:10 +00:00
|
|
|
#endif
|
2002-10-02 20:24:20 +00:00
|
|
|
if (__builtin_expect (r_type == R_ALPHA_NONE, 0))
|
|
|
|
return;
|
|
|
|
else
|
1996-06-12 04:51:27 +00:00
|
|
|
{
|
elf: Avoid nested functions in the loader [BZ #27220]
dynamic-link.h is included more than once in some elf/ files (rtld.c,
dl-conflict.c, dl-reloc.c, dl-reloc-static-pie.c) and uses GCC nested
functions. This harms readability and the nested functions usage
is the biggest obstacle prevents Clang build (Clang doesn't support GCC
nested functions).
The key idea for unnesting is to add extra parameters (struct link_map
*and struct r_scope_elm *[]) to RESOLVE_MAP,
ELF_MACHINE_BEFORE_RTLD_RELOC, ELF_DYNAMIC_RELOCATE, elf_machine_rel[a],
elf_machine_lazy_rel, and elf_machine_runtime_setup. (This is inspired
by Stan Shebs' ppc64/x86-64 implementation in the
google/grte/v5-2.27/master which uses mixed extra parameters and static
variables.)
Future simplification:
* If mips elf_machine_runtime_setup no longer needs RESOLVE_GOTSYM,
elf_machine_runtime_setup can drop the `scope` parameter.
* If TLSDESC no longer need to be in elf_machine_lazy_rel,
elf_machine_lazy_rel can drop the `scope` parameter.
Tested on aarch64, i386, x86-64, powerpc64le, powerpc64, powerpc32,
sparc64, sparcv9, s390x, s390, hppa, ia64, armhf, alpha, and mips64.
In addition, tested build-many-glibcs.py with {arc,csky,microblaze,nios2}-linux-gnu
and riscv64-linux-gnu-rv64imafdc-lp64d.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-10-07 18:55:02 +00:00
|
|
|
struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
|
|
|
|
r_type);
|
2002-11-08 02:19:00 +00:00
|
|
|
Elf64_Addr sym_value;
|
2003-01-12 19:22:32 +00:00
|
|
|
Elf64_Addr sym_raw_value;
|
1996-06-12 04:51:27 +00:00
|
|
|
|
2003-01-12 19:22:32 +00:00
|
|
|
sym_raw_value = sym_value = reloc->r_addend;
|
2005-02-07 03:11:46 +00:00
|
|
|
if (sym_map)
|
2003-01-12 19:22:32 +00:00
|
|
|
{
|
|
|
|
sym_raw_value += sym->st_value;
|
elf: Unify symbol address run-time calculation [BZ #19818]
Wrap symbol address run-time calculation into a macro and use it
throughout, replacing inline calculations.
There are a couple of variants, most of them different in a functionally
insignificant way. Most calculations are right following RESOLVE_MAP,
at which point either the map or the symbol returned can be checked for
validity as the macro sets either both or neither. In some places both
the symbol and the map has to be checked however.
My initial implementation therefore always checked both, however that
resulted in code larger by as much as 0.3%, as many places know from
elsewhere that no check is needed. I have decided the size growth was
unacceptable.
Having looked closer I realized that it's the map that is the culprit.
Therefore I have modified LOOKUP_VALUE_ADDRESS to accept an additional
boolean argument telling it to access the map without checking it for
validity. This in turn has brought quite nice results, with new code
actually being smaller for i686, and MIPS o32, n32 and little-endian n64
targets, unchanged in size for x86-64 and, unusually, marginally larger
for big-endian MIPS n64, as follows:
i686:
text data bss dec hex filename
152255 4052 192 156499 26353 ld-2.27.9000-base.so
152159 4052 192 156403 262f3 ld-2.27.9000-elf-symbol-value.so
MIPS/o32/el:
text data bss dec hex filename
142906 4396 260 147562 2406a ld-2.27.9000-base.so
142890 4396 260 147546 2405a ld-2.27.9000-elf-symbol-value.so
MIPS/n32/el:
text data bss dec hex filename
142267 4404 260 146931 23df3 ld-2.27.9000-base.so
142171 4404 260 146835 23d93 ld-2.27.9000-elf-symbol-value.so
MIPS/n64/el:
text data bss dec hex filename
149835 7376 408 157619 267b3 ld-2.27.9000-base.so
149787 7376 408 157571 26783 ld-2.27.9000-elf-symbol-value.so
MIPS/o32/eb:
text data bss dec hex filename
142870 4396 260 147526 24046 ld-2.27.9000-base.so
142854 4396 260 147510 24036 ld-2.27.9000-elf-symbol-value.so
MIPS/n32/eb:
text data bss dec hex filename
142019 4404 260 146683 23cfb ld-2.27.9000-base.so
141923 4404 260 146587 23c9b ld-2.27.9000-elf-symbol-value.so
MIPS/n64/eb:
text data bss dec hex filename
149763 7376 408 157547 2676b ld-2.27.9000-base.so
149779 7376 408 157563 2677b ld-2.27.9000-elf-symbol-value.so
x86-64:
text data bss dec hex filename
148462 6452 400 155314 25eb2 ld-2.27.9000-base.so
148462 6452 400 155314 25eb2 ld-2.27.9000-elf-symbol-value.so
[BZ #19818]
* sysdeps/generic/ldsodefs.h (LOOKUP_VALUE_ADDRESS): Add `set'
parameter.
(SYMBOL_ADDRESS): New macro.
[!ELF_FUNCTION_PTR_IS_SPECIAL] (DL_SYMBOL_ADDRESS): Use
SYMBOL_ADDRESS for symbol address calculation.
* elf/dl-runtime.c (_dl_fixup): Likewise.
(_dl_profile_fixup): Likewise.
* elf/dl-symaddr.c (_dl_symbol_address): Likewise.
* elf/rtld.c (dl_main): Likewise.
* sysdeps/aarch64/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/alpha/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/arm/dl-machine.h (elf_machine_rel): Likewise.
(elf_machine_rela): Likewise.
* sysdeps/hppa/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/hppa/dl-symaddr.c (_dl_symbol_address): Likewise.
* sysdeps/i386/dl-machine.h (elf_machine_rel): Likewise.
(elf_machine_rela): Likewise.
* sysdeps/ia64/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/m68k/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/microblaze/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/mips/dl-machine.h (ELF_MACHINE_BEFORE_RTLD_RELOC):
Likewise.
(elf_machine_reloc): Likewise.
(elf_machine_got_rel): Likewise.
* sysdeps/mips/dl-trampoline.c (__dl_runtime_resolve): Likewise.
* sysdeps/nios2/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela):
Likewise.
* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela):
Likewise.
* sysdeps/riscv/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela):
Likewise.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela):
Likewise.
* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela):
Likewise.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela):
Likewise.
* sysdeps/tile/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-04-04 22:09:37 +00:00
|
|
|
sym_value += SYMBOL_ADDRESS (sym_map, sym, true);
|
2003-01-12 19:22:32 +00:00
|
|
|
}
|
1996-06-12 04:51:27 +00:00
|
|
|
|
1997-03-25 02:22:23 +00:00
|
|
|
if (r_type == R_ALPHA_GLOB_DAT)
|
1996-07-08 06:17:19 +00:00
|
|
|
*reloc_addr = sym_value;
|
2001-12-12 00:10:27 +00:00
|
|
|
#ifdef RESOLVE_CONFLICT_FIND_MAP
|
|
|
|
/* In .gnu.conflict section, R_ALPHA_JMP_SLOT relocations have
|
|
|
|
R_ALPHA_JMP_SLOT in lower 8 bits and the remaining 24 bits
|
|
|
|
are .rela.plt index. */
|
|
|
|
else if ((r_type & 0xff) == R_ALPHA_JMP_SLOT)
|
|
|
|
{
|
|
|
|
/* elf_machine_fixup_plt needs the map reloc_addr points into,
|
|
|
|
while in _dl_resolve_conflicts map is _dl_loaded. */
|
|
|
|
RESOLVE_CONFLICT_FIND_MAP (map, reloc_addr);
|
|
|
|
reloc = ((const Elf64_Rela *) D_PTR (map, l_info[DT_JMPREL]))
|
|
|
|
+ (r_type >> 8);
|
2017-06-14 01:17:25 +00:00
|
|
|
elf_machine_fixup_plt (map, 0, 0, 0, reloc, reloc_addr, sym_value);
|
2001-12-12 00:10:27 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
else if (r_type == R_ALPHA_JMP_SLOT)
|
2017-06-14 01:17:25 +00:00
|
|
|
elf_machine_fixup_plt (map, 0, 0, 0, reloc, reloc_addr, sym_value);
|
2001-12-12 00:10:27 +00:00
|
|
|
#endif
|
2001-02-28 15:23:48 +00:00
|
|
|
#ifndef RTLD_BOOTSTRAP
|
1997-03-25 02:22:23 +00:00
|
|
|
else if (r_type == R_ALPHA_REFQUAD)
|
1996-06-12 04:51:27 +00:00
|
|
|
{
|
2000-07-01 05:08:03 +00:00
|
|
|
/* Store value without causing unaligned trap. */
|
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Don't assume
reloc_addr is aligned.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/cris/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/hppa/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/ia64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/m68k/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/mips/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc64/dl-machine.h
(elf_machine_rela_relative, elf_machine_rela): Adjust.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative):
* sysdeps/sh/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
2003-07-31 06:33:52 +00:00
|
|
|
memcpy (reloc_addr_arg, &sym_value, 8);
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
2001-02-28 15:23:48 +00:00
|
|
|
#endif
|
2002-11-08 02:19:00 +00:00
|
|
|
else if (r_type == R_ALPHA_DTPMOD64)
|
|
|
|
{
|
2006-10-27 23:11:45 +00:00
|
|
|
# ifdef RTLD_BOOTSTRAP
|
2002-11-08 02:19:00 +00:00
|
|
|
/* During startup the dynamic linker is always index 1. */
|
|
|
|
*reloc_addr = 1;
|
2006-10-27 23:11:45 +00:00
|
|
|
# else
|
2002-11-08 02:19:00 +00:00
|
|
|
/* Get the information from the link map returned by the
|
|
|
|
resolv function. */
|
|
|
|
if (sym_map != NULL)
|
|
|
|
*reloc_addr = sym_map->l_tls_modid;
|
2006-10-27 23:11:45 +00:00
|
|
|
# endif
|
2002-11-08 02:19:00 +00:00
|
|
|
}
|
|
|
|
else if (r_type == R_ALPHA_DTPREL64)
|
|
|
|
{
|
2006-10-27 23:11:45 +00:00
|
|
|
# ifndef RTLD_BOOTSTRAP
|
2002-11-08 02:19:00 +00:00
|
|
|
/* During relocation all TLS symbols are defined and used.
|
|
|
|
Therefore the offset is already correct. */
|
2003-01-12 19:22:32 +00:00
|
|
|
*reloc_addr = sym_raw_value;
|
2006-10-27 23:11:45 +00:00
|
|
|
# endif
|
2002-11-08 02:19:00 +00:00
|
|
|
}
|
|
|
|
else if (r_type == R_ALPHA_TPREL64)
|
|
|
|
{
|
2006-10-27 23:11:45 +00:00
|
|
|
# ifdef RTLD_BOOTSTRAP
|
2003-02-14 06:02:01 +00:00
|
|
|
*reloc_addr = sym_raw_value + map->l_tls_offset;
|
2006-10-27 23:11:45 +00:00
|
|
|
# else
|
2002-11-08 02:19:00 +00:00
|
|
|
if (sym_map)
|
|
|
|
{
|
|
|
|
CHECK_STATIC_TLS (map, sym_map);
|
2003-02-14 06:02:01 +00:00
|
|
|
*reloc_addr = sym_raw_value + sym_map->l_tls_offset;
|
2002-11-08 02:19:00 +00:00
|
|
|
}
|
2006-10-27 23:11:45 +00:00
|
|
|
# endif
|
2002-11-08 02:19:00 +00:00
|
|
|
}
|
1996-06-12 04:51:27 +00:00
|
|
|
else
|
1999-07-21 16:57:52 +00:00
|
|
|
_dl_reloc_bad_type (map, r_type, 0);
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-06 00:33:22 +00:00
|
|
|
/* Let do-rel.h know that on Alpha if l_addr is 0, all RELATIVE relocs
|
|
|
|
can be skipped. */
|
|
|
|
#define ELF_MACHINE_REL_RELATIVE 1
|
|
|
|
|
elf: Avoid nested functions in the loader [BZ #27220]
dynamic-link.h is included more than once in some elf/ files (rtld.c,
dl-conflict.c, dl-reloc.c, dl-reloc-static-pie.c) and uses GCC nested
functions. This harms readability and the nested functions usage
is the biggest obstacle prevents Clang build (Clang doesn't support GCC
nested functions).
The key idea for unnesting is to add extra parameters (struct link_map
*and struct r_scope_elm *[]) to RESOLVE_MAP,
ELF_MACHINE_BEFORE_RTLD_RELOC, ELF_DYNAMIC_RELOCATE, elf_machine_rel[a],
elf_machine_lazy_rel, and elf_machine_runtime_setup. (This is inspired
by Stan Shebs' ppc64/x86-64 implementation in the
google/grte/v5-2.27/master which uses mixed extra parameters and static
variables.)
Future simplification:
* If mips elf_machine_runtime_setup no longer needs RESOLVE_GOTSYM,
elf_machine_runtime_setup can drop the `scope` parameter.
* If TLSDESC no longer need to be in elf_machine_lazy_rel,
elf_machine_lazy_rel can drop the `scope` parameter.
Tested on aarch64, i386, x86-64, powerpc64le, powerpc64, powerpc32,
sparc64, sparcv9, s390x, s390, hppa, ia64, armhf, alpha, and mips64.
In addition, tested build-many-glibcs.py with {arc,csky,microblaze,nios2}-linux-gnu
and riscv64-linux-gnu-rv64imafdc-lp64d.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-10-07 18:55:02 +00:00
|
|
|
static inline void
|
2005-03-15 Jakub Jelinek <jakub@redhat.com>
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rel_relative,
elf_machine_rela, elf_machine_rela_relative, elf_machine_lazy_rel):
Add inline keyword.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative, elf_machine_lazy_rel): Add always_inline
attribute.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative, elf_machine_lazy_rel): Likewise. Change
static inline into auto inline.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative, elf_machine_lazy_rel): Likewise.
* sysdeps/generic/dl-machine.h (elf_machine_rel, elf_machine_rela):
Likewise.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rel_relative,
elf_machine_rela, elf_machine_rela_relative, elf_machine_lazy_rel):
Likewise.
2005-03-15 22:57:26 +00:00
|
|
|
__attribute__ ((always_inline))
|
2001-08-24 14:53:03 +00:00
|
|
|
elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
|
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Don't assume
reloc_addr is aligned.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/cris/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/hppa/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/ia64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/m68k/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/mips/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc64/dl-machine.h
(elf_machine_rela_relative, elf_machine_rela): Adjust.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative):
* sysdeps/sh/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
2003-07-31 06:33:52 +00:00
|
|
|
void *const reloc_addr_arg)
|
2001-08-24 08:43:21 +00:00
|
|
|
{
|
2004-03-05 10:22:54 +00:00
|
|
|
/* XXX Make some timings. Maybe it's preferable to test for
|
2001-08-24 08:43:21 +00:00
|
|
|
unaligned access and only do it the complex way if necessary. */
|
|
|
|
Elf64_Addr reloc_addr_val;
|
|
|
|
|
|
|
|
/* Load value without causing unaligned trap. */
|
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Don't assume
reloc_addr is aligned.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/cris/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/hppa/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/ia64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/m68k/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/mips/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc64/dl-machine.h
(elf_machine_rela_relative, elf_machine_rela): Adjust.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative):
* sysdeps/sh/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
2003-07-31 06:33:52 +00:00
|
|
|
memcpy (&reloc_addr_val, reloc_addr_arg, 8);
|
2001-08-24 08:43:21 +00:00
|
|
|
reloc_addr_val += l_addr;
|
|
|
|
|
|
|
|
/* Store value without causing unaligned trap. */
|
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Don't assume
reloc_addr is aligned.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/cris/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/hppa/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/ia64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/m68k/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/mips/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc64/dl-machine.h
(elf_machine_rela_relative, elf_machine_rela): Adjust.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative):
* sysdeps/sh/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
2003-07-31 06:33:52 +00:00
|
|
|
memcpy (reloc_addr_arg, &reloc_addr_val, 8);
|
2001-08-24 08:43:21 +00:00
|
|
|
}
|
|
|
|
|
elf: Avoid nested functions in the loader [BZ #27220]
dynamic-link.h is included more than once in some elf/ files (rtld.c,
dl-conflict.c, dl-reloc.c, dl-reloc-static-pie.c) and uses GCC nested
functions. This harms readability and the nested functions usage
is the biggest obstacle prevents Clang build (Clang doesn't support GCC
nested functions).
The key idea for unnesting is to add extra parameters (struct link_map
*and struct r_scope_elm *[]) to RESOLVE_MAP,
ELF_MACHINE_BEFORE_RTLD_RELOC, ELF_DYNAMIC_RELOCATE, elf_machine_rel[a],
elf_machine_lazy_rel, and elf_machine_runtime_setup. (This is inspired
by Stan Shebs' ppc64/x86-64 implementation in the
google/grte/v5-2.27/master which uses mixed extra parameters and static
variables.)
Future simplification:
* If mips elf_machine_runtime_setup no longer needs RESOLVE_GOTSYM,
elf_machine_runtime_setup can drop the `scope` parameter.
* If TLSDESC no longer need to be in elf_machine_lazy_rel,
elf_machine_lazy_rel can drop the `scope` parameter.
Tested on aarch64, i386, x86-64, powerpc64le, powerpc64, powerpc32,
sparc64, sparcv9, s390x, s390, hppa, ia64, armhf, alpha, and mips64.
In addition, tested build-many-glibcs.py with {arc,csky,microblaze,nios2}-linux-gnu
and riscv64-linux-gnu-rv64imafdc-lp64d.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-10-07 18:55:02 +00:00
|
|
|
static inline void
|
2005-03-15 Jakub Jelinek <jakub@redhat.com>
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rel_relative,
elf_machine_rela, elf_machine_rela_relative, elf_machine_lazy_rel):
Add inline keyword.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative, elf_machine_lazy_rel): Add always_inline
attribute.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative, elf_machine_lazy_rel): Likewise. Change
static inline into auto inline.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative, elf_machine_lazy_rel): Likewise.
* sysdeps/generic/dl-machine.h (elf_machine_rel, elf_machine_rela):
Likewise.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rel_relative,
elf_machine_rela, elf_machine_rela_relative, elf_machine_lazy_rel):
Likewise.
2005-03-15 22:57:26 +00:00
|
|
|
__attribute__ ((always_inline))
|
elf: Avoid nested functions in the loader [BZ #27220]
dynamic-link.h is included more than once in some elf/ files (rtld.c,
dl-conflict.c, dl-reloc.c, dl-reloc-static-pie.c) and uses GCC nested
functions. This harms readability and the nested functions usage
is the biggest obstacle prevents Clang build (Clang doesn't support GCC
nested functions).
The key idea for unnesting is to add extra parameters (struct link_map
*and struct r_scope_elm *[]) to RESOLVE_MAP,
ELF_MACHINE_BEFORE_RTLD_RELOC, ELF_DYNAMIC_RELOCATE, elf_machine_rel[a],
elf_machine_lazy_rel, and elf_machine_runtime_setup. (This is inspired
by Stan Shebs' ppc64/x86-64 implementation in the
google/grte/v5-2.27/master which uses mixed extra parameters and static
variables.)
Future simplification:
* If mips elf_machine_runtime_setup no longer needs RESOLVE_GOTSYM,
elf_machine_runtime_setup can drop the `scope` parameter.
* If TLSDESC no longer need to be in elf_machine_lazy_rel,
elf_machine_lazy_rel can drop the `scope` parameter.
Tested on aarch64, i386, x86-64, powerpc64le, powerpc64, powerpc32,
sparc64, sparcv9, s390x, s390, hppa, ia64, armhf, alpha, and mips64.
In addition, tested build-many-glibcs.py with {arc,csky,microblaze,nios2}-linux-gnu
and riscv64-linux-gnu-rv64imafdc-lp64d.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-10-07 18:55:02 +00:00
|
|
|
elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
|
2011-10-05 09:50:05 +00:00
|
|
|
Elf64_Addr l_addr, const Elf64_Rela *reloc,
|
|
|
|
int skip_ifunc)
|
1996-06-12 04:51:27 +00:00
|
|
|
{
|
1998-08-28 22:54:12 +00:00
|
|
|
Elf64_Addr * const reloc_addr = (void *)(l_addr + reloc->r_offset);
|
2000-05-05 07:12:09 +00:00
|
|
|
unsigned long int const r_type = ELF64_R_TYPE (reloc->r_info);
|
1996-06-12 04:51:27 +00:00
|
|
|
|
1997-03-25 02:22:23 +00:00
|
|
|
if (r_type == R_ALPHA_JMP_SLOT)
|
1996-06-12 04:51:27 +00:00
|
|
|
{
|
|
|
|
/* Perform a RELATIVE reloc on the .got entry that transfers
|
|
|
|
to the .plt. */
|
1998-08-28 22:54:12 +00:00
|
|
|
*reloc_addr += l_addr;
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
1997-03-25 02:22:23 +00:00
|
|
|
else if (r_type == R_ALPHA_NONE)
|
1996-07-16 06:12:11 +00:00
|
|
|
return;
|
1996-06-12 04:51:27 +00:00
|
|
|
else
|
1999-07-21 16:57:52 +00:00
|
|
|
_dl_reloc_bad_type (map, r_type, 1);
|
1996-06-12 04:51:27 +00:00
|
|
|
}
|
|
|
|
|
2005-01-23 08:02:38 +00:00
|
|
|
#endif /* RESOLVE_MAP */
|