summaryrefslogtreecommitdiff
path: root/sysdeps/powerpc/powerpc32/dl-machine.h
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2021-09-24 13:44:48 -0700
committerFangrui Song <maskray@google.com>2021-09-24 13:44:48 -0700
commit23381aebf2576115acac23690af6081544fc80eb (patch)
tree12b19a2907794d5833cff7818792c5d49effef0a /sysdeps/powerpc/powerpc32/dl-machine.h
parent4ae2b8a42338f6adba7817539d05ad347154cda3 (diff)
downloadglibc-maskray/unnest.tar.gz
elf: Avoid nested functions in the loader (all ports) [BZ #27220]maskray/unnest
[Alternative to https://sourceware.org/pipermail/libc-alpha/2021-August/130340.html This version fixes all ports and doesn't add NESTING dispatches.] [Available at https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/maskray/unnest ] 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 CC=clang (which doesn't support the feature). The key idea for unnesting is to add extra parameters (link_map * and r_scope_elm *[]) to RESOLVE_MAP, ELF_MACHINE_BEFORE_RTLD_RELOC, ELF_DYNAMIC_RELOCATE, elf_machine_rela?, 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 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-linux-gnu, powerpc64le-linux-gnu and x86_64-linux-gnu. Tested build-many-glibcs.py glibcs with {alpha,arc,csky,hppa,ia64,microblaze,nios2,s390x,sh4,sparc64,sparc64}-linux-gnu, arm-linux-gnueabi, csky-linux-gnuabiv2, mips64-linux-gnu-n64, and riscv64-linux-gnu-rv64imafdc-lp64.
Diffstat (limited to 'sysdeps/powerpc/powerpc32/dl-machine.h')
-rw-r--r--sysdeps/powerpc/powerpc32/dl-machine.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h
index ced3a7b659..cda012dc1b 100644
--- a/sysdeps/powerpc/powerpc32/dl-machine.h
+++ b/sysdeps/powerpc/powerpc32/dl-machine.h
@@ -109,8 +109,6 @@ elf_machine_load_address (void)
return runtime_dynamic - elf_machine_dynamic ();
}
-#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) /* nothing */
-
/* The PLT uses Elf32_Rela relocs. */
#define elf_machine_relplt elf_machine_rela
@@ -172,7 +170,7 @@ extern int __elf_machine_runtime_setup (struct link_map *map,
int lazy, int profile);
static inline int
-elf_machine_runtime_setup (struct link_map *map,
+elf_machine_runtime_setup (struct link_map *map, struct r_scope_elem *scope[],
int lazy, int profile)
{
if (map->l_info[DT_JMPREL] == 0)
@@ -286,9 +284,10 @@ extern void _dl_reloc_overflow (struct link_map *map,
LOADADDR is the load address of the object; INFO is an array indexed
by DT_* of the .dynamic section info. */
-auto inline void __attribute__ ((always_inline))
-elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
- const Elf32_Sym *sym, const struct r_found_version *version,
+static inline void __attribute__ ((always_inline))
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
+ const Elf32_Rela *reloc, const Elf32_Sym *sym,
+ const struct r_found_version *version,
void *const reloc_addr_arg, int skip_ifunc)
{
Elf32_Addr *const reloc_addr = reloc_addr_arg;
@@ -317,7 +316,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
}
else
{
- sym_map = RESOLVE_MAP (&sym, version, r_type);
+ sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
value = SYMBOL_ADDRESS (sym_map, sym, true);
}
value += reloc->r_addend;
@@ -441,7 +440,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
}
}
-auto inline void __attribute__ ((always_inline))
+static inline void __attribute__ ((always_inline))
elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
void *const reloc_addr_arg)
{
@@ -449,8 +448,8 @@ elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
*reloc_addr = l_addr + reloc->r_addend;
}
-auto inline void __attribute__ ((always_inline))
-elf_machine_lazy_rel (struct link_map *map,
+static inline void __attribute__ ((always_inline))
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
Elf32_Addr l_addr, const Elf32_Rela *reloc,
int skip_ifunc)
{