about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2022-11-03 17:28:03 +0100
committerFlorian Weimer <fweimer@redhat.com>2022-11-03 17:28:03 +0100
commit1f34a2328890aa192141f96449d25b77f666bf47 (patch)
tree283ca2a4b46cf069da45f40663e779003064bcdc /elf
parentfb6ee7ba8122330ac819556a42cc56db07d9da76 (diff)
downloadglibc-1f34a2328890aa192141f96449d25b77f666bf47.tar.gz
glibc-1f34a2328890aa192141f96449d25b77f666bf47.tar.xz
glibc-1f34a2328890aa192141f96449d25b77f666bf47.zip
elf: Introduce <dl-call_tls_init_tp.h> and call_tls_init_tp (bug 29249)
This makes it more likely that the compiler can compute the strlen
argument in _startup_fatal at compile time, which is required to
avoid a dependency on strlen this early during process startup.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Diffstat (limited to 'elf')
-rw-r--r--elf/rtld.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 8671594f1f..70ad1acc43 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -52,6 +52,7 @@
 #include <dl-execve.h>
 #include <dl-find_object.h>
 #include <dl-audit-check.h>
+#include <dl-call_tls_init_tp.h>
 
 #include <assert.h>
 
@@ -796,10 +797,7 @@ cannot allocate TLS data structures for initial thread\n");
   GL(dl_initial_dtv) = GET_DTV (tcbp);
 
   /* And finally install it for the main thread.  */
-  const char *lossage = TLS_INIT_TP (tcbp);
-  if (__glibc_unlikely (lossage != NULL))
-    _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage);
-  __tls_init_tp ();
+  call_tls_init_tp (tcbp);
   __rtld_tls_init_tp_called = true;
 
   return tcbp;
@@ -2348,13 +2346,7 @@ dl_main (const ElfW(Phdr) *phdr,
 
   /* And finally install it for the main thread.  */
   if (! __rtld_tls_init_tp_called)
-    {
-      const char *lossage = TLS_INIT_TP (tcbp);
-      if (__glibc_unlikely (lossage != NULL))
-	_dl_fatal_printf ("cannot set up thread-local storage: %s\n",
-			  lossage);
-      __tls_init_tp ();
-    }
+    call_tls_init_tp (tcbp);
 
   /* Make sure no new search directories have been added.  */
   assert (GLRO(dl_init_all_dirs) == GL(dl_all_dirs));