From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 878943858D32 for ; Mon, 29 Aug 2022 12:27:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 878943858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661776017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eDBObYUz74IHboEmH9RM1PCFliaordsxahChRtkRQDA=; b=PEbil9JqDqWrJCBfzSNn+gf2D1/tKurDnALcBo5WbsLFqVlph287J34AiG9MRfeIJFf5// Om9JtGWG/VJyQNoznLGnldF7vf6G/S4R4YSwCJlKC6YCaCjrIo7eaDrl22/la/BeFhP8jI klJa5IpIV+WGUPurq0xCx3HUXzdJ8Bs= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-580-EyVtHw6RO-2smmJnAA8ujQ-1; Mon, 29 Aug 2022 08:26:56 -0400 X-MC-Unique: EyVtHw6RO-2smmJnAA8ujQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 349AD38041C6 for ; Mon, 29 Aug 2022 12:26:56 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.190]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C544F40B40E4 for ; Mon, 29 Aug 2022 12:26:55 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v4 1/3] ld.so: Export tls_init_tp_called as __rtld_tls_init_tp_called In-Reply-To: References: X-From-Line: 08163a7b1e71d42325dfa3baeec3193268729771 Mon Sep 17 00:00:00 2001 Message-Id: <08163a7b1e71d42325dfa3baeec3193268729771.1661775887.git.fweimer@redhat.com> Date: Mon, 29 Aug 2022 14:26:54 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This allows the rest of dynamic loader to check whether the TCB has been set up (and THREAD_GETMEM and THREAD_SETMEM will work). --- 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 cbbaf4a331..714434b21d 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); @@ -2315,7 +2315,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); } } @@ -2341,7 +2341,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 050a3032de..fc81affed0 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1217,6 +1217,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) -- 2.37.2