From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60046.outbound.protection.outlook.com [40.107.6.46]) by sourceware.org (Postfix) with ESMTPS id 63AFC385841A for ; Thu, 3 Nov 2022 16:15:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 63AFC385841A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=mgpQyrfNdstr3DusoG8VAo1toBHyORkXYejVaZxondPcRQB9zZJvGd3iYJE3GBNDjTSRvC5dbDzrUOpEL3ttiQhWbUpaondAk6VNTw6okH50arBaa1yl2p4muAGyl3uWg3w2MfRuulrWc8EQJiP2zb8w5CyAtlcJ861zo/5mMtUQq3NP704qTU8szeH52//HFJbecEEldJiN3Ud4hkhYoum6LWiIU5TdnYVEbikxIqvwd4ceFE/4dviUK8NLBRHskHvkZJiv1v49icNDAZU3pQzyyVyI8TUGqATAQAVuS/1M2jqr9/JFmHw+5138sW0/PI0RiLf6LS8d5fcv5d+yTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yGyWlA2Lg4tF7ETHdxBljYjnI74ly7zu35uQoWMB2c8=; b=IWmk13EeXatTk9RtEIDAeiSSYZbq2rYH4voK9Albs6cr4xYs8Vts1KMYXp4kpIMpDvHdax/05OAg1Pdw9kBMr1SfaF8CLWaWYdVHsPtDh3rS/jW/7aqYbFeyuociuqrIllf0vzvS9sOJgkbxhma6h2f8MsRce2CheF7R/MYIQZxUlsQbXrYVNBQWHg5x+w17vyMdQfFClEYxsFvh4M2MD03M5XsOboWN5YDtGp2XnJRn791K9C6tBur/5r8Fd9T/k5hd2oYW7o5NInj3uvglNQnXflg078VcZj2GOFCyHSCUOwhiZFNE0PB4xog+abxjI2me5R/pW2oSgO29zp+vcA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yGyWlA2Lg4tF7ETHdxBljYjnI74ly7zu35uQoWMB2c8=; b=7aqF9gOS0cuec+9Ej6/S7xLBcTSicxSzUHgEbkCHz7fsJFSwXKrglfz8fr7NicYgfBJEOq74qfeoG2YNnemEL29rhsRY62cOofyryg2FoZ9DrCzHEinnSaHsJDqLRM6QdISdPZPkBd6i4DHZueVr6WWPRL44/cCuB9RPxJHjoac= Received: from DB6PR07CA0114.eurprd07.prod.outlook.com (2603:10a6:6:2c::28) by DU0PR08MB9608.eurprd08.prod.outlook.com (2603:10a6:10:448::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.19; Thu, 3 Nov 2022 16:15:35 +0000 Received: from DBAEUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2c:cafe::a4) by DB6PR07CA0114.outlook.office365.com (2603:10a6:6:2c::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22 via Frontend Transport; Thu, 3 Nov 2022 16:15:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT056.mail.protection.outlook.com (100.127.142.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20 via Frontend Transport; Thu, 3 Nov 2022 16:15:34 +0000 Received: ("Tessian outbound 73ab5f36653e:v130"); Thu, 03 Nov 2022 16:15:34 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0f335c78d9a5cf5b X-CR-MTA-TID: 64aa7808 Received: from 9613131effbb.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8B94F0C2-26B5-452B-A8EE-EC6DDD74F9E0.1; Thu, 03 Nov 2022 16:15:27 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9613131effbb.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Nov 2022 16:15:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bT7pfW4zKrFNz/eYZE88bdO41/Hyz4IUXKAG843fBqmIeFJLJa11B/AfqdiLUzG+Z33bhUdZSxlmdsyrjSXtJu5fLWRITZe7Syn5eUdTiYIMuZvR/G7uYfJxV/SnkcgsGAqDSS7xCl8YFg0R7wmJSA7lMGAmQQ5OA9bLagS9Varngi2y1+8aHdLnLpThO49NbTXc2vHQVhIoNwgpPU3fjwIiXOof09FricekWJMwjK+YbL1Xmhg0Ra1hpOxrQq8iv/7vNO2tLNruNODjq6zaOjeXamlZjYfx17eFkk96tNm+UAIC0tMWj6+oI/55qaQuRgA03tofN6YuN+ERM9Uacw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yGyWlA2Lg4tF7ETHdxBljYjnI74ly7zu35uQoWMB2c8=; b=BvKfJAROdBc+04tizwCNFFe778oIKDCXFoVqxm/gwaD6xtAWZTCJi1DB9mH7MDfUgfFkjtGSqd04gCjgm//Jhu0t6sSP5BhHhEgDwwLCwrjaP3HqOyXVj3Sy53V05egHbdh7YdBnJqSL4Uiksut2/tdfe3PlIdWE9Od6WHKhOb5pe4wvSjYfftoWSc/PlN8mIXLLOU2E2ke19gkeX4h3qX2KRygDtn0wEFTmzGpjmlUEa8VONQv8hpGNBPEBZ588GuCvzsg1iJOg3dYVYM7ZfHlhef3i7M7kocvhaNXKOp5uK7HOQJO16DPisIqQmLVX7IeXTikajRVi2LBERlD2iQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yGyWlA2Lg4tF7ETHdxBljYjnI74ly7zu35uQoWMB2c8=; b=7aqF9gOS0cuec+9Ej6/S7xLBcTSicxSzUHgEbkCHz7fsJFSwXKrglfz8fr7NicYgfBJEOq74qfeoG2YNnemEL29rhsRY62cOofyryg2FoZ9DrCzHEinnSaHsJDqLRM6QdISdPZPkBd6i4DHZueVr6WWPRL44/cCuB9RPxJHjoac= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by DB5PR08MB10140.eurprd08.prod.outlook.com (2603:10a6:10:4a1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.16; Thu, 3 Nov 2022 16:15:21 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::81ce:94a0:632d:7016]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::81ce:94a0:632d:7016%3]) with mapi id 15.20.5791.022; Thu, 3 Nov 2022 16:15:21 +0000 Date: Thu, 3 Nov 2022 16:15:08 +0000 From: Szabolcs Nagy To: Florian Weimer Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] elf: Introduce and call_tls_init_tp (bug 29249) Message-ID: References: <87edukf5f0.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87edukf5f0.fsf@oldenburg.str.redhat.com> X-ClientProxiedBy: LO4P265CA0242.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:350::16) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB7179:EE_|DB5PR08MB10140:EE_|DBAEUR03FT056:EE_|DU0PR08MB9608:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e5c8dcb-afd0-44ef-3324-08dabdb6a367 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: C07DllfA7n9iwOtFiaS1bpIM1xmN+IeN7EZQCTwQ/2kRQuqdODL/2ev0bwwZLad0PUwEdz8uDOy0RfKWWmHMaPnnXD1W63oYz591I3S2jPBbtehm1DV0avIBtLLEg25GAGx7Rjtd8kS4QpI100VRShmHsbrqEJREXWEzalK0aWtPdo27LJTtatrLlD02tCnEcLZoT+Z4AUaezYORddrmpbE8nbr0e1/YC+EQfs0QgTlAiHT+0zQcaWdlUZ3RI8tZcaCSUlKGPT3Kg7gxW+/qckXE/1qjqXkwPTGCEhRG9tlZH6+xP4KX5znqg6ukUEA9cjwae7ZLGbvDXAyNLAoCj7wdDb5yzJGbL3jqXt+IikYGUitcj1/O+Mw54oZ3COys/HVtvSCqFvTy5guM9d+3aaH5cwWPubLOvYG5596XUAxYq5y3JknMZo8vwKu2YDS7b8P3VABEd4op2ZViHp0XRj1JvZ4s4KKWCgXJkZG9+HdHolLQyU9YSkZzbwoyUtAL1GBlRRzY/ITSTHGXxjJnh8h2duNCdWJFJJbMIp7ixDQUBzkwmaSNQyOBeTidJvOj/mk3I/l/oKsuka2ZwQZqRKwY/72NHeBV3hPO0XynZhEZWLnUxRFNnqNrk6hqzxOZIWuS5m3lM2AdXpABA/S7JBXzpaZ/c2YTw4uAdd1/jb0ERXlFOfgCfKzFnM96ROBc0ln+conyDoEwxeezdY+m/xXxjyhvZzi3U1tBfAMVsvr2wZ91UQ8W27b3dJ4WaOBqEJ9/Dn5kx/P/LK2q6YJ3cA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB7179.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(376002)(346002)(39860400002)(366004)(451199015)(66899015)(2906002)(83380400001)(86362001)(8676002)(36756003)(6512007)(6506007)(4326008)(41300700001)(66556008)(26005)(38100700002)(6666004)(6916009)(186003)(6486002)(30864003)(5660300002)(66476007)(66946007)(316002)(44832011)(8936002)(2616005)(478600001)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR08MB10140 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 147ef944-be4e-4d39-e575-08dabdb69b31 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eFazLMy1bj2MnYBxERikca5+ZzXtUIeA+utY4NiCNRgEPl0xmK2nMsBRBcUNN+J0ND5eNOuI8xsbeecTP+OOWkyo9Ax9DJnanR/o/XD6DCSlbZ4i3Q2MZnYqVonvI2L/xKpqvKgNuugzEK+i8X1+gLowq4C9bNgZgMO27XJEia1Xg2uOI1FHJtkK2s2PFI+FnJd3h9tl91SOzDjMnKrxTI3qcxPR+p6Smrd9gHHSzoKGfbEMHek95gJmmnvzB+wgU4VWQpMkrqCmPvjQB/pAzM3lgBNNbBZg7eohh19/gP1HBoNAeFrzIRFkRRfEjHmCbviNiY6izNoh/vsHbKVQfI6s/AlDKnH9QddY2TtX1JKuC7DLnqKH7aBiBrhiCVSzkdR4p2fL2adnq/2uN89ekUctmhpSLaTUwPi08CE+W1wFWSbGqb34V9EXELMOUCti6onGr6MBuIi2LWhHnFxpdIORDxeeZrHpHNCa3tPF0St+aclxHJDNM/KUeWjU+aphMNopsNhVerSYCU9+UG0Oik3CZFbCvqVR6z9mkaoQtyXZPbUvhxVvCc8cCH0KLa6xSuhF9dFKS3FdojhXYbhe9IqNH7kqTm0HeW6B4pONrW198VqjNJmUhPt5YI/axBEkSB8zo+LByucCOPKqeoCiC5ILKWxzq7WWnzP28GUiWM55dilowoIgWwjNHlHXJsG9bho8B6NuEabKLrgyXwkcnN3Bw8qo/6MpH4TAxCQQhPH0D1imcrI7UmkH6/Um/Tu+LEnGUsStFfpZmwJ4B09d47ezKq8ptKwlqh/M7S418RSLts6d8MI+1SdTHMgYwR/+ X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(396003)(136003)(451199015)(46966006)(36840700001)(40470700004)(8676002)(4326008)(70206006)(36756003)(2906002)(47076005)(70586007)(83380400001)(40480700001)(6666004)(316002)(82310400005)(86362001)(6506007)(356005)(36860700001)(40460700003)(81166007)(82740400003)(478600001)(6512007)(5660300002)(26005)(30864003)(2616005)(41300700001)(8936002)(6862004)(66899015)(6486002)(186003)(336012)(44832011)(2004002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2022 16:15:34.9337 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e5c8dcb-afd0-44ef-3324-08dabdb6a367 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9608 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY 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: The 11/03/2022 16:01, Florian Weimer via Libc-alpha wrote: > This makes it more likely that the compiler can compute the strlen > argument in _startup_fatal at compile time, which is required to > avoid a dependency on strlen this early during process startup. > > Tested on aarch64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, > s390x-linux-gnu, x86_64-linux-gnu. Built with build-many-glibcs.py. this looks good. dropping arch specific custom error messages is ok. using _startup_fatal instead of _dl_fatal_printf in rtld for tp init failure is ok. Reviewed-by: Szabolcs Nagy > > --- > csu/libc-tls.c | 14 +++++--------- > elf/rtld.c | 14 +++----------- > sysdeps/aarch64/nptl/tls.h | 2 +- > sysdeps/alpha/nptl/tls.h | 2 +- > sysdeps/arc/nptl/tls.h | 3 +-- > sysdeps/csky/nptl/tls.h | 3 +-- > sysdeps/generic/dl-call_tls_init_tp.h | 34 ++++++++++++++++++++++++++++++++++ > sysdeps/generic/startup.h | 2 +- > sysdeps/hppa/nptl/tls.h | 2 +- > sysdeps/i386/nptl/tls.h | 3 +-- > sysdeps/ia64/nptl/tls.h | 2 +- > sysdeps/loongarch/nptl/tls.h | 2 +- > sysdeps/m68k/nptl/tls.h | 2 +- > sysdeps/mach/hurd/i386/tls.h | 10 +++++----- > sysdeps/microblaze/nptl/tls.h | 2 +- > sysdeps/mips/nptl/tls.h | 3 +-- > sysdeps/nios2/nptl/tls.h | 2 +- > sysdeps/or1k/nptl/tls.h | 2 +- > sysdeps/powerpc/nptl/tls.h | 2 +- > sysdeps/riscv/nptl/tls.h | 2 +- > sysdeps/s390/nptl/tls.h | 2 +- > sysdeps/sh/nptl/tls.h | 2 +- > sysdeps/sparc/nptl/tls.h | 2 +- > sysdeps/unix/sysv/linux/arm/tls.h | 3 +-- > sysdeps/x86_64/nptl/tls.h | 2 +- > 25 files changed, 68 insertions(+), 51 deletions(-) > > diff --git a/csu/libc-tls.c b/csu/libc-tls.c > index 0a216c5502..ca4def2613 100644 > --- a/csu/libc-tls.c > +++ b/csu/libc-tls.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > > #ifdef SHARED > #error makefile bug, this file is for static only > @@ -147,14 +148,14 @@ __libc_setup_tls (void) > tcb_offset = roundup (memsz + GLRO(dl_tls_static_surplus), max_align); > tlsblock = _dl_early_allocate (tcb_offset + TLS_INIT_TCB_SIZE + max_align); > if (tlsblock == NULL) > - _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n"); > + _startup_fatal_tls_error (); > #elif TLS_DTV_AT_TP > tcb_offset = roundup (TLS_INIT_TCB_SIZE, align ?: 1); > tlsblock = _dl_early_allocate (tcb_offset + memsz + max_align > + TLS_PRE_TCB_SIZE > + GLRO(dl_tls_static_surplus)); > if (tlsblock == NULL) > - _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n"); > + _startup_fatal_tls_error (); > tlsblock += TLS_PRE_TCB_SIZE; > #else > /* In case a model with a different layout for the TCB and DTV > @@ -191,16 +192,11 @@ __libc_setup_tls (void) > #if TLS_TCB_AT_TP > INSTALL_DTV ((char *) tlsblock + tcb_offset, _dl_static_dtv); > > - const char *lossage = TLS_INIT_TP ((char *) tlsblock + tcb_offset); > + call_tls_init_tp ((char *) tlsblock + tcb_offset); > #elif TLS_DTV_AT_TP > INSTALL_DTV (tlsblock, _dl_static_dtv); > - const char *lossage = TLS_INIT_TP (tlsblock); > -#else > -# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" > + call_tls_init_tp (tlsblock); > #endif > - if (__builtin_expect (lossage != NULL, 0)) > - _startup_fatal (lossage); > - __tls_init_tp (); > > /* Update the executable's link map with enough information to make > the TLS routines happy. */ > diff --git a/elf/rtld.c b/elf/rtld.c > index 8671594f1f..70ad1acc43 100644 > --- a/elf/rtld.c > +++ b/elf/rtld.c > @@ -52,6 +52,7 @@ > #include > #include > #include > +#include > > #include > > @@ -796,10 +797,7 @@ cannot allocate TLS data structures for initial thread\n"); > GL(dl_initial_dtv) = GET_DTV (tcbp); > > /* And finally install it for the main thread. */ > - const char *lossage = TLS_INIT_TP (tcbp); > - if (__glibc_unlikely (lossage != NULL)) > - _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage); > - __tls_init_tp (); > + call_tls_init_tp (tcbp); > __rtld_tls_init_tp_called = true; > > return tcbp; > @@ -2348,13 +2346,7 @@ dl_main (const ElfW(Phdr) *phdr, > > /* And finally install it for the main thread. */ > if (! __rtld_tls_init_tp_called) > - { > - const char *lossage = TLS_INIT_TP (tcbp); > - if (__glibc_unlikely (lossage != NULL)) > - _dl_fatal_printf ("cannot set up thread-local storage: %s\n", > - lossage); > - __tls_init_tp (); > - } > + call_tls_init_tp (tcbp); > > /* Make sure no new search directories have been added. */ > assert (GLRO(dl_init_all_dirs) == GL(dl_all_dirs)); > diff --git a/sysdeps/aarch64/nptl/tls.h b/sysdeps/aarch64/nptl/tls.h > index 08aa2eff89..6fe084c1ef 100644 > --- a/sysdeps/aarch64/nptl/tls.h > +++ b/sysdeps/aarch64/nptl/tls.h > @@ -72,7 +72,7 @@ typedef struct > special attention since 'errno' is not yet available and if the > operation can cause a failure 'errno' must not be touched. */ > # define TLS_INIT_TP(tcbp) \ > - ({ __asm __volatile ("msr tpidr_el0, %0" : : "r" (tcbp)); NULL; }) > + ({ __asm __volatile ("msr tpidr_el0, %0" : : "r" (tcbp)); true; }) > > /* Value passed to 'clone' for initialization of the thread register. */ > # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 > diff --git a/sysdeps/alpha/nptl/tls.h b/sysdeps/alpha/nptl/tls.h > index 8f5b69ad3b..48dc1369fc 100644 > --- a/sysdeps/alpha/nptl/tls.h > +++ b/sysdeps/alpha/nptl/tls.h > @@ -69,7 +69,7 @@ typedef struct > special attention since 'errno' is not yet available and if the > operation can cause a failure 'errno' must not be touched. */ > # define TLS_INIT_TP(tcbp) \ > - (__builtin_set_thread_pointer ((void *)(tcbp)), NULL) > + (__builtin_set_thread_pointer ((void *)(tcbp)), true) > > /* Value passed to 'clone' for initialization of the thread register. */ > # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 > diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h > index 7fc6602b23..948e618a3a 100644 > --- a/sysdeps/arc/nptl/tls.h > +++ b/sysdeps/arc/nptl/tls.h > @@ -75,8 +75,7 @@ typedef struct > long result_var; \ > __builtin_set_thread_pointer (tcbp); \ > result_var = INTERNAL_SYSCALL_CALL (arc_settls, (tcbp));\ > - INTERNAL_SYSCALL_ERROR_P (result_var) \ > - ? "settls syscall error" : NULL; \ > + !INTERNAL_SYSCALL_ERROR_P (result_var); \ > }) > > /* Value passed to 'clone' for initialization of the thread register. */ > diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h > index 58d6ab0fb2..3f7afc9339 100644 > --- a/sysdeps/csky/nptl/tls.h > +++ b/sysdeps/csky/nptl/tls.h > @@ -92,8 +92,7 @@ typedef struct > ({ long int result_var; \ > result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \ > (char *) (tcbp) + TLS_TCB_OFFSET); \ > - INTERNAL_SYSCALL_ERROR_P (result_var) \ > - ? "unknown error" : NULL; }) > + !INTERNAL_SYSCALL_ERROR_P (result_var); }) > > /* Return the address of the dtv for the current thread. */ > # define THREAD_DTV() \ > diff --git a/sysdeps/generic/dl-call_tls_init_tp.h b/sysdeps/generic/dl-call_tls_init_tp.h > new file mode 100644 > index 0000000000..411feda3fc > --- /dev/null > +++ b/sysdeps/generic/dl-call_tls_init_tp.h > @@ -0,0 +1,34 @@ > +/* Invoke TLS_INIT_TP and __tls_init_tp with error handling. > + Copyright (C) 2022 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 > + . */ > + > +#include > +#include > + > +static inline void > +_startup_fatal_tls_error (void) > +{ > + _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n"); > +} > + > +static inline void > +call_tls_init_tp (void *addr) > +{ > + if (!TLS_INIT_TP (addr)) > + _startup_fatal_tls_error (); > + __tls_init_tp (); > +} > diff --git a/sysdeps/generic/startup.h b/sysdeps/generic/startup.h > index 45979ab231..4b444511b4 100644 > --- a/sysdeps/generic/startup.h > +++ b/sysdeps/generic/startup.h > @@ -19,7 +19,7 @@ > /* Targets should override this file if the default definitions below > will not work correctly very early before TLS is initialized. */ > > -#include > +#include > > /* Use macro instead of inline function to avoid including . */ > #define _startup_fatal(message) __libc_fatal ((message)) > diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h > index e6b0bd5c71..6af22cdc00 100644 > --- a/sysdeps/hppa/nptl/tls.h > +++ b/sysdeps/hppa/nptl/tls.h > @@ -74,7 +74,7 @@ typedef struct > special attention since 'errno' is not yet available and if the > operation can cause a failure 'errno' must not be touched. */ > # define TLS_INIT_TP(tcbp) \ > - ({ __set_cr27(tcbp); NULL; }) > + ({ __set_cr27(tcbp); true; }) > > /* Value passed to 'clone' for initialization of the thread register. */ > # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 > diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h > index 91090bf287..553b55b3f2 100644 > --- a/sysdeps/i386/nptl/tls.h > +++ b/sysdeps/i386/nptl/tls.h > @@ -203,8 +203,7 @@ tls_fill_user_desc (union user_desc_init *desc, > which is necessary since we have changed it. */ \ > TLS_SET_GS (_segdescr.desc.entry_number * 8 + 3); \ > \ > - _result == 0 ? NULL \ > - : "set_thread_area failed when setting up thread-local storage\n"; }) > + _result == 0; }) > > # define TLS_DEFINE_INIT_TP(tp, pd) \ > union user_desc_init _segdescr; \ > diff --git a/sysdeps/ia64/nptl/tls.h b/sysdeps/ia64/nptl/tls.h > index d2411b3c1a..4085c56832 100644 > --- a/sysdeps/ia64/nptl/tls.h > +++ b/sysdeps/ia64/nptl/tls.h > @@ -105,7 +105,7 @@ register struct pthread *__thread_self __asm__("r13"); > special attention since 'errno' is not yet available and if the > operation can cause a failure 'errno' must not be touched. */ > # define TLS_INIT_TP(thrdescr) \ > - (__thread_self = (thrdescr), INIT_SYSINFO, NULL) > + (__thread_self = (thrdescr), INIT_SYSINFO, true) > > /* Value passed to 'clone2' for initialization of the thread register. */ > # define TLS_DEFINE_INIT_TP(tp, pd) \ > diff --git a/sysdeps/loongarch/nptl/tls.h b/sysdeps/loongarch/nptl/tls.h > index 24bffe3a0a..e8b616854f 100644 > --- a/sysdeps/loongarch/nptl/tls.h > +++ b/sysdeps/loongarch/nptl/tls.h > @@ -83,7 +83,7 @@ typedef struct > #define TLS_INIT_TP(tcbp) \ > ({ \ > __thread_self = (char *) tcbp + TLS_TCB_OFFSET; \ > - NULL; \ > + true; \ > }) > > /* Return the address of the dtv for the current thread. */ > diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h > index 742e1b6767..ebcc118bbe 100644 > --- a/sysdeps/m68k/nptl/tls.h > +++ b/sysdeps/m68k/nptl/tls.h > @@ -90,7 +90,7 @@ typedef struct > \ > _sys_result = INTERNAL_SYSCALL_CALL (set_thread_area, \ > ((void *) (tcbp)) + TLS_TCB_OFFSET); \ > - INTERNAL_SYSCALL_ERROR_P (_sys_result) ? "unknown error" : NULL; }) > + !INTERNAL_SYSCALL_ERROR_P (_sys_result); }) > > # define TLS_DEFINE_INIT_TP(tp, pd) \ > void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE > diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h > index 602bacc0de..2847e3ee61 100644 > --- a/sysdeps/mach/hurd/i386/tls.h > +++ b/sysdeps/mach/hurd/i386/tls.h > @@ -117,12 +117,12 @@ extern unsigned short __init1_desc; > > # define HURD_SEL_LDT(sel) (__builtin_expect ((sel) & 4, 0)) > > -static inline const char * __attribute__ ((unused)) > +static inline bool __attribute__ ((unused)) > _hurd_tls_init (tcbhead_t *tcb) > { > HURD_TLS_DESC_DECL (desc, tcb); > thread_t self = __mach_thread_self (); > - const char *msg = NULL; > + bool success = true; > > /* This field is used by TLS accesses to get our "thread pointer" > from the TLS point of view. */ > @@ -141,14 +141,14 @@ _hurd_tls_init (tcbhead_t *tcb) > assert_perror (err); > if (err) > { > - msg = "i386_set_ldt failed"; > + success = false; > goto out; > } > } > else if (err) > { > assert_perror (err); /* Separate from above with different line #. */ > - msg = "i386_set_gdt failed"; > + success = false; > goto out; > } > > @@ -157,7 +157,7 @@ _hurd_tls_init (tcbhead_t *tcb) > > out: > __mach_port_deallocate (__mach_task_self (), self); > - return msg; > + return success; > } > > /* Code to initially initialize the thread pointer. This might need > diff --git a/sysdeps/microblaze/nptl/tls.h b/sysdeps/microblaze/nptl/tls.h > index 588fd1c5d6..d8be1932b9 100644 > --- a/sysdeps/microblaze/nptl/tls.h > +++ b/sysdeps/microblaze/nptl/tls.h > @@ -75,7 +75,7 @@ typedef struct > /* Code to initially initialize the thread pointer. > r21 is reserved for thread pointer. */ > # define TLS_INIT_TP(tcbp) \ > - ({ __asm __volatile ("or r21,r0,%0" : : "r" ((void *)tcbp)); NULL; }) > + ({ __asm __volatile ("or r21,r0,%0" : : "r" ((void *)tcbp)); true; }) > > # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 > > diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h > index 2aa7cb4bb8..bac6e8771c 100644 > --- a/sysdeps/mips/nptl/tls.h > +++ b/sysdeps/mips/nptl/tls.h > @@ -116,8 +116,7 @@ typedef struct > ({ long int result_var; \ > result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \ > (char *) (tcbp) + TLS_TCB_OFFSET); \ > - INTERNAL_SYSCALL_ERROR_P (result_var) \ > - ? "unknown error" : NULL; }) > + !INTERNAL_SYSCALL_ERROR_P (result_var); }) > > /* Value passed to 'clone' for initialization of the thread register. */ > # define TLS_DEFINE_INIT_TP(tp, pd) \ > diff --git a/sysdeps/nios2/nptl/tls.h b/sysdeps/nios2/nptl/tls.h > index cb231e2a4b..f5a9713f93 100644 > --- a/sysdeps/nios2/nptl/tls.h > +++ b/sysdeps/nios2/nptl/tls.h > @@ -88,7 +88,7 @@ register struct pthread *__thread_self __asm__("r23"); > > /* Code to initially initialize the thread pointer. */ > # define TLS_INIT_TP(tcbp) \ > - (__thread_self = (struct pthread *) ((char *) tcbp + TLS_TCB_OFFSET), NULL) > + (__thread_self = (struct pthread *) ((char *) tcbp + TLS_TCB_OFFSET), true) > > /* Value passed to 'clone' for initialization of the thread register. */ > # define TLS_DEFINE_INIT_TP(tp, pd) \ > diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h > index e82f444738..eda0e893ae 100644 > --- a/sysdeps/or1k/nptl/tls.h > +++ b/sysdeps/or1k/nptl/tls.h > @@ -112,7 +112,7 @@ register tcbhead_t *__thread_self __asm__("r10"); > It's hard to fail this, so return NULL always. */ > > # define TLS_INIT_TP(tcbp) \ > - ({__thread_self = ((tcbhead_t *)tcbp + 1); NULL;}) > + ({__thread_self = ((tcbhead_t *)tcbp + 1); true;}) > > /* Value passed to 'clone' for initialization of the thread register. */ > # define TLS_DEFINE_INIT_TP(tp, pd) \ > diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h > index e62a96238a..68a1d8b546 100644 > --- a/sysdeps/powerpc/nptl/tls.h > +++ b/sysdeps/powerpc/nptl/tls.h > @@ -139,7 +139,7 @@ typedef struct > __thread_register = (void *) (tcbp) + TLS_TCB_OFFSET; \ > THREAD_SET_HWCAP (__tcb.hwcap); \ > THREAD_SET_AT_PLATFORM (__tcb.at_platform); \ > - NULL; \ > + true; \ > }) > > /* Value passed to 'clone' for initialization of the thread register. */ > diff --git a/sysdeps/riscv/nptl/tls.h b/sysdeps/riscv/nptl/tls.h > index 700c2f5189..b221980399 100644 > --- a/sysdeps/riscv/nptl/tls.h > +++ b/sysdeps/riscv/nptl/tls.h > @@ -79,7 +79,7 @@ typedef struct > > /* Code to initially initialize the thread pointer. */ > # define TLS_INIT_TP(tcbp) \ > - ({ __thread_self = (char*)tcbp + TLS_TCB_OFFSET; NULL; }) > + ({ __thread_self = (char*)tcbp + TLS_TCB_OFFSET; true; }) > > /* Return the address of the dtv for the current thread. */ > # define THREAD_DTV() \ > diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h > index 98d7870148..937c49dda6 100644 > --- a/sysdeps/s390/nptl/tls.h > +++ b/sysdeps/s390/nptl/tls.h > @@ -112,7 +112,7 @@ typedef struct > INIT_SYSINFO; \ > \ > __builtin_set_thread_pointer (_thrdescr); \ > - NULL; \ > + true; \ > }) > > /* Value passed to 'clone' for initialization of the thread register. */ > diff --git a/sysdeps/sh/nptl/tls.h b/sysdeps/sh/nptl/tls.h > index 1530489a6c..3882114f5c 100644 > --- a/sysdeps/sh/nptl/tls.h > +++ b/sysdeps/sh/nptl/tls.h > @@ -83,7 +83,7 @@ typedef struct > special attention since 'errno' is not yet available and if the > operation can cause a failure 'errno' must not be touched. */ > # define TLS_INIT_TP(tcbp) \ > - ({ __asm __volatile ("ldc %0,gbr" : : "r" (tcbp)); NULL; }) > + ({ __asm __volatile ("ldc %0,gbr" : : "r" (tcbp)); true; }) > > # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 > > diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h > index 95a69cb824..e8fbe40e7b 100644 > --- a/sysdeps/sparc/nptl/tls.h > +++ b/sysdeps/sparc/nptl/tls.h > @@ -89,7 +89,7 @@ register struct pthread *__thread_self __asm__("%g7"); > > /* Code to initially initialize the thread pointer. */ > # define TLS_INIT_TP(descr) \ > - (__thread_self = (__typeof (__thread_self)) (descr), NULL) > + (__thread_self = (__typeof (__thread_self)) (descr), true) > > /* Value passed to 'clone' for initialization of the thread register. */ > # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) > diff --git a/sysdeps/unix/sysv/linux/arm/tls.h b/sysdeps/unix/sysv/linux/arm/tls.h > index 9d1601af44..045fad2275 100644 > --- a/sysdeps/unix/sysv/linux/arm/tls.h > +++ b/sysdeps/unix/sysv/linux/arm/tls.h > @@ -33,8 +33,7 @@ > # define TLS_INIT_TP(tcbp) \ > ({ long int result_var; \ > result_var = INTERNAL_SYSCALL_CALL (set_tls, (tcbp)); \ > - INTERNAL_SYSCALL_ERROR_P (result_var) \ > - ? "unknown error" : NULL; }) > + !INTERNAL_SYSCALL_ERROR_P (result_var); }) > > #endif /* __ASSEMBLER__ */ > > diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h > index 75f8020975..63744f6384 100644 > --- a/sysdeps/x86_64/nptl/tls.h > +++ b/sysdeps/x86_64/nptl/tls.h > @@ -156,7 +156,7 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80, > "S" (_thrdescr) \ > : "memory", "cc", "r11", "cx"); \ > \ > - _result ? "cannot set %fs base address for thread-local storage" : 0; \ > + _result == 0; \ > }) > > # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) > > base-commit: d33705c0b020632274318323931695a99753b5be >