glibc/csu
Florian Weimer ec935dea63 elf: Implement __libc_early_init
This function is defined in libc.so, and the dynamic loader calls
right after relocation has been finished, before any ELF constructors
or the preinit function is invoked.  It is also used in the static
build for initializing parts of the static libc.

To locate __libc_early_init, a direct symbol lookup function is used,
_dl_lookup_direct.  It does not search the entire symbol scope and
consults merely a single link map.  This function could also be used
to implement lookups in the vDSO (as an optimization).

A per-namespace variable (libc_map) is added for locating libc.so,
to avoid repeated traversals of the search scope.  It is similar to
GL(dl_initfirst).  An alternative would have been to thread a context
argument from _dl_open down to _dl_map_object_from_fd (where libc.so
is identified).  This could have avoided the global variable, but
the change would be larger as a result.  It would not have been
possible to use this to replace GL(dl_initfirst) because that global
variable is used to pass the function pointer past the stack switch
from dl_main to the main program.  Replacing that requires adding
a new argument to _dl_init, which in turn needs changes to the
architecture-specific libc.so startup code written in assembler.

__libc_early_init should not be used to replace _dl_var_init (as
it exists today on some architectures).  Instead, _dl_lookup_direct
should be used to look up a new variable symbol in libc.so, and
that should then be initialized from the dynamic loader, immediately
after the object has been loaded in _dl_map_object_from_fd (before
relocation is run).  This way, more IFUNC resolvers which depend on
these variables will work.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-04-24 22:32:09 +02:00
..
abi-note.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
check_fds.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
dso_handle.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
elf-init.c Introduce <elf-initfini.h> and ELF_INITFINI for all architectures 2020-02-18 15:12:25 +01:00
errno-loc.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
errno.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
gmon-start.c Introduce <elf-initfini.h> and ELF_INITFINI for all architectures 2020-02-18 15:12:25 +01:00
init-first.c elf: Implement __libc_early_init 2020-04-24 22:32:09 +02:00
init.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
libc-start.c elf: Implement __libc_early_init 2020-04-24 22:32:09 +02:00
libc-tls.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
Makefile Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
start.c More fallout from supporting only ELF 2012-01-08 00:45:01 -05:00
static-reloc.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
sysdep.c Moved to csu/errno-loc.c. 2005-12-14 15:06:39 +00:00
version.c Update copyright dates not handled by scripts/update-copyrights. 2020-01-01 00:21:22 +00:00
Versions Remove unused %include lines from Versions files. 2014-02-22 00:58:54 -08:00