Message ID | d7eb5cfd6953e9689c0306d808e234bd00741e6e.1611155254.git.szabolcs.nagy@arm.com |
---|---|
State | Committed |
Commit | 2682695e5c7acf1e60dd3b5c3a14d4e82416262c |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> 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 CC7083840C2A; Wed, 20 Jan 2021 15:32:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC7083840C2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611156738; bh=8zS5JXCD/PxxnmlCRDC4rWoLPJMFgEnFYKZ/loZc304=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=BjMaoHddWgfhCx0HzZMRL1vhyzXwYyHq+roK8KfH0849mtxNwUZUU7JtJsY3KQzrk TKz9mTfVLAhpbsQZP+3G/A34mrlvGo47L2aPkActgDrb6Il39c2IrJjO/VV6ecB95g e1L77BAuGlqfu3jtjnuLz63w4HSHh25pTpAfS+MQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2061.outbound.protection.outlook.com [40.107.20.61]) by sourceware.org (Postfix) with ESMTPS id 4F5653840C2A for <libc-alpha@sourceware.org>; Wed, 20 Jan 2021 15:32:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4F5653840C2A Received: from AM5PR0601CA0084.eurprd06.prod.outlook.com (2603:10a6:206::49) by DBBPR08MB5546.eurprd08.prod.outlook.com (2603:10a6:10:c3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Wed, 20 Jan 2021 15:32:12 +0000 Received: from AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:0:cafe::c1) by AM5PR0601CA0084.outlook.office365.com (2603:10a6:206::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Wed, 20 Jan 2021 15:32:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;sourceware.org; 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT060.mail.protection.outlook.com (10.152.16.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Wed, 20 Jan 2021 15:32:11 +0000 Received: ("Tessian outbound 8418c949a3fa:v71"); Wed, 20 Jan 2021 15:32:10 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 23a6477e8ff397a0 X-CR-MTA-TID: 64aa7808 Received: from 4d72bb613e6f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 436C8F27-AABA-403C-9A9A-4FC610A229DC.1; Wed, 20 Jan 2021 15:32:03 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4d72bb613e6f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 20 Jan 2021 15:32:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aI97fE7/4G4DlmAONGG8OTSNpU5h29yMr+bZyD9oROg3B8RrV8Rcxpt+jzGC/6u5QV8XVSsBsd2qGgLTEmGpOKTYVAFFgbbOzGIVlvao9Z7i83ihClKxzwEhwkFlTBAo4Lcu9AOb4EyYFPENLG4I4eI2NLRAHAdQZYg3Lr3SSf95ZF/wWbHr5jLmmQsoPDqhYObcgKe68eA2UoeON1oROa6pMrza8GnIGgATARXyDWJT8bIMkzHX9LDnTPA2rbwh0t3Zp2fCzSFFcnvn4wEhT2gTG4tq/i4qVDwpDbVjmGP/KCLwQvP9cMHyidzDc0+gbZTSJFLo5fIUVI4q/cQnPQ== 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-SenderADCheck; bh=8zS5JXCD/PxxnmlCRDC4rWoLPJMFgEnFYKZ/loZc304=; b=m9tBBVt036R7yZYQAx3Ati+AVqcX5awrIdmmFz3uyoFA59BTKBFXaCb8d7rcjKXRcPM9jicd8YYCT5sOuogQRHAzjurcfhf99VjGVSUMhnXss5jnRxSGPm1Hn0g80brOl6nPrfCPdAGWHdOwrdmf0B4j/Bp6SDo4+tgwYiJFRHUBFSZDLWsY4IxnDpBZ4pHqClwoiu1v6k7ReDncgCw3ycieIpVHMIw5bRicvLKGohDl7iEfAgbvdW3nwN07ddfnvY3G/zGxI3E8kVYePaTUv9phxVKIuhd/tdJAoQIhgjHoU8KEbN2P2U2EXbXkQ7X1b66cEwpKZ6c7T1SdWU56TQ== 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 Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) by PR3PR08MB5577.eurprd08.prod.outlook.com (2603:10a6:102:81::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Wed, 20 Jan 2021 15:32:03 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f%7]) with mapi id 15.20.3763.014; Wed, 20 Jan 2021 15:32:03 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v5 7/7] Make libc symbols hidden in static PIE Date: Wed, 20 Jan 2021 15:31:56 +0000 Message-Id: <d7eb5cfd6953e9689c0306d808e234bd00741e6e.1611155254.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <cover.1611155254.git.szabolcs.nagy@arm.com> References: <cover.1611155254.git.szabolcs.nagy@arm.com> Content-Type: text/plain X-Originating-IP: [217.140.106.51] X-ClientProxiedBy: LO2P265CA0184.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::28) To PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.51) by LO2P265CA0184.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Wed, 20 Jan 2021 15:32:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5e6f0c8a-6a76-40cc-4141-08d8bd588e44 X-MS-TrafficTypeDiagnostic: PR3PR08MB5577:|DBBPR08MB5546: X-Microsoft-Antispam-PRVS: <DBBPR08MB554647075E17C0D19A07B967EDA20@DBBPR08MB5546.eurprd08.prod.outlook.com> x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: vkFfxolFtoftIR6xOrOelJ1ZRsGEAbF3xMYtoOb/RwP9W6fTNOTDKON1hDGLLpOknoBKJryFuhOr/0l5Vt3+S6CHjmPF1UQiRamiHw9PjZmpRcX/qgbA9r9tzFIM8s2i0YwbDX88zLOTjaWlT9U8cUiehc3uucbW8nr1YTKmjHLIlOGEvXJzs6ZZ8A58TRqG6COwDY8PmjqCiPl+Isv89ByVa02F1VpN2uRzNTOz9D6Y/mMi5udOQbptjcdm/g6QC/JaYNsOq9WDN0/d/K920l25bTKtWs79o0VbDI2WYNHNdxRrZRag2UkLj/vaS9KeDRFTFECQPc2YIbjgHjcz0WzExWrJrhDK4f2NhhnE99X8e5PEhRlgpZiK0FKSpOPB32BbOTtI2eZlTJvXGKRra13jpnoBFrpkycs9/cMLHIRyy5UlzU0lfb0InX7ZCMAilA1x94kkHJ5Z4BgxDKJjiQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR08MB6320.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(66476007)(2906002)(316002)(52116002)(6666004)(186003)(16526019)(66556008)(83380400001)(36756003)(86362001)(6486002)(2616005)(478600001)(26005)(44832011)(8936002)(6512007)(6916009)(66946007)(69590400011)(956004)(8676002)(5660300002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: t6PRODRaflFk1vwY5+TNfh61m7/PfPtG4OgyGgjAfdlULIPg2wpKXnFqoMX/eo/0Cue2GQCCzxQbkdq35Jd9q6nKLHeReXOsVcL10LO+jFXvQSNc1OPPKGxa1zu5CCYYLapv4ud50tiwr3z7867zoFAmTlWn+wdrlqixSDhha59kZ0jN58TlvU8yDuqzmxs8364eADCRbZK9rXgR4MBRSj4RNQKbFzlxo6X58rQb3ZWdEajTT2SpJnklPDHPrUFdTgI9gxiGObO24adppJJiVC8D5avq6hnLnPGZVeKTfYbDrRcP7cAZWyIB5/KpJo6WPr6m4xXuPBjY+TtLOHfjRMyT0oyLBiOEHsNpdIvceo9+vmOESN5OSP1mJaYNCsY4/1TVEWWayEH0tmqHZB5iI6iF/QB6j20i/ImFd8gSc1m5CX3WNifMkofhws13TcWkbc+aowBA9FXMiJBt8k0gAyTEXGKFfCNAW0hcMwc+eY+bfYB9lTOhctJTnYaXAyJrkVFupe8W3VzBegJcMtJp6Gt0GDB4a6XdkMXa/vMXqDvkxtEhphmySv3ufd/G8ApGc4T2/eJ0z6dwQKs5BW/vWzywrk6HPzytRT4dYGqXvg2YXb+iomU55Is2K9e+A7O6rT3gXQnH/7W/Zzr8Yu0WvIZirwwXoeadwZCisWYbN8w4+XAUYJob2zVAO/C1pgqgvYL/Julsxwq2SgwYpVrQ/OBJTesmVfDkBBSMyrVLvF1yrlEB9zd8UF+WKbFiqnsiTJi2FO9xnd4K5052+mW5qy8aePBb/TrESDFWGHXgsZJ3di8l/pmf/wsiMLdsmcrqI2EXH8CJ805DVyqG/ulQNN9q4DM39emwKJZROl0r9PewtzFcFMZOsR8b9Cs/Zx8FIUt0eRLjrML/6E78qzrfpz1BDUpTMI2HX7njO8YibuZwDlWkTDGI+ZqUg9GWVWqGJOq7JpZCN9P+bHq9RBAQ7DV7lfmROUB5LuKO+zYrkt+NxGzjn+66S+/anUEfNJXl X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5577 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 2dd09933-35a4-49b8-92c9-08d8bd5888ea X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D2V6vFRfSD2+qBLBmEY3F3PGNLqNur8PBShXLdKIPs5QknliO2EA1cHVp4EmPOpG4Z0u0xyC9YVezH220OKzej6lg5NRhWwmuCsP5tElUyQMGs1vAWDbBMG3bIEqk+oGmcEsSXxzg88QHXQ74LG7b+o68yW9MMhtwV2TVr0pthZjJf8bgJgpMVxyOyjkX+Mu/1z2MWvF++mOtWHigov8MCBo/BYo5D3VR4qcuW9GXfAIdwUtIE+6fWQNoafiHxC/mUvNYknV66jfeg+K1olS4NsXCpYjOJ0tUtNuPiMpFjGsqDdiI+OH7F2+HREuvKBKofdvH9Z2erawlrelX9xyZYPR0EtJYntl7sdS9N7Xc8LH07K+GesfMGe4rirIrpXelBH/KIM2PqFEr/LVsgdDRaVkM0WxoMp9G+t++WMDG6+DA5By6bSRvmKB+7VvNW42ILSdPAmocXqO2Suqijm1jQriw/PUEitCh0AA4KMoyCaEKcy5G5nz/n3U5pe/P1lf 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:(4636009)(136003)(396003)(39860400002)(346002)(376002)(46966006)(69590400011)(316002)(186003)(70586007)(478600001)(6506007)(356005)(2906002)(82310400003)(44832011)(83380400001)(5660300002)(26005)(2616005)(81166007)(6916009)(70206006)(8676002)(336012)(6666004)(47076005)(82740400003)(36756003)(6486002)(16526019)(86362001)(956004)(8936002)(6512007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 15:32:11.3974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e6f0c8a-6a76-40cc-4141-08d8bd588e44 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: AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB5546 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Szabolcs Nagy via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Szabolcs Nagy <szabolcs.nagy@arm.com> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
fix ifunc with static pie [BZ #27072]
|
|
Commit Message
Szabolcs Nagy
Jan. 20, 2021, 3:31 p.m. UTC
Hidden visibility can avoid indirections and RELATIVE relocs in static PIE libc. The check should use IS_IN_LIB instead of IS_IN(libc) since all symbols are defined locally in static PIE and the optimization is useful in all libraries not just libc. However the test system links objects from libcrypt.a into dynamic linked test binaries where hidden visibility does not work. I think mixing static and shared libc components in the same binary should not be supported usage, but to be safe only use hidden in libc.a. On some targets (i386) this optimization cannot be applied because hidden visibility PIE ifunc functions don't work, so it is gated by NO_HIDDEN_EXTERN_FUNC_IN_PIE. From -static-pie linked 'int main(){}' this shaves off 71 relative relocs on aarch64 and reduces code size by about 2k. --- include/libc-symbols.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Comments
On 20/01/2021 12:31, Szabolcs Nagy via Libc-alpha wrote: > Hidden visibility can avoid indirections and RELATIVE relocs in > static PIE libc. > > The check should use IS_IN_LIB instead of IS_IN(libc) since all > symbols are defined locally in static PIE and the optimization is > useful in all libraries not just libc. However the test system > links objects from libcrypt.a into dynamic linked test binaries > where hidden visibility does not work. I think mixing static and > shared libc components in the same binary should not be supported > usage, but to be safe only use hidden in libc.a. Why do we need this linkage for testing? Could we fix it so this change could be used in all static libraries? > > On some targets (i386) this optimization cannot be applied because > hidden visibility PIE ifunc functions don't work, so it is gated by > NO_HIDDEN_EXTERN_FUNC_IN_PIE. > > From -static-pie linked 'int main(){}' this shaves off 71 relative > relocs on aarch64 and reduces code size by about 2k. Nice. LGTM, thanks. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> > --- > include/libc-symbols.h | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/include/libc-symbols.h b/include/libc-symbols.h > index ea126ae70c..f4dd735555 100644 > --- a/include/libc-symbols.h > +++ b/include/libc-symbols.h > @@ -434,13 +434,18 @@ for linking") > strong_alias(real, name) > #endif > > -#if defined SHARED || defined LIBC_NONSHARED \ > - || (BUILD_PIE_DEFAULT && IS_IN (libc)) > +#if defined SHARED || defined LIBC_NONSHARED > # define attribute_hidden __attribute__ ((visibility ("hidden"))) > #else > # define attribute_hidden > #endif > > +/* Mark all symbols hidden in static PIE libc to avoid GOT indirections. */ > +#if BUILD_PIE_DEFAULT && !defined NO_HIDDEN_EXTERN_FUNC_IN_PIE \ > + && IS_IN (libc) && !defined LIBC_NONSHARED > +# pragma GCC visibility push(hidden) > +#endif > + > #define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec"))) > > #define attribute_relro __attribute__ ((section (".data.rel.ro"))) > Ok.
The 01/21/2021 11:10, Adhemerval Zanella wrote: > On 20/01/2021 12:31, Szabolcs Nagy via Libc-alpha wrote: > > Hidden visibility can avoid indirections and RELATIVE relocs in > > static PIE libc. > > > > The check should use IS_IN_LIB instead of IS_IN(libc) since all > > symbols are defined locally in static PIE and the optimization is > > useful in all libraries not just libc. However the test system > > links objects from libcrypt.a into dynamic linked test binaries > > where hidden visibility does not work. I think mixing static and > > shared libc components in the same binary should not be supported > > usage, but to be safe only use hidden in libc.a. > > Why do we need this linkage for testing? Could we fix it so this > change could be used in all static libraries? i think the md5 and sha* tests want to directly call some internal symbol (for the hash implementation instead of the iterated password hash) which you can do if you static link libcrypt.a i don't know if this may appear in user code (static linking some libfoo.a from libc into a dynamic linked executable) may be the crypt tests can be changed to be fully static linked.
Szabolcs Nagy via Libc-alpha <libc-alpha@sourceware.org> writes: > Hidden visibility can avoid indirections and RELATIVE relocs in > static PIE libc. > > The check should use IS_IN_LIB instead of IS_IN(libc) since all > symbols are defined locally in static PIE and the optimization is > useful in all libraries not just libc. However the test system > links objects from libcrypt.a into dynamic linked test binaries > where hidden visibility does not work. I think mixing static and > shared libc components in the same binary should not be supported > usage, but to be safe only use hidden in libc.a. > > On some targets (i386) this optimization cannot be applied because > hidden visibility PIE ifunc functions don't work, so it is gated by > NO_HIDDEN_EXTERN_FUNC_IN_PIE. > > From -static-pie linked 'int main(){}' this shaves off 71 relative > relocs on aarch64 and reduces code size by about 2k. After this patch got merged, I noticed that malloc/tst-malloc-stats-cancellation never returns on ppc (32-bit only). It seems stuck in a futex_wait: #0 0x6fddab58 in futex_wait (private=0, expected=2, futex_word=0x6ff405ec <main_arena>) at ../sysdeps/nptl/futex-internal.h:146 #1 __lll_lock_wait_private (futex=0x6ff405ec <main_arena>) at ./lowlevellock.c:35 #2 0x6fde3614 in __GI___libc_malloc (bytes=bytes@entry=4096) at malloc.c:3235 #3 0x6fdbf7f0 in __GI__IO_file_doallocate (fp=0xf7dc01a0) at filedoalloc.c:101 #4 0x6fdd6c20 in __GI__IO_doallocbuf (fp=0xf7dc01a0) at libioP.h:948 #5 __GI__IO_doallocbuf (fp=fp@entry=0xf7dc01a0) at genops.c:342 #6 0x6fdd5768 in _IO_new_file_overflow (f=0xf7dc01a0, ch=-1) at fileops.c:745 #7 0x6fdd41c0 in _IO_new_file_xsputn (n=37, data=<optimized out>, f=<optimized out>) at libioP.h:948 #8 _IO_new_file_xsputn (f=0xf7dc01a0, data=<optimized out>, n=37) at fileops.c:1197 #9 0x6fdc19e8 in __GI__IO_fwrite (buf=0x6ffc1880, size=1, count=37, fp=0xf7dc01a0) at libioP.h:948 #10 0x6ffc0e80 in ?? () #11 0x6fd6641c in generic_start_main (main=0x6ffc0b10, argc=1, argv=0xf6c00760, auxvec=0x0, init=<optimized out>, rtld_fini=<optimized out>, stack_end=<optimized out>, fini=<optimized out>) at ../csu/libc-start.c:332 #12 0x6fd665c0 in __libc_start_main (argc=<optimized out>, argv=<optimized out>, ev=<optimized out>, auxvec=<optimized out>, rtld_fini=<optimized out>, stinfo=<optimized out>, stack_on_entry=<optimized out>) at ../sysdeps/unix/sysv/linux/powerpc/libc-start.c:98 #13 0x00000000 in ?? ()
The 01/21/2021 22:25, Tulio Magno Quites Machado Filho wrote: > Szabolcs Nagy via Libc-alpha <libc-alpha@sourceware.org> writes: > > > Hidden visibility can avoid indirections and RELATIVE relocs in > > static PIE libc. > > > > The check should use IS_IN_LIB instead of IS_IN(libc) since all > > symbols are defined locally in static PIE and the optimization is > > useful in all libraries not just libc. However the test system > > links objects from libcrypt.a into dynamic linked test binaries > > where hidden visibility does not work. I think mixing static and > > shared libc components in the same binary should not be supported > > usage, but to be safe only use hidden in libc.a. > > > > On some targets (i386) this optimization cannot be applied because > > hidden visibility PIE ifunc functions don't work, so it is gated by > > NO_HIDDEN_EXTERN_FUNC_IN_PIE. > > > > From -static-pie linked 'int main(){}' this shaves off 71 relative > > relocs on aarch64 and reduces code size by about 2k. > > After this patch got merged, I noticed that > malloc/tst-malloc-stats-cancellation never returns on ppc (32-bit only). that patch is only expected to change anything if defined PIC && !defined SHARED && defined IS_IN(libc) && !defined LIBC_NONSHARED i.e. when libc.a is compiled as pie. can you check the build log e.g. grep ' -DMODULE_NAME=libc .*-DPIC' build-and-check.log |grep -v ' -DSHARED' should not find anything. the backtrace e.g. can happen if malloc_stat was cancelled somehow while the malloc lock is held and then the main thread tries to print some error message but cannot get the malloc lock. but it is hard to tell just from the backtrace where things went wrong. > > It seems stuck in a futex_wait: > > #0 0x6fddab58 in futex_wait (private=0, expected=2, futex_word=0x6ff405ec <main_arena>) at ../sysdeps/nptl/futex-internal.h:146 > #1 __lll_lock_wait_private (futex=0x6ff405ec <main_arena>) at ./lowlevellock.c:35 > #2 0x6fde3614 in __GI___libc_malloc (bytes=bytes@entry=4096) at malloc.c:3235 > #3 0x6fdbf7f0 in __GI__IO_file_doallocate (fp=0xf7dc01a0) at filedoalloc.c:101 > #4 0x6fdd6c20 in __GI__IO_doallocbuf (fp=0xf7dc01a0) at libioP.h:948 > #5 __GI__IO_doallocbuf (fp=fp@entry=0xf7dc01a0) at genops.c:342 > #6 0x6fdd5768 in _IO_new_file_overflow (f=0xf7dc01a0, ch=-1) at fileops.c:745 > #7 0x6fdd41c0 in _IO_new_file_xsputn (n=37, data=<optimized out>, f=<optimized out>) at libioP.h:948 > #8 _IO_new_file_xsputn (f=0xf7dc01a0, data=<optimized out>, n=37) at fileops.c:1197 > #9 0x6fdc19e8 in __GI__IO_fwrite (buf=0x6ffc1880, size=1, count=37, fp=0xf7dc01a0) at libioP.h:948 > #10 0x6ffc0e80 in ?? () > #11 0x6fd6641c in generic_start_main (main=0x6ffc0b10, argc=1, argv=0xf6c00760, auxvec=0x0, init=<optimized out>, rtld_fini=<optimized out>, stack_end=<optimized out>, fini=<optimized out>) at ../csu/libc-start.c:332 > #12 0x6fd665c0 in __libc_start_main (argc=<optimized out>, argv=<optimized out>, ev=<optimized out>, auxvec=<optimized out>, rtld_fini=<optimized out>, stinfo=<optimized out>, stack_on_entry=<optimized out>) at ../sysdeps/unix/sysv/linux/powerpc/libc-start.c:98 > #13 0x00000000 in ?? () > > -- > Tulio Magno
This breaks every newly linked program. Andreas.
diff --git a/include/libc-symbols.h b/include/libc-symbols.h index ea126ae70c..f4dd735555 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -434,13 +434,18 @@ for linking") strong_alias(real, name) #endif -#if defined SHARED || defined LIBC_NONSHARED \ - || (BUILD_PIE_DEFAULT && IS_IN (libc)) +#if defined SHARED || defined LIBC_NONSHARED # define attribute_hidden __attribute__ ((visibility ("hidden"))) #else # define attribute_hidden #endif +/* Mark all symbols hidden in static PIE libc to avoid GOT indirections. */ +#if BUILD_PIE_DEFAULT && !defined NO_HIDDEN_EXTERN_FUNC_IN_PIE \ + && IS_IN (libc) && !defined LIBC_NONSHARED +# pragma GCC visibility push(hidden) +#endif + #define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec"))) #define attribute_relro __attribute__ ((section (".data.rel.ro")))