about summary refs log tree commit diff
path: root/sysdeps/mach/hurd/i386/dl-tls-initialized.c
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2023-03-19 18:10:07 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-04-14 10:31:22 +0000
commite2756903329365134089d23548e9083d23bc3dd9 (patch)
tree99c465b707b132731dc6b8c29adae59f5d8dd23b /sysdeps/mach/hurd/i386/dl-tls-initialized.c
parentba00d787f3469b02032766b074d4df9071fa7e24 (diff)
downloadglibc-e2756903329365134089d23548e9083d23bc3dd9.tar.gz
glibc-e2756903329365134089d23548e9083d23bc3dd9.tar.xz
glibc-e2756903329365134089d23548e9083d23bc3dd9.zip
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/i386/dl-tls-initialized.c')
-rw-r--r--sysdeps/mach/hurd/i386/dl-tls-initialized.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sysdeps/mach/hurd/i386/dl-tls-initialized.c b/sysdeps/mach/hurd/i386/dl-tls-initialized.c
new file mode 100644
index 0000000000..493ec2396c
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/dl-tls-initialized.c
@@ -0,0 +1,21 @@
+/* Determine whether TLS is initialized, for i386/Hurd.
+   Copyright (C) 1995-2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef SHARED
+unsigned short __init1_desc;
+#endif