aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2024-09-24 13:23:10 +0200
committerFlorian Weimer <fweimer@redhat.com>2024-09-24 13:23:10 +0200
commit2abfa1907218c5ec9d52bb81bee3f1af652f67c7 (patch)
treef22efdd1ff57848090fd5e79e80f559b75767662
parent9802c0f2fec787ffcd192e1f2d6871dc586c6dad (diff)
downloadglibc-2abfa1907218c5ec9d52bb81bee3f1af652f67c7.zip
glibc-2abfa1907218c5ec9d52bb81bee3f1af652f67c7.tar.gz
glibc-2abfa1907218c5ec9d52bb81bee3f1af652f67c7.tar.bz2
elf: Move __rtld_malloc_init_stubs call into _dl_start_final
Calling an extern function in a different translation unit before self-relocation is brittle. The compiler may load the address at an earlier point in _dl_start, before self-relocation. In _dl_start_final, the call is behind a compiler barrier, so this cannot happen.
-rw-r--r--elf/rtld.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 9355b30..cb6b61d 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -452,6 +452,8 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
{
ElfW(Addr) start_addr;
+ __rtld_malloc_init_stubs ();
+
/* Do not use an initializer for these members because it would
interfere with __rtld_static_init. */
GLRO (dl_find_object) = &_dl_find_object;
@@ -574,8 +576,6 @@ _dl_start (void *arg)
function, that way the compiler cannot put accesses to the GOT
before ELF_DYNAMIC_RELOCATE. */
- __rtld_malloc_init_stubs ();
-
#ifdef DONT_USE_BOOTSTRAP_MAP
return _dl_start_final (arg);
#else