glibc/sysdeps
Fangrui Song b19de59d62 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>
(cherry picked from commit 490e6c62aa)
2022-04-08 14:18:11 -04:00
..
aarch64 elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
alpha elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
arc elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
arm elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
csky elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
generic ld.so: Initialize bootstrap_map.l_ld_readonly [BZ #28340] 2021-11-03 07:53:12 +01:00
gnu hurd: Fix glob lstat compatibility 2021-07-22 20:31:52 +02:00
hppa elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
htl htl: Do not expose pthread hidden proto outside libpthread 2021-07-18 20:25:33 +00:00
hurd Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
i386 elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
ia64 elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
ieee754 Update math: redirect roundeven function 2021-06-27 07:56:57 -07:00
m68k elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
mach hurd if_index: Explicitly use AF_INET for if index discovery 2022-02-03 16:22:04 +01:00
microblaze elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
mips elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
nios2 elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
nptl nptl: Fix type of pthread_mutexattr_getrobust_np, pthread_mutexattr_setrobust_np (bug 28036) 2021-09-21 07:15:25 +02:00
posix getcwd: Set errno to ERANGE for size == 1 (CVE-2021-3999) 2022-01-24 11:37:06 +05:30
powerpc elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
pthread pthread/tst-cancel28: Fix barrier re-init race condition 2021-12-14 10:07:27 +05:30
riscv elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
s390 elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
sh elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
sparc elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00
unix hppa: Use END instead of PSEUDO_END in swapcontext.S 2022-03-15 23:14:37 +00:00
wordsize-32 Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
wordsize-64 Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
x86 x86: Fix TEST_NAME to make it a string in tst-strncmp-rtm.c 2022-02-18 15:34:40 -08:00
x86_64 elf: Avoid nested functions in the loader [BZ #27220] 2022-04-08 14:18:11 -04:00