diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2023-03-19 18:10:07 +0300 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-04-10 23:33:30 +0200 |
commit | b37899d34d2190ef4b454283188f22519f096048 (patch) | |
tree | d21e03749c679cfa3659cc9acb126903668c7897 /sysdeps/mach/hurd/x86 | |
parent | 4644fb9c4c10287c875dc60c345a3eb6f4c8e87b (diff) | |
download | glibc-b37899d34d2190ef4b454283188f22519f096048.zip glibc-b37899d34d2190ef4b454283188f22519f096048.tar.gz glibc-b37899d34d2190ef4b454283188f22519f096048.tar.bz2 |
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 <bugaevc@gmail.com>
Message-Id: <20230319151017.531737-25-bugaevc@gmail.com>
Diffstat (limited to 'sysdeps/mach/hurd/x86')
-rw-r--r-- | sysdeps/mach/hurd/x86/init-first.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/sysdeps/mach/hurd/x86/init-first.c b/sysdeps/mach/hurd/x86/init-first.c index 48c330e..89a5f44 100644 --- a/sysdeps/mach/hurd/x86/init-first.c +++ b/sysdeps/mach/hurd/x86/init-first.c @@ -40,13 +40,6 @@ extern char **_dl_argv; #ifndef SHARED static tcbhead_t __init1_tcbhead; -# ifndef __x86_64__ -unsigned short __init1_desc; -# endif -#endif - -#ifdef __x86_64__ -unsigned char __libc_tls_initialized; #endif /* Things that want to be run before _hurd_init or much anything else. @@ -166,9 +159,7 @@ first_init (void) _hurd_tls_init (&__init1_tcbhead); /* Make sure __LIBC_NO_TLS () keeps evaluating to 1. */ -# ifdef __x86_64__ - __libc_tls_initialized = 0; -# else +# ifndef __x86_64__ asm ("movw %%gs,%w0" : "=m" (__init1_desc)); # endif #endif |