glibc/sysdeps/riscv
Maciej W. Rozycki 10a446ddcc 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 23:09:37 +01:00
..
bits RISC-V: Generic <math.h> and soft-fp Routines 2018-01-29 10:26:35 -08:00
nofpu RISC-V: Add ABI Lists 2018-01-29 10:37:28 -08:00
nptl hurd: add gscope support 2018-03-11 13:06:33 +01:00
rv64 RISC-V: Build Infastructure 2018-01-29 10:43:15 -08:00
rvd RISC-V: fmax/fmin: Handle signalling NaNs correctly. 2018-02-22 14:31:54 -05:00
rvf RISC-V: fmax/fmin: Handle signalling NaNs correctly. 2018-02-22 14:31:54 -05:00
sys RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
__longjmp.S RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
bsd-_setjmp.c RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
bsd-setjmp.c RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
configure RISC-V: Build Infastructure 2018-01-29 10:43:15 -08:00
configure.ac RISC-V: Build Infastructure 2018-01-29 10:43:15 -08:00
dl-machine.h elf: Unify symbol address run-time calculation [BZ #19818] 2018-04-04 23:09:37 +01:00
dl-tls.h RISC-V: Thread-Local Storage Support 2018-01-29 10:25:58 -08:00
dl-trampoline.S RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
e_sqrtl.c RISC-V: Generic <math.h> and soft-fp Routines 2018-01-29 10:26:35 -08:00
fpu_control.h RISC-V: Generic <math.h> and soft-fp Routines 2018-01-29 10:26:35 -08:00
gccframe.h RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
Implies RISC-V: Build Infastructure 2018-01-29 10:43:15 -08:00
jmpbuf-offsets.h RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
jmpbuf-unwind.h RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
ldsodefs.h RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
libc-tls.c RISC-V: Thread-Local Storage Support 2018-01-29 10:25:58 -08:00
linkmap.h RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
machine-gmon.h RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
Makefile RISC-V: Build Infastructure 2018-01-29 10:43:15 -08:00
math-tests.h RISC-V: Generic <math.h> and soft-fp Routines 2018-01-29 10:26:35 -08:00
memusage.h RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
preconfigure RISC-V: Build Infastructure 2018-01-29 10:43:15 -08:00
setjmp.S RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
sfp-machine.h RISC-V: Generic <math.h> and soft-fp Routines 2018-01-29 10:26:35 -08:00
sotruss-lib.c RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
stackinfo.h RISC-V: Thread-Local Storage Support 2018-01-29 10:25:58 -08:00
start.S RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00
tininess.h RISC-V: Generic <math.h> and soft-fp Routines 2018-01-29 10:26:35 -08:00
tls-macros.h RISC-V: Do not initialize $gp in TLS macros. 2018-02-22 14:28:47 -05:00
tst-audit.h RISC-V: ABI Implementation 2018-01-29 10:25:29 -08:00