From 1f34a2328890aa192141f96449d25b77f666bf47 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 3 Nov 2022 17:28:03 +0100 Subject: elf: Introduce 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 --- csu/libc-tls.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'csu') diff --git a/csu/libc-tls.c b/csu/libc-tls.c index 0a216c5..ca4def2 100644 --- a/csu/libc-tls.c +++ b/csu/libc-tls.c @@ -25,6 +25,7 @@ #include #include #include +#include #ifdef SHARED #error makefile bug, this file is for static only @@ -147,14 +148,14 @@ __libc_setup_tls (void) tcb_offset = roundup (memsz + GLRO(dl_tls_static_surplus), max_align); tlsblock = _dl_early_allocate (tcb_offset + TLS_INIT_TCB_SIZE + max_align); if (tlsblock == NULL) - _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n"); + _startup_fatal_tls_error (); #elif TLS_DTV_AT_TP tcb_offset = roundup (TLS_INIT_TCB_SIZE, align ?: 1); tlsblock = _dl_early_allocate (tcb_offset + memsz + max_align + TLS_PRE_TCB_SIZE + GLRO(dl_tls_static_surplus)); if (tlsblock == NULL) - _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n"); + _startup_fatal_tls_error (); tlsblock += TLS_PRE_TCB_SIZE; #else /* In case a model with a different layout for the TCB and DTV @@ -191,16 +192,11 @@ __libc_setup_tls (void) #if TLS_TCB_AT_TP INSTALL_DTV ((char *) tlsblock + tcb_offset, _dl_static_dtv); - const char *lossage = TLS_INIT_TP ((char *) tlsblock + tcb_offset); + call_tls_init_tp ((char *) tlsblock + tcb_offset); #elif TLS_DTV_AT_TP INSTALL_DTV (tlsblock, _dl_static_dtv); - const char *lossage = TLS_INIT_TP (tlsblock); -#else -# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" + call_tls_init_tp (tlsblock); #endif - if (__builtin_expect (lossage != NULL, 0)) - _startup_fatal (lossage); - __tls_init_tp (); /* Update the executable's link map with enough information to make the TLS routines happy. */ -- cgit v1.1