From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id B8566382EA30; Thu, 27 Oct 2022 09:37:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8566382EA30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666863424; bh=Ftl3PHxE3BmFZdqvG9dr+JPArmHuu9k43A+AZDPOFkU=; h=From:To:Subject:Date:From; b=QcjQJjo0UeSEHyMQApjBec6vU8pyu0W1wZKgaHPti6U6mNt8TrDXvKOT97QuVVNFW /PuSNs647vdfzzETXJFgFXnm4RnYRTplfozzvPnl+3byZAVq1/+COvqm5m82HH7cVA Rsseob3PRqGcFnUsT4bQRXX5B8ZLoPwvlQWRbQxE= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc] ld.so: Export tls_init_tp_called as __rtld_tls_init_tp_called X-Act-Checkin: glibc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/master X-Git-Oldrev: 77db67c56b24bba3c735aac34a6f796c909b68c0 X-Git-Newrev: a65ff76c9a1811dd2396ab45563f645579c0e687 Message-Id: <20221027093704.B8566382EA30@sourceware.org> Date: Thu, 27 Oct 2022 09:37:04 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a65ff76c9a1811dd2396ab45563f645579c0e687 commit a65ff76c9a1811dd2396ab45563f645579c0e687 Author: Florian Weimer Date: Thu Oct 27 11:36:44 2022 +0200 ld.so: Export tls_init_tp_called as __rtld_tls_init_tp_called This allows the rest of dynamic loader to check whether the TCB has been set up (and THREAD_GETMEM and THREAD_SETMEM will work). Reviewed-by: Siddhesh Poyarekar Diff: --- elf/rtld.c | 10 +++++----- sysdeps/generic/ldsodefs.h | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/elf/rtld.c b/elf/rtld.c index 3b78f40562..221be5c71e 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -730,7 +730,7 @@ match_version (const char *string, struct link_map *map) return 0; } -static bool tls_init_tp_called; +bool __rtld_tls_init_tp_called; static void * init_tls (size_t naudit) @@ -800,7 +800,7 @@ cannot allocate TLS data structures for initial thread\n"); if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage); __tls_init_tp (); - tls_init_tp_called = true; + __rtld_tls_init_tp_called = true; return tcbp; } @@ -2050,7 +2050,7 @@ dl_main (const ElfW(Phdr) *phdr, an old kernel that can't perform TLS_INIT_TP, even if no TLS is ever used. Trying to do it lazily is too hairy to try when there could be multiple threads (from a non-TLS-using libpthread). */ - bool was_tls_init_tp_called = tls_init_tp_called; + bool was_tls_init_tp_called = __rtld_tls_init_tp_called; if (tcbp == NULL) tcbp = init_tls (0); @@ -2321,7 +2321,7 @@ dl_main (const ElfW(Phdr) *phdr, consider_profiling); /* Add object to slot information data if necessasy. */ - if (l->l_tls_blocksize != 0 && tls_init_tp_called) + if (l->l_tls_blocksize != 0 && __rtld_tls_init_tp_called) _dl_add_to_slotinfo (l, true); } } @@ -2347,7 +2347,7 @@ dl_main (const ElfW(Phdr) *phdr, _dl_allocate_tls_init (tcbp, false); /* And finally install it for the main thread. */ - if (! tls_init_tp_called) + if (! __rtld_tls_init_tp_called) { const char *lossage = TLS_INIT_TP (tcbp); if (__glibc_unlikely (lossage != NULL)) diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 6b256b8388..0223aa9f12 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1219,6 +1219,9 @@ extern void *_dl_allocate_tls_storage (void) attribute_hidden; extern void *_dl_allocate_tls_init (void *, bool); rtld_hidden_proto (_dl_allocate_tls_init) +/* True if the TCB has been set up. */ +extern bool __rtld_tls_init_tp_called attribute_hidden; + /* Deallocate memory allocated with _dl_allocate_tls. */ extern void _dl_deallocate_tls (void *tcb, bool dealloc_tcb); rtld_hidden_proto (_dl_deallocate_tls)