From patchwork Tue Dec 28 09:21:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 49323 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 826803858416 for ; Tue, 28 Dec 2021 09:21:33 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1]) by sourceware.org (Postfix) with ESMTPS id 349B23858C39 for ; Tue, 28 Dec 2021 09:21:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 349B23858C39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id BF05F307; Tue, 28 Dec 2021 10:21:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i-Jnhg8OA11A; Tue, 28 Dec 2021 10:21:18 +0100 (CET) Received: from begin.home (2a01cb0088600700de41a9fffe47ec49.ipv6.abo.wanadoo.fr [IPv6:2a01:cb00:8860:700:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 58B9813D; Tue, 28 Dec 2021 10:21:18 +0100 (CET) Received: from samy by begin.home with local (Exim 4.95) (envelope-from ) id 1n28fV-007kRS-GU; Tue, 28 Dec 2021 10:21:17 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited] hurd: let csu initialize tls Date: Tue, 28 Dec 2021 10:21:16 +0100 Message-Id: <20211228092116.1846811-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spamd-Bar: ++++ X-Rspamd-Server: hera Authentication-Results: hera.aquilenet.fr; none X-Rspamd-Queue-Id: BF05F307 X-Spamd-Result: default: False [4.90 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[] X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Since 9cec82de715b ("htl: Initialize later"), we let csu initialize pthreads. We can thus let it initialize tls later too, to better align with the generic order. Initialization however accesses ports which links/unlinks into the sigstate for unwinding. We can however easily skip that during initialization. --- hurd/hurd/userlink.h | 39 ++++++++++++++++++----------- sysdeps/mach/hurd/i386/init-first.c | 3 --- sysdeps/mach/hurd/libc-start.h | 31 ----------------------- 3 files changed, 24 insertions(+), 49 deletions(-) delete mode 100644 sysdeps/mach/hurd/libc-start.h diff --git a/hurd/hurd/userlink.h b/hurd/hurd/userlink.h index 4b5ba96cf2..0301658bfa 100644 --- a/hurd/hurd/userlink.h +++ b/hurd/hurd/userlink.h @@ -98,13 +98,16 @@ _hurd_userlink_link (struct hurd_userlink **chainp, link->resource.prevp = chainp; *chainp = link; - /* Also chain it on the current thread's list of active resources. */ - thread_chainp = &_hurd_self_sigstate ()->active_resources; - link->thread.next = *thread_chainp; - if (link->thread.next) - link->thread.next->thread.prevp = &link->thread.next; - link->thread.prevp = thread_chainp; - *thread_chainp = link; + if (!__LIBC_NO_TLS ()) + { + /* Also chain it on the current thread's list of active resources. */ + thread_chainp = &_hurd_self_sigstate ()->active_resources; + link->thread.next = *thread_chainp; + if (link->thread.next) + link->thread.next->thread.prevp = &link->thread.next; + link->thread.prevp = thread_chainp; + *thread_chainp = link; + } } # endif #endif @@ -131,11 +134,14 @@ _hurd_userlink_unlink (struct hurd_userlink *link) if (link->resource.next) link->resource.next->resource.prevp = link->resource.prevp; - /* Remove our link from the chain of currently active resources - for this thread. */ - *link->thread.prevp = link->thread.next; - if (link->thread.next) - link->thread.next->thread.prevp = link->thread.prevp; + if (!__LIBC_NO_TLS ()) + { + /* Remove our link from the chain of currently active resources + for this thread. */ + *link->thread.prevp = link->thread.next; + if (link->thread.next) + link->thread.next->thread.prevp = link->thread.prevp; + } return dealloc; } @@ -160,9 +166,12 @@ _hurd_userlink_move (struct hurd_userlink *new_link, new_link->resource.next->resource.prevp = &new_link->resource.next; *new_link->resource.prevp = new_link; - if (new_link->thread.next != NULL) - new_link->thread.next->thread.prevp = &new_link->thread.next; - *new_link->thread.prevp = new_link; + if (!__LIBC_NO_TLS ()) + { + if (new_link->thread.next != NULL) + new_link->thread.next->thread.prevp = &new_link->thread.next; + *new_link->thread.prevp = new_link; + } } # endif #endif diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c index a430aae085..5e85aa2bc5 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/i386/init-first.c @@ -184,9 +184,6 @@ init (int *data) _dl_phnum = d->phdrsz / sizeof (ElfW(Phdr)); assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0); } - - /* We need to setup TLS before initializing libpthread. */ - __libc_setup_tls (); #endif /* Call `init1' (above) with the user code as the return address, and the diff --git a/sysdeps/mach/hurd/libc-start.h b/sysdeps/mach/hurd/libc-start.h deleted file mode 100644 index 32cf99e16c..0000000000 --- a/sysdeps/mach/hurd/libc-start.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Hurd definitions for libc main startup. - Copyright (C) 2017-2021 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 - . */ - -#ifndef _LIBC_START_H -#define _LIBC_START_H - -#ifndef SHARED -/* By default we perform STT_GNU_IFUNC resolution *before* TLS - initialization, and this means you cannot, without machine - knowledge, access TLS from an IFUNC resolver. */ -#define ARCH_SETUP_IREL() apply_irel () -#define ARCH_SETUP_TLS() -#define ARCH_APPLY_IREL() -#endif /* ! SHARED */ - -#endif /* _LIBC_START_H */