Message ID | b5dbaa167f4317c312e22fb761036d3570e6614a.1611155254.git.szabolcs.nagy@arm.com |
---|---|
State | Committed |
Commit | 86d439b06fb29af8d063ee8855ff63a863f46ef3 |
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 CF781396EC6C; Wed, 20 Jan 2021 15:32:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF781396EC6C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611156730; bh=lbHGQoKsZVXOkAj4spJE/YnNMQJTwdJDIwsgG2yiWQg=; 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=keFggnQiQ9/lDyNV1UUwaXLcF5nZ7SGsrcFljCu0MXKCdVUMeXVaPay9pLTdKTSji kmVpyTPZ8B7+orw2NDt44oj9fLY6w/b1tD/o3/isNup8eYc4WscZG8UJ/XERuyi1DR 2XTWAsTYC4d8DzQOgUQjX82FRN/F1d+8m3fkjS+4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80074.outbound.protection.outlook.com [40.107.8.74]) by sourceware.org (Postfix) with ESMTPS id 39E8E385700F for <libc-alpha@sourceware.org>; Wed, 20 Jan 2021 15:32:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 39E8E385700F Received: from AM0P190CA0002.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::12) by AM7PR08MB5319.eurprd08.prod.outlook.com (2603:10a6:20b:dc::22) 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:05 +0000 Received: from AM5EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:190::4) by AM0P190CA0002.outlook.office365.com (2603:10a6:208:190::12) 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:05 +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 AM5EUR03FT026.mail.protection.outlook.com (10.152.16.155) 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:05 +0000 Received: ("Tessian outbound 2b57fdd78668:v71"); Wed, 20 Jan 2021 15:32:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 73c1ae1cbf1557cd X-CR-MTA-TID: 64aa7808 Received: from 49fcc8980802.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 22DB98AE-8559-4E32-AD4E-7911B576CF01.1; Wed, 20 Jan 2021 15:31:46 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 49fcc8980802.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 20 Jan 2021 15:31:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M4B8ioztu99ZPN0TEHaUAIa/WMDujhbdTfFA84moZ1hesu340XTLMLCstGOPgv5cU+dyrTMjmmvpbkCfYwH7DkbFVMFEkQYsa/GoMjuYW9rdJz981e9bL3J/BwOOpe3SJuUBjwpxsVmwII1xgsoFnVPYxGVCyPoDHQpBki+AHVMszKG4ClRUVD8wUOe9fgs0+iZSeFn1gH63oi/XusVPsjHC9K1pT25FwXsrcUNmpKIBtqSsAbYYGzEztTNeTOv6hpbTf4sIz98/OTFO64oZpXFj/H3z6pUq4HUTThUbz2DIS0SGLeLfJKD/bsAJo7XMKro0h2COc/jlaQvu/Qb//A== 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=lbHGQoKsZVXOkAj4spJE/YnNMQJTwdJDIwsgG2yiWQg=; b=gvhsrUnWoCbuDVKkRo4uh/ZVK//CJ2y8lZhBn7klWDhlMQ+FZd0w0KCIDAzvM1K87KyMZvg2C/dDvSl7WOuXJSFvXP0seSVcGOqCBiUip/N4yYvAQasZO68lQ2Pw3NOxo+aqQH+HTB3V/M2Lyg5dyBSSulTTz+9LNmOmWa5PTxFpMQo8LbNcxmlrE+iFYf/L7L2c8bVI5llK/RoQcSDeRuF6H/0ARvwbKNJeIVNLywKfmQhFeTtul1rQzjEdqLKO02cZzGvt4V0gfwsud5oCEjqVxT5SVsPOFhOgfRZWorrqO/irHJftrAN0xfQZtd4GdmPRRXo3jhreJKOXl6h7Qw== 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:31:45 +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:31:45 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v5 6/7] csu: Move static pie self relocation later [BZ #27072] Date: Wed, 20 Jan 2021 15:31:39 +0000 Message-Id: <b5dbaa167f4317c312e22fb761036d3570e6614a.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: LO4P123CA0423.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18b::14) 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 LO4P123CA0423.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18b::14) 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:31:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c2fcba76-1e10-4f5b-9a11-08d8bd588a78 X-MS-TrafficTypeDiagnostic: PR3PR08MB5577:|AM7PR08MB5319: X-Microsoft-Antispam-PRVS: <AM7PR08MB531958089939BC55F53C83CEEDA20@AM7PR08MB5319.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: 7KflXLLl9NcxynGEpA9oMpXBdcmuArKLloSTldkvfdMdgYHerJhpKAjGlJ6OMqGMUdj2Z3/4P/2NiU34iAZdG3Pm3pLX5mG/RCd1uAc3MnKmIa1i8YeQpjl1M3YJ+29m8xRMwWnQg0oDF2JWz65OiTqCbMOWzIHWNjyVujUO3zhScDEUSFnrd5r/eeS+mXdySIyWnkM5122p9Spdh+7lkZCxLLROsTJWP2JKM5660Z8q7zOeGS0uO/5XcDhx2BILH01hl5XlD+OQkpnCpm58vbzqFNWV3Eon9+QOD55c/98SXppnytErokSa0YLxz8Y8l8Tuj3odik8BEGSeh21zlDwT48JZYRkfSgH/AV3ziWRuUrMe3KFTmbeht3GWgCwGQnJ1Kq7USuGFzzQRp+Eh+U5ylHx7AMHxdbjOBuwRXiusTDJTo+/el7wCHi2azqk3c4n49GpgC0tDlwGYaLLKuQ== 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: 4evL7SwH3nf6fMEhIL5bMFmPmDlR1nBfjBTu3QLit3twnttEUFB/whzXMysqx5zeJ5H5d2aPQWh0n8gjEP83dz38puTrTmxB6cyMFBBaDcvKzWrU4XTrQtmPadikW0v1E0pjeRgHkV3kDxBNmf3thQD4eOD0JkqBILNcr3D5o5zRUoBQ+bJjP72hIw9n4vG610W9IbQ0FZc1R+uTbi4scyrhR2Y5R1V/pQZZyHzr9FwjmHV4UgUSEVhRYexefTKH6tkPhWdujJE9H16bA7rlHH2hx4+zOEQaawjsO2Aai6CZUfG+BtcpNqHWvYh2vzVz8HhhoCQ0sL/ixp5z7pXf1SQ8dDtuNWMJnOAMRVb2IHkCc054fwKS5axFx/ckmOqruisNjqWkaXK+SEY3sHSnry3Xmgdp358sOb0rr7BZsvNac4vWNSg9oo9tSHsT1did05gvv9SsdSNi2j0YVG6ZwHlQ2xqUYrgx9MWNdE3PZt4WpsWfW6JUPMQn8ooVtp2JDrS1CeUHRw5yO5Wemx5/LJpwvfeR2Em4pwShXdKK2qpEbX+xUHkuSBiw1ZEPx6m2tEW7a8rB6LKDQtv3XQpf8TcdY9YgpNoURtqF95cCb8jDhy+vi/ZOYzWXe0GzwaOlC/P5dD31oKJ40FocbTHN9iG9tQAGwUL9iWIb1t22qcV/Txpegi2Ok5JkCs4GfxEJ0/8zvKfAltmCGprfbaCu+hqf8wXd1eirLIIPSXGQAvTXeF/c8o/nJMNAn0KwADc4wF2Yr+mSuV3V6si6HpEv+pU0x3IqgmSBEw1qjhiJSbwlTEhTaxAfnY0rPB+1pHnJInebeHbL8iuWQRuch6izQqv8UsMw7K8ELXrM/6kPhQNuXMGU7UWvgyvGEiPC48Qo1JTSpndCKmHHzGqjwDRynnqEoaesUQ75OxQQP2kP8QfYESD/VcFDaEF+ZownFPpszsTwR8n9NckvAP92ZgkMFvPK0NH4jR4lUfa5otFQT1pP2xGMbCu/Ufv4z8jIXFWX 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: AM5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 27f86d07-8c4c-42da-e325-08d8bd587ed2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 44Yrdx0MffSl0WJbyl21rVT7TENlDhmUg1FFzC8sWrMWfbkynbhI2GzkCo1e/9J1FxpyBQ5T5ZWSDFS8LNs4EMe55hdfUeNs89wDOiowr9aMSV81240+nj0+lVSKDIWRrYMOVj9dWRM67+67c9+s5MIppaspjcZJ+XjefPSFCq+K+elGd9zHQHPKdbX1b92Votdqftn9gtw/gugCBzIfGRjvem4Z+vT+wHwvnJMYmum7jpwCEDF1Lz4QHKLZoicDNKbahg06/fFhZlbf5V35i0T3vkpUWvSU/bdgwOOSgMfF4vH8CbbAN0Ezs0OczZ6+EPTEBQx4NZpddJoMYqBvlvo3/g6CxHTtH5gnFM9jc/m9KfJeC5hkIC6r2VgPB4+K+LYuHpmCZlRowjSOSgI15gId5zBgfoAe2vr4300hWJY3iv/jyQj6Ob5XRcynDEjKtgRGjf1peFrD3wyvzr6ZiWUaIPrGfQIDr+parPJu4ojbftt1RtvNpzOHXm15+Pma 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)(39860400002)(396003)(376002)(346002)(46966006)(83380400001)(69590400011)(2616005)(86362001)(82310400003)(16526019)(356005)(81166007)(5660300002)(186003)(36756003)(956004)(8936002)(47076005)(6916009)(44832011)(478600001)(6666004)(6486002)(8676002)(2906002)(82740400003)(336012)(316002)(70586007)(26005)(6506007)(6512007)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 15:32:05.0266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2fcba76-1e10-4f5b-9a11-08d8bd588a78 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: AM5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5319 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
IFUNC resolvers may depend on tunables and cpu feature setup so move static pie self relocation after those. It is hard to guarantee that the ealy startup code does not rely on relocations so this is a bit fragile. It would be more robust to handle RELATIVE relocs early and only IRELATIVE relocs later, but the current relocation processing code cannot do that. The early startup code up to relocation processing includes _dl_aux_init (auxvec); __libc_init_secure (); __tunables_init (__environ); ARCH_INIT_CPU_FEATURES (); _dl_relocate_static_pie (); These are simple enough that RELATIVE relocs can be avoided. The following steps include ARCH_SETUP_IREL (); ARCH_SETUP_TLS (); ARCH_APPLY_IREL (); On some targets IRELATIVE processing relies on TLS setup on others TLS setup relies on IRELATIVE relocs, so the right position for _dl_relocate_static_pie is target dependent. For now move self relocation as early as possible on targets that support static PIE. Fixes bug 27072. --- csu/libc-start.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Comments
On 20/01/2021 12:31, Szabolcs Nagy via Libc-alpha wrote: > IFUNC resolvers may depend on tunables and cpu feature setup so > move static pie self relocation after those. > > It is hard to guarantee that the ealy startup code does not rely > on relocations so this is a bit fragile. It would be more robust > to handle RELATIVE relocs early and only IRELATIVE relocs later, > but the current relocation processing code cannot do that. As a side note, how hard would that be? I really think we should aim to make the bootstrap less fragile and it would also make porting static-pie to other architecture easier. > > The early startup code up to relocation processing includes > > _dl_aux_init (auxvec); > __libc_init_secure (); > __tunables_init (__environ); > ARCH_INIT_CPU_FEATURES (); > _dl_relocate_static_pie (); > > These are simple enough that RELATIVE relocs can be avoided. > > The following steps include > > ARCH_SETUP_IREL (); > ARCH_SETUP_TLS (); > ARCH_APPLY_IREL (); > > On some targets IRELATIVE processing relies on TLS setup on > others TLS setup relies on IRELATIVE relocs, so the right > position for _dl_relocate_static_pie is target dependent. > For now move self relocation as early as possible on targets > that support static PIE. > > Fixes bug 27072. LGTM, thanks. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> > --- > csu/libc-start.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/csu/libc-start.c b/csu/libc-start.c > index a2f6e12728..feb0d7ce11 100644 > --- a/csu/libc-start.c > +++ b/csu/libc-start.c > @@ -146,8 +146,6 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), > int result; > > #ifndef SHARED > - _dl_relocate_static_pie (); > - > char **ev = &argv[argc + 1]; > > __environ = ev; > @@ -199,6 +197,11 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), > > ARCH_INIT_CPU_FEATURES (); > > + /* Do static pie self relocation after tunables and cpu features > + are setup for ifunc resolvers. Before this point relocations > + must be avoided. */ > + _dl_relocate_static_pie (); > + > /* Perform IREL{,A} relocations. */ > ARCH_SETUP_IREL (); > > Ok.
The 01/21/2021 11:07, Adhemerval Zanella wrote: > > > On 20/01/2021 12:31, Szabolcs Nagy via Libc-alpha wrote: > > IFUNC resolvers may depend on tunables and cpu feature setup so > > move static pie self relocation after those. > > > > It is hard to guarantee that the ealy startup code does not rely > > on relocations so this is a bit fragile. It would be more robust > > to handle RELATIVE relocs early and only IRELATIVE relocs later, > > but the current relocation processing code cannot do that. > > As a side note, how hard would that be? I really think we should aim > to make the bootstrap less fragile and it would also make porting > static-pie to other architecture easier. the IRELATIVE relocs are in the DT_JMPREL area, while RELATIVE relocs are outside of it. (this split is to allow simpler lazy binding, i don't know how strictly this is enforced in elf, but since ifunc is a gnu extension we can just say that this is abi.) so i think you only have to change/copy elf/dynamic-link.h and have a ELF_DYNAMIC_RELOCATE variant that processes the two sets of relocations separately. if you don't want to rely on DT_JMPREL then i think you have to change elf/do-rel.h as well to have a elf_dynamic_do_Rel variant that does IRELATIVE separately. either case changing these looked more scary to me than the current patches: likely we have to copy complex logic with slight modification and there are a lot of things going on there. (but that was before i learnt about the i386 hidden issue and hidden weak refs and tunables_strdup.) > > > > The early startup code up to relocation processing includes > > > > _dl_aux_init (auxvec); > > __libc_init_secure (); > > __tunables_init (__environ); > > ARCH_INIT_CPU_FEATURES (); > > _dl_relocate_static_pie (); > > > > These are simple enough that RELATIVE relocs can be avoided. > > > > The following steps include > > > > ARCH_SETUP_IREL (); > > ARCH_SETUP_TLS (); > > ARCH_APPLY_IREL (); > > > > On some targets IRELATIVE processing relies on TLS setup on > > others TLS setup relies on IRELATIVE relocs, so the right > > position for _dl_relocate_static_pie is target dependent. > > For now move self relocation as early as possible on targets > > that support static PIE. > > > > Fixes bug 27072. > > LGTM, thanks. > > Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> thanks.
diff --git a/csu/libc-start.c b/csu/libc-start.c index a2f6e12728..feb0d7ce11 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -146,8 +146,6 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), int result; #ifndef SHARED - _dl_relocate_static_pie (); - char **ev = &argv[argc + 1]; __environ = ev; @@ -199,6 +197,11 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), ARCH_INIT_CPU_FEATURES (); + /* Do static pie self relocation after tunables and cpu features + are setup for ifunc resolvers. Before this point relocations + must be avoided. */ + _dl_relocate_static_pie (); + /* Perform IREL{,A} relocations. */ ARCH_SETUP_IREL ();