From e2756903329365134089d23548e9083d23bc3dd9 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Sun, 19 Mar 2023 18:10:07 +0300 Subject: hurd: Only check for TLS initialization inside rtld or in static builds When glibc is built as a shared library, TLS is always initialized by the call of TLS_INIT_TP () macro made inside the dynamic loader, prior to running the main program (see dl-call_tls_init_tp.h). We can take advantage of this: we know for sure that __LIBC_NO_TLS () will evaluate to 0 in all other cases, so let the compiler know that explicitly too. Also, only define _hurd_tls_init () and TLS_INIT_TP () under the same conditions (either !SHARED or inside rtld), to statically assert that this is the case. Other than a microoptimization, this also helps with avoiding awkward sharing of the __libc_tls_initialized variable between ld.so and libc.so that we would have to do otherwise -- we know for sure that no sharing is required, simply because __libc_tls_initialized would always be set to true inside libc.so. Signed-off-by: Sergey Bugaev Message-Id: <20230319151017.531737-25-bugaevc@gmail.com> --- sysdeps/mach/hurd/Makefile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sysdeps/mach/hurd/Makefile') diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile index 0e880755ca..8fb6baf09e 100644 --- a/sysdeps/mach/hurd/Makefile +++ b/sysdeps/mach/hurd/Makefile @@ -197,6 +197,10 @@ ifeq (hurd, $(subdir)) sysdep_routines += cthreads endif +ifeq (elf, $(subdir)) +sysdep-dl-routines += dl-tls-initialized +endif + ifeq (io, $(subdir)) sysdep_routines += f_setlk close_nocancel close_nocancel_nostatus \ fcntl_nocancel open_nocancel openat_nocancel read_nocancel \ -- cgit 1.4.1