]> sourceware.org Git - glibc.git/commitdiff
elf: Move __rtld_malloc_init_stubs call into _dl_start_final
authorFlorian Weimer <fweimer@redhat.com>
Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)
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.

elf/rtld.c

index 9355b30214d975c9a9731e355c5328ce0739e6dd..cb6b61d5705c438f2c017de6fb110b2851bfe06d 100644 (file)
@@ -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
This page took 0.041173 seconds and 5 git commands to generate.