From patchwork Tue Jan 12 17:21:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41697 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 353243896C06; Tue, 12 Jan 2021 17:22:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 353243896C06 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610472120; bh=0rgsnD521ICO1RxuXKoRrhHJ5Ts3KFs/IK6UE1EozgY=; 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=vbVIBSu/j0D9H/mK9DYnSzcl3WOoBohsEYirS0xA8fk4KZ6zz1NqMxkU/BwdvSXCl j4fqK/9D42DD4ZECHSoj63nsYCf5TbRnckZg+X7PzSy2Dh09xZMZ179y+tKuTa4hY8 u3iIsPxxU+m+JKwjGuCZRhPKvfbR6wBVrblZJU7k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2086.outbound.protection.outlook.com [40.107.21.86]) by sourceware.org (Postfix) with ESMTPS id 86D483894C33 for ; Tue, 12 Jan 2021 17:21:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 86D483894C33 Received: from DB6PR0301CA0057.eurprd03.prod.outlook.com (2603:10a6:4:54::25) by AM8PR08MB6340.eurprd08.prod.outlook.com (2603:10a6:20b:368::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 17:21:55 +0000 Received: from DB5EUR03FT003.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::4f) by DB6PR0301CA0057.outlook.office365.com (2603:10a6:4:54::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Tue, 12 Jan 2021 17:21:55 +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 DB5EUR03FT003.mail.protection.outlook.com (10.152.20.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 17:21:55 +0000 Received: ("Tessian outbound af289585f0f4:v71"); Tue, 12 Jan 2021 17:21:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: acc479350b5bbc9c X-CR-MTA-TID: 64aa7808 Received: from 7fdb225fd77d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 59DBADA4-EFD8-4151-AA5C-430F2911AE45.1; Tue, 12 Jan 2021 17:21:49 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7fdb225fd77d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Jan 2021 17:21:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NWvCtJpQ+UqyUM96AlxUEGUX++LqBX8aCZKuh8choiAc1Ze/EI7vhNjrDJCtisP/evPopZnYm9PKI5zCU5gjAxzn7XSuRc+hayYwJaFQXZhZzk31El/wH4NXc2AvBt63kt6KsIPgI0sXL25XCE1FTooAhgb39bWYjSkkgDP+VCV3TeBFoeYXbcZG1q8Uweriy6YP1Yklb0N59kr69vwIHd8lA216sw2SMk7MPpz8mNYVwQgPN3EdtlSSnFcXcyj1t0gFD4FW6He33qnObWoTT+8/4uGYYS4DeovAYf6NvP4yQMmeCHHI9hnMkGPHYuVbv4LLy0gUeyyUyq26vpn96A== 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=0rgsnD521ICO1RxuXKoRrhHJ5Ts3KFs/IK6UE1EozgY=; b=m9lInySF+78WvLMRmhZlB4NmxeKMnjh75g9enIOj0qhQgh5JjkJgjckI1SY1tzXVaD/OVQVaYtYSir2aQ19KfK1W1PKNlmYGYpkb6cHDQngMqqFENvRHp8njNAQJO2v8Qa/MwvaOuR6dpiUp3M5i7nCcmVPqlDcMIOLyeZz+pn0oXdPUprvJ2oaLwpRdD0JwNoU4Qh0oCnqrVzZ0SEWRAh66L2o3B3WZdmqB3qqdvWToHCT6OurEBihXhe50NK28pNqBeG8kGNlzDkG9ClLburvDKUGEZCzL5RRaSxBUc8Nk4LP9I23phyDpLSAmTLAjgSWlsGXWyuWNn3e3OpVHkQ== 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 PR3PR08MB5753.eurprd08.prod.outlook.com (2603:10a6:102:87::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 17:21:48 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f%6]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 17:21:48 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v3 1/5] configure: Require PI_STATIC_AND_HIDDEN for static pie Date: Tue, 12 Jan 2021 17:21:42 +0000 Message-Id: <5a446e7a422bc4edd49384884106383485d05c08.1610471272.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.50] X-ClientProxiedBy: LO4P123CA0323.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:197::22) 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.50) by LO4P123CA0323.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:197::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 17:21:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 97594e96-7a10-4152-66c2-08d8b71e8f93 X-MS-TrafficTypeDiagnostic: PR3PR08MB5753:|AM8PR08MB6340: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: h2OaUqozJgGlTjMNYB1keZK3B/aYyXLz2PT7XUORah0CdAmROxD9l5cBEKdFX7rNbgNC7eApDAoK9DRrcMWbUGHMKg5o3iGFbS2DBTggbc+huVHYkuMPVz94BrndPzzB2orofIDnn1sqitGenyV4jV3xVBONQYmPCU9DbauxNh1E0Ni3aQ+/16K4eYiaSIsSeQ68Eves34lYs/RuYChHp8LdBKM3WDomzbQK6vENHUiUjeGFinpJVyma+YkBtf8Kr1dxBKv5/jdmOhpTF39xLbwGRWFWbbcZOAe4MDxbIFt5d/RA2p3E3XS48RyJilVM832kIGS8Bp1dDgVZfrh0RDSR3K4NibgBY91K+MwSWt8LMWDy9IeGRWEX9cnXHBLD+yce60DIDeZ5kpce6eVRCOZsLH0OWezZv23T/vMzpYVHuasg/6EcIQOtBFlF3kGtPPZnJqJlFcmst7m2AzK2Mw== 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)(376002)(136003)(39850400004)(346002)(366004)(396003)(16526019)(26005)(6916009)(86362001)(6506007)(956004)(36756003)(83380400001)(69590400011)(478600001)(2906002)(8936002)(186003)(66476007)(6512007)(2616005)(6486002)(316002)(5660300002)(66946007)(44832011)(6666004)(66556008)(52116002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2ssJVcJeLFJwyu72pD+8paJ1IG6bobgfJNB7nCbHj3Abh9Us9cGMg/ythIaZOQT42gJI/KJMGQo4zz4KigQ5LPI2yVHxZhSKZfukAPHypdnaZhfDyMIvByZc5II6lDmSaS/0k4ZsTQ8ItzWrptDpEZ5ki8Bvt1kGq1OGTIjvPTsoVd6BB52nOwPK/oALkOwCooiktbLrKfQPJ6KhoBp82iZWu5rsRzGE3wSGMpt0VhSInt+XiAoAHt9XuxjmDNcS9orJdGW3yZTe0tdR1r+jfD8tZZ5PgaKQAHvNuNCu83oI32BCJEuobKXGtEcBwPre9K9PuaG5+14QS1AS339SPAx5xdN5PVJcwEV+74gc4y+YOa2i08nzqGiVgiU1yziluSE+2w+/7bA2yYC73H72bVTM+77IqqHsj/FxmL0pjJfSLhKN/VmMu5MyYyTIx0pEaZdd0DninplvXvWC9q2x8UYX9UWmcPGQUAVY7wSz3YNrAATPLUXHyxMjBYkRsEb1C2/0yUojlY0fkLtXX4GKHEhWl4dElWXQSIv1hBWipttbL9tnQQUnnyxHJyfLsMu0lOGbuulH9CEa9GBpl02ENeLiqIcoX7ZO8RrS5rqsV0+N4c6N/DQtPx/ohxQPqR7W1UUniWPe7T5ty/Vx1V3/t/RiPXi0xs9CmApjs2473iis71fZ9nXa7DaU0YWNEzo2s3iHoWr6fj+45+ZA69uuUdcnSBhMEPvI9ZGwUvui8QcGemKESpVMa3TFF402nQX3exqn3Ma6T+NCK8y8ey2D1leDejirPYcyYwgQ2QUH7j99bPhB28iNsfQVoMxyoHY0UtbyZq1sdz6mABq/14++DQzqLbVsHn/4d1juSK5lE960giA9xchD/4OXGsAyhyDXZpeW8qqX645hbHTqA2aS2KDwHIZEBv8IxaAe4uglbabg1uXOoNS3V1p7W5STvbVz2kXlZl6hVnb1nhNT+NMQu81/1IQW4VSNKFRT8l77UhrJaNjI4sYvlbk/wmTlBEBI X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5753 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: DB5EUR03FT003.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ad406d9b-2beb-492a-6ba6-08d8b71e8b69 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: af9PigUYPPtwWrpezBfXBmnjpbK1irKkfILYsnmc1s6AdbVY8byPahSaOGqkZuDMb5LPPbOK1x5zTb511kAO9eahvzv8rU/rASZrqQE5FtbTpnXGNOGPil0D0z9sOOJXQDZH1/G4ZOIrn6T1LNt5U5WomePu5mtsXQsoGgjQpjBrSSFFt91lplKjZWjx9Id2A1oGWWbQjMepoggeATbY2AIgEs7iqm8LDJkD6pYgJ5/W6KJgtghSKlITWs8svDlOQPp8nD51ceudRcyg0skF6ayMppg8h7Z5vrTIfzQH8GzhZZEnfFSRrgjhGK9UuFNVfy7mA8KgqGAPKYTzyP4/FL5RRa3uuChclgnvY1jDHmzEN0K83IKbvPK7CfMIvi59108S5V5u991B9edxtbuT1qjVgt2zNTEMogDvxe+rQ5y0Opkm0NljG0/sTaTIfsaS0SebcWNshO2wl/6G0R1a9WG9q52m7jsm/izCZryywm1RbgythaKu/attVzj4o0W2BmVgNm1NP/FkB84ar9v12g== 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)(376002)(396003)(39850400004)(136003)(346002)(46966006)(47076005)(83380400001)(6666004)(86362001)(2616005)(478600001)(82310400003)(44832011)(336012)(16526019)(70586007)(316002)(70206006)(69590400011)(34020700004)(6916009)(6486002)(82740400003)(186003)(2906002)(36756003)(5660300002)(956004)(6512007)(8936002)(356005)(6506007)(81166007)(8676002)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2021 17:21:55.8559 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97594e96-7a10-4152-66c2-08d8b71e8f93 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: DB5EUR03FT003.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6340 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The glibc static pie self relocation code relies on that local symbols can be accessed without dynamic relocations in position independent code. Reviewed-by: Adhemerval Zanella --- configure | 14 ++++++++++++++ configure.ac | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/configure b/configure index 49f7b32b52..81fd116d87 100755 --- a/configure +++ b/configure @@ -6818,6 +6818,20 @@ if test "$static_pie" = yes; then if test "$libc_cv_no_dynamic_linker" != yes; then as_fn_error $? "linker support for --no-dynamic-linker needed" "$LINENO" 5 fi + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef PI_STATIC_AND_HIDDEN +# error static pie depends on PI_STATIC_AND_HIDDEN +#endif +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + as_fn_error $? "the target does not support static pie" "$LINENO" 5 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + # Default to PIE. libc_cv_pie_default=yes $as_echo "#define ENABLE_STATIC_PIE 1" >>confdefs.h diff --git a/configure.ac b/configure.ac index 341d4eeac2..8b7c99001d 100644 --- a/configure.ac +++ b/configure.ac @@ -1835,6 +1835,11 @@ if test "$static_pie" = yes; then if test "$libc_cv_no_dynamic_linker" != yes; then AC_MSG_ERROR([linker support for --no-dynamic-linker needed]) fi + + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef PI_STATIC_AND_HIDDEN +# error static pie depends on PI_STATIC_AND_HIDDEN +#endif]])], , AC_MSG_ERROR([the target does not support static pie])) + # Default to PIE. libc_cv_pie_default=yes AC_DEFINE(ENABLE_STATIC_PIE) From patchwork Tue Jan 12 17:22:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41698 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 CE60E3894C36; Tue, 12 Jan 2021 17:22:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE60E3894C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610472139; bh=AJjRKVVaPVbqR+IT22N7OI0Zk+9N+Gh1NCsQ184p9CE=; 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=IbnW8WOkKGpv6IYejXkz5lmjLCtFMK+U5+aWYfhiQHJn3MO3TEUcjh1PohXq9JB67 bptpsMrujRDu9ujLphWBhVdj111ugAn+D5cGPml0e9HW969+YiI1ZPb1hP3v6ZXfAM rtdUUBGnio9SR5wW3w8lAJM9yS1+/OMBXkqBd6kY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140052.outbound.protection.outlook.com [40.107.14.52]) by sourceware.org (Postfix) with ESMTPS id 316993894C33 for ; Tue, 12 Jan 2021 17:22:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 316993894C33 Received: from AM5PR0402CA0019.eurprd04.prod.outlook.com (2603:10a6:203:90::29) by VI1PR08MB2928.eurprd08.prod.outlook.com (2603:10a6:802:1e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.11; Tue, 12 Jan 2021 17:22:14 +0000 Received: from AM5EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:90:cafe::fe) by AM5PR0402CA0019.outlook.office365.com (2603:10a6:203:90::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Tue, 12 Jan 2021 17:22:13 +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 AM5EUR03FT061.mail.protection.outlook.com (10.152.16.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 17:22:13 +0000 Received: ("Tessian outbound 8418c949a3fa:v71"); Tue, 12 Jan 2021 17:22:13 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cb72f6af9963b3e3 X-CR-MTA-TID: 64aa7808 Received: from d54ed4daa39c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DFF1EFC0-6B67-44B0-A42D-0F95A1E8A811.1; Tue, 12 Jan 2021 17:22:07 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d54ed4daa39c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Jan 2021 17:22:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TsJjSTqr0KyfMa4r5CB9ZAa5N/hk62Nx9PsGYFgfL9BaiyWxyyOlYrjpxO+9pwDaA+5lqGTbBpODz/v90xy+VjCBOIeRy22iU4kyfmQZfByuDRBG89Nsecua7tPF1XHUHymeJfQ2n8FsHE3bweN6AS8V5nTzl/cCAL59BVovbIgGcd9VSmzpz/3SVsKbNSG1i6AiAxVzFfW97NuDCwmAlGJLfmYcB9h8Nv81biepNzPjxSBCiO5tZd6S12M0QXwDDm2MsMe4yo/PBa1t4KhxbIBS/kDQh3/kOJloQORVxNQJcsaCSGgRa5zeXUanGMS4HP+OBP408LEH4pcD4tx6CQ== 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=AJjRKVVaPVbqR+IT22N7OI0Zk+9N+Gh1NCsQ184p9CE=; b=BA8v7ZACWK7BNhd77zpi3g5sRXHGMZlS6O7M6h9Q3Az9GP0/RXqpco01eVG55auoQ0m2iC5S7UsE/xToHVrPzwY8HECbXt4Z9A8FaCrh7Dqkr28udhYHJlnNwI1U88pyeKRcdUCiLA1b56aA6fQKJOb/bPkDXQ3cUfXj5Ff1xWPZKO4gcMmuf2WdXZ0QU+HQcuFDxn49LTpyB7RYf/h6p1W0vPtoBVVvQjWlYl5ZRFC+5pSIE2jwsoLgOyMN56XAnGE2FPPAqemD3kMA4elfFoa2P0ugK/QH0dHGTPSp7CFx+XpDU5atiBd8UzRy9ICH9X7UMBxLAOLwVpxawoQf1w== 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 PR3PR08MB5753.eurprd08.prod.outlook.com (2603:10a6:102:87::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 17:22:07 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f%6]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 17:22:06 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v3 2/5] Make libc symbols hidden in static PIE Date: Tue, 12 Jan 2021 17:22:00 +0000 Message-Id: <27498bbc768372541e4379794656ac2778d33035.1610471272.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.50] X-ClientProxiedBy: LO2P265CA0416.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a0::20) 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.50) by LO2P265CA0416.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Tue, 12 Jan 2021 17:22:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f588d0e7-bd76-43f6-76dc-08d8b71e9a1a X-MS-TrafficTypeDiagnostic: PR3PR08MB5753:|VI1PR08MB2928: X-Microsoft-Antispam-PRVS: 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: Ey9e5Eyd58gFFGj50iNTmO0hnsF0DGiJPf/5cUF2rSZyhiHgAjmSAx9CiqsHnKuey4D6SoiPU+W8hTW8oo5MJJ11lMxfEEqbIaa+YKQKu2koYIOGXAkEqFh0RqCrZG4/qAKoBMfV34HebGC79j9WsWytiFrSH+5SnD8GDE+xE2v++Nb9HD2wcB1wDXLbMqRcKBiRslr0QfDhLHstOBy5PHyW6XT0hWdLCMoB+8U6zY+GL07IFc/kVKH0gdZApo498EKEE449cTthTOdPHY9A/HjDi6+tgQlAIMl6hV4ATsgU4lVqjecSurjA0sf2kW3ewnUuB7jiaDXLjdskhOtgS04ySiuxw6UqxUQBXujkzqgCfrJ8XyQnzaOhK/HPt5Sn436R7mbUn7cVtHw9PQqjjyMt92OFHjjj+Q0n29XWOobWHLJV7puJhdbek5sRoWKH/yMFqGn4MfVHz4vLP2R/5g== 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)(376002)(136003)(39850400004)(346002)(366004)(396003)(16526019)(26005)(6916009)(86362001)(6506007)(956004)(36756003)(83380400001)(69590400011)(478600001)(2906002)(8936002)(186003)(66476007)(6512007)(2616005)(6486002)(316002)(5660300002)(66946007)(44832011)(6666004)(66556008)(52116002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: GZYrDpppZnrn9FIcJIHYL9h5NVL4AXFZgy1viu+1S7/FSbT7y1B/FhdVK7nbSh3BD2Y7FMIxhG/apjIPyrCPM+aRcXjSmEUkBkB+sVt1d+G/4lEuCgAHG4gYAZSJ3gvIsJbwWGkmadmJEXcZg3/+rsEOxu1rGeRBN7UHE8E6hXKzf6eYex7YZdyUdOElhtlliKae4JUMqEQo6a6IDv/W+s3YPUFtVZFy357C7JIWSzImqbvfZkqoDMFgY2BjHKhaKUAIL2YRUN8mDedA67oAawgaDh3PJi21SFuxbRLtwGUNcnsWq/kfq3L4XXyOfPJa7L+9l4FjF9OT7rbCeB+M2GSmOLHTp0a9RAuajKYSDH+9H5d23Rc3rT6kLj/b1tz/fJsHZofX0mI09f0jj8PH+Jzj1RtygW/zkwXMIXhX5Noev+lgBEYz13EyoMiM5PqeZO0JwhIQi8Nd8qlkqOb1zFrI1jmu2rwOqSnSzkujjxGwbTy+KK5AjYM3I29RbvPnDn+ZXQgjdlBdzczYfIfdeS+FXI4U26aC6n8cdLwWzJcKWzOW+ehE1EBkdoh4ceVMHwBlDBYPFe/hDWeQe8YAFhvKuvogWhlA0NRYoEnwn6z3Ae8OKNRStYKslYRQwFM3GdTZq0JlqutMkK2B4UiSJsgNYMdFTpnAkelEYUUFmwRCbD0UgiBtDqrANQjc2XkgWLHSzai/pEE+uKTqMA7A16SDrmFrkZA0pC4d5bAG4WzlArDqwjfTnVHdAqIEYDYlPo7ZLTtx5FPf5JVb5atRrWa/uAUB5aDEZ1+NKXv1aVMtyjbtF1oNrsdiPlWqb+3jCaAqU7AKufDa+5JT4SbPc49FRjs15iYsGBZ0o3l+uHAbvCHBXr9unNtcp1AOA9TSh1Hf1aheQ+QX/nLvvaHJT+sx2D/b6ILYOvllzs81w5320o4Kj2SJyZ/ykaKGJVX7KcwA7adcj0o+sMncTuWw63fOQtiTf91rn8Zuo9aJf63N+SKUbNqw4ybaNyEJTLeb X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5753 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: AM5EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 013d2d61-dd20-4997-4250-08d8b71e9632 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PtikCXp0lKZW9yF8em+8FGOFpHsL/2n27oKWLt8GPyT4Ws3YlmJMxuBRauxPk0YKMX5+coTe1hVGWdQKS0fqLczYUp6ZVPn2eP9vy+wdMcGIRX0WQfny+x4cpICAb2xBz5KHv1Z/cjv7L1NbEdbKNQKbSVSzWXUUq6mkWUtpzWn7iRFp5t3wQFKDrZeH5VR8mF7fqOGswTr7p3R8G1vBmoP1IVFXImWjytJhiBdsVZ9LQ1UjCQ1YIAAVkQFb/4Dlr5Pj4y/kBXTe2Aasr37U92c81pXto8CQtNQZ20SItKHVdBab6HJz0LU92mdmKBAHZBNBIGive5vI8u7m0MvcJOAqYug7nThfev2g+AJoPmD2fhcGSqfkaNxwPVyRFipIWBW0wFWxYX+vbj5yG42xow8v8GTqrUC2BWqybO+O/MsfJxOhetj11AWovyxFhmVQFx2gQf6pWqOMZNU3LIwRbCLt/c3OzieNnO/Tn2LR6gFZQScLEhYDIZCruIFGuOksOeDiA44IzJxUlOD2KTeUIg== 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)(396003)(376002)(136003)(39850400004)(346002)(46966006)(83380400001)(81166007)(356005)(6666004)(70586007)(82310400003)(69590400011)(86362001)(34020700004)(82740400003)(70206006)(316002)(6486002)(6512007)(478600001)(2616005)(6506007)(8936002)(336012)(956004)(5660300002)(186003)(2906002)(8676002)(44832011)(26005)(6916009)(16526019)(47076005)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2021 17:22:13.4553 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f588d0e7-bd76-43f6-76dc-08d8b71e9a1a 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: AM5EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2928 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Hidden matters with static PIE: extern symbol access in position independent code usually involves GOT indirections which needs RELATIVE relocs in a static linked PIE. Using So hidden avoids indirections and RELATIVE relocs on targets that can access symbols pc-relative. The check should use IS_IN_LIB instead of IS_IN(libc) since all static libraries can use hidden visibility to avoid indirections, however the test system links objects from libcrypt.a into dynamic linked test binaries so hidden does not work there. 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. From -static-pie linked 'int main(){}' this shaves off 73 relative relocs on aarch64 and reduces code size too. --- include/libc-symbols.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/libc-symbols.h b/include/libc-symbols.h index ea126ae70c..93e63ee889 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -434,13 +434,17 @@ 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 && 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"))) From patchwork Tue Jan 12 17:22:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41699 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 D1159389683C; Tue, 12 Jan 2021 17:22:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1159389683C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610472162; bh=KFLRP/UR1T3V1ePdWgOTCGZuAdS28qOo5XdFgSPrCH0=; 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=iKX3ltBBF59gS520+Us2cP5hRCtRcS4WVcK0h36epoMuUsdaYbbjjDqpsYJvtFqZJ uVnfQMUJtT4hUkEFl2kcw33eVYC7hCPAtjmIYQJs4WkwPPCmZwJP4eDgHUn+I2RMPt nJK+8hobrfI1TGOwkz4xwnCY2CbiFgR/q+iOG0Qs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40086.outbound.protection.outlook.com [40.107.4.86]) by sourceware.org (Postfix) with ESMTPS id D88EA3894C33 for ; Tue, 12 Jan 2021 17:22:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D88EA3894C33 Received: from DB6PR1001CA0019.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:b7::29) by AM6PR08MB5061.eurprd08.prod.outlook.com (2603:10a6:20b:d6::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 17:22:37 +0000 Received: from DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b7:cafe::a) by DB6PR1001CA0019.outlook.office365.com (2603:10a6:4:b7::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Tue, 12 Jan 2021 17:22:37 +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 DB5EUR03FT053.mail.protection.outlook.com (10.152.21.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 17:22:36 +0000 Received: ("Tessian outbound af289585f0f4:v71"); Tue, 12 Jan 2021 17:22:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 242385fbd773d8c1 X-CR-MTA-TID: 64aa7808 Received: from 9ca4217b47f6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3544509E-4860-4569-B965-CBF2E19A0D59.1; Tue, 12 Jan 2021 17:22:31 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9ca4217b47f6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Jan 2021 17:22:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G5dVU7A83WnjMXVtCazk7DE27S8Ev3qK3XXjAthnB8WfCCv4OTfpK+qRWEg3W23rJtgte40ote98g37unQL2PTlyIppLeP1NfAKtHK3TiM7tW/03efpf0u8tPkhqfHx2qES4fMU+1rr9L8vtJbQU50qZKaJx2xRYuCuz2FoOZ1Zsi+Afns92Zl/V6P8jfT72me7axlr+53he/vqrrGNA84g3O0un4iOglXaQM34n7Cst1PQ7js18PfVLanJI9xpKjO13Nn5UnSGYzrrzZgyLw1QinamzR5bOwTDkdUI/7LaCuUFj89HVKwaLpQRTHaA9xZrUB0rf1E7TqYRssYa7GA== 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=KFLRP/UR1T3V1ePdWgOTCGZuAdS28qOo5XdFgSPrCH0=; b=fg47UpCKpMoG6AM+NyiCeQ5Heeno/JZpXBLKcoJDi4LAXnyz6Eq5sxhZBAE9N7Y4crDwUIMdXTmrdZa+dkgj0Obg2TY9BP/8tVr23tsxGjq4MRN8/DNKf1tPGIjvwFL1DIbq16GzZdLLST5QRUJ3rv/hemrkSuG5kysgRwZmhJOCmGuOFA4mzNzA6bs5T9KO8ESWe1bPkDgFK24spohLXve2IBaU3N8UccfLCibb8gh9nvN+P48w90B1FJSMXkPrShzrS/1rez8fORTVB46I/bhnbj4W/v9+0qnzusCFmpWwkLmRl0sji6A530Mx+9nvYb+ZneecrHMfsULBdbGMUw== 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 PR3PR08MB5753.eurprd08.prod.outlook.com (2603:10a6:102:87::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 17:22:30 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f%6]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 17:22:30 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v3 3/5] elf: Make the tunable struct definition internal only Date: Tue, 12 Jan 2021 17:22:18 +0000 Message-Id: <7b64c9aa6cd771ec569c51d50395147e4b22acc5.1610471272.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.50] X-ClientProxiedBy: SA9PR11CA0007.namprd11.prod.outlook.com (2603:10b6:806:6e::12) 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.50) by SA9PR11CA0007.namprd11.prod.outlook.com (2603:10b6:806:6e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20 via Frontend Transport; Tue, 12 Jan 2021 17:22:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a0e12876-21f8-46df-b8f3-08d8b71ea813 X-MS-TrafficTypeDiagnostic: PR3PR08MB5753:|AM6PR08MB5061: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: sCOvdsPGtRowJp4Lg0u44EvgRuhWzsc6LzxEpzN38r/8xyBv9Et8VZXYZF4apmngXRqZROll3zn/YWHxQs+i8y5E9TseOMdRkwygQ0oa7lS4FElVac2DyRGw7SlL0rYPcPqL+jjX1Qysvn6pc5glDkK0cTjt4oi8ytS0vg3/DU7RHSho3eGuT73ECikX/6E6Mw14XrOi8eL6+CzqJOwG3EFGEysvmb8HGG53GuW8yxheSHjSCFEjopjpL/hIXRHPYRoRULYf6QkVYHguh0iL1lYiJxUbm6E1HXOnhr6320RAtz8qjOZuZAlnVkbURXEei6iyuqdi0FNw+wEsmQ5cON84qHbf2Ft/f42tRCH41VasyI/teFjzGYNWbleVqlsKTeq7J1rb25da61vp5iZHZiPY5qRgR9fZ+E+pdKmzcR01DIfO2WHImIbXsQ+0TmcRy1jRaJjGPqStAlrG/3ZX0mSASn2loYpPs5066vKOQEFwmbWCFG7QMoDX4RdmoM5EagvvXFmZf1VsDwyCaOzUjjvTb6A4aa8P6SqFpj7IErI= 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)(376002)(136003)(39850400004)(346002)(366004)(396003)(16526019)(26005)(6916009)(86362001)(6506007)(956004)(36756003)(83380400001)(69590400011)(478600001)(2906002)(8936002)(186003)(66476007)(6512007)(2616005)(6486002)(316002)(5660300002)(66946007)(44832011)(6666004)(66556008)(52116002)(8676002)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: QPd6KySVr0SYynQrLVE1eyhQdf2Brfd588+B0gtsNdMzaTv9jgkm2RsSWDmr46W1Stnvt8IXToeUbJa/LBBBgOi074sl1JO/SamgGne93E5LrUHw0QBT5nGwYmBwRFBQVFKifutyVLL9b8LLa2alvB9LqEiw3m+JZcNUuSMsE49CWESKFYtfbnAbLvmi2XEyht4Fr3Qm1nuZ0CN4/riobzJV0tRnp91Kn4IPOTkhQArraJMnhK2gaUyWhqqfZ1JqiePN2gU9SqPgfWaKTckxWF2JLgxHoRV3NoGL8fGlHoAopKvKZ29VhNzxYgjRtGsAdsijllyCBi1q06TkNtc7nDig6La8+KEsbiYEzX4IJAhJ+7lHqyAcMUk3kuygQviQVqmUIc9ByX3k2dP0eyZKlb1LGZr2vHom2ULcSoSDQ7tcipuifxJHkoGUuF83WzhhNo1vk6UlY8x0+cbnQYnzNwh6MRsSCd4lEfgYrwA75q7NEkOhO+ORGKv5cpG1qFfN4y1nhIpOZt+7/l3JVPdzXqEfnUKBlWaa2dw5xPkjzo8/N+VfPkr+m+vRlxpkQSfTvx1OI/AtFn0fcWJxG7Im/GwPJVD5Gnsks7Sz9YFe0l5vY66PuGr6SATijbo3eww7ekndAsqMWvYBsumGQB6IsMaM5gx8MblSwn2VBPlOYxiG0xKUVGbMyoVP5CWArkur0qOKZSA7HGY515arrrHzL4fOoErk+He5rqgQRO/4LdzPQHfOCuNMJlr4ZXMOAO6FSNmowKkEINAPHSYsbh/GxoFMZtUEktkd25WPcYJGBp5D4PguSJbgyjqxyLXoq5MLfQSsb0SvNXG7apAa+vS2rEFUq71XSeIdFsYVbiA7YYCkqH4jFH68FFctEbP0u8PlraITGfRofBnxVEIfhjNQYImWt3VX2r39X2+j6zdQoYE8MByo9HgKOVfhMUNYqWRLjIG9ACmvfIj8R3hd/qjUgCsaM4H6AHnZiSBJvdq0PsaP8E5AEe8VGUSqYiSDvSoK X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5753 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: DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8dece590-7aa4-4552-797e-08d8b71ea41c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QBSFwADcCLxXpD5rrf2gFeuHnhTo6olG4LruUfD9sW9a5gYgpJmAJGaF8KU3AKiiyEvhUCcuDqu9DH8TS+iG14BMDpBuO635s1aXkw93xulxe0XeiYo8JxAxYrBhTNLP80FE4T2G3JQ5S3+1g5xeoIhfLcJXucnMD6hbJcJm8u/6kAWRTu3QHwh5sureyVCyHlh5uBQvIzONZoGUPs/9RfO8WbtfOftKS6Xff+6v1mf6lLDGoTOxMmRQGAprMO/CIeY6hCwe1fCzka24h/Zact19MIkWp3mnGHq9qcrKPqIzf57/93A2SiiYmManEkIN84XHtmt2Va0OVLp3ly9GWM7nEbkwduiyTgegQ+C3QYcERZqzL2gN+rrsrDwg6nEePrNBBP58wCdc3vgpvjIAQqRlVbHfU2FPX7RTMdSAO9AtScTSF96oBJaubZLbM6uFHOwqx7zaDxNfqk5+v2KyFldS6xrRlN4yffCX51khGuk3TNfQJkjw3BALFF3xPnai1YZFIZwA2Sd/nsRG+Zy0aBoxZ0tRh/kf/wD9yz3API203cqUNpNEZ3aXsvqxeSiW9lE2PU0qcSvJqf+Aoxc710Mw4axE92EDczbi7bSarj+WcbbV5a3gLkMX8MD4bxD2 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)(39850400004)(396003)(136003)(376002)(346002)(46966006)(6512007)(86362001)(6506007)(6666004)(316002)(69590400011)(70586007)(83380400001)(186003)(26005)(36756003)(82310400003)(478600001)(2906002)(6916009)(16526019)(8676002)(70206006)(34020700004)(6486002)(44832011)(956004)(2616005)(5660300002)(336012)(82740400003)(47076005)(356005)(81166007)(8936002)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2021 17:22:36.9622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0e12876-21f8-46df-b8f3-08d8b71ea813 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: DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5061 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The representation of the tunables including type information and the tunable list structure are only used in the implementation not in the tunables api that is exposed to usage within glibc. This patch moves the representation related definitions into the existing dl-tunable-types.h and uses that only for implementation. The tunable callback and related types are moved to dl-tunables.h because they are part of the tunables api. This reduces the details exposed in the tunables api so the internals are easier to change. Reviewed-by: Adhemerval Zanella --- elf/dl-tunable-types.h | 42 ++++++++++++++++++++++++++++++---------- elf/dl-tunables.h | 35 ++++++++------------------------- scripts/gen-tunables.awk | 4 +++- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/elf/dl-tunable-types.h b/elf/dl-tunable-types.h index 8f6a383dcc..05d4958e1c 100644 --- a/elf/dl-tunable-types.h +++ b/elf/dl-tunable-types.h @@ -1,4 +1,4 @@ -/* Tunable type information. +/* Internal representation of tunables. Copyright (C) 2016-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -18,8 +18,14 @@ . */ #ifndef _TUNABLE_TYPES_H_ -# define _TUNABLE_TYPES_H_ +#define _TUNABLE_TYPES_H_ + +/* Note: This header is included in the generated dl-tunables-list.h and + only used internally in the tunables implementation in dl-tunables.c. */ + +#include #include +#include typedef enum { @@ -36,14 +42,6 @@ typedef struct int64_t max; } tunable_type_t; -typedef union -{ - int64_t numval; - const char *strval; -} tunable_val_t; - -typedef void (*tunable_callback_t) (tunable_val_t *); - /* Security level for tunables. This decides what to do with individual tunables for AT_SECURE binaries. */ typedef enum @@ -58,5 +56,29 @@ typedef enum TUNABLE_SECLEVEL_NONE = 2, } tunable_seclevel_t; +/* A tunable. */ +struct _tunable +{ + const char *name; /* Internal name of the tunable. */ + tunable_type_t type; /* Data type of the tunable. */ + tunable_val_t val; /* The value. */ + bool initialized; /* Flag to indicate that the tunable is + initialized. */ + tunable_seclevel_t security_level; /* Specify the security level for the + tunable with respect to AT_SECURE + programs. See description of + tunable_seclevel_t to see a + description of the values. + + Note that even if the tunable is + read, it may not get used by the + target module if the value is + considered unsafe. */ + /* Compatibility elements. */ + const char *env_alias; /* The compatibility environment + variable name. */ +}; + +typedef struct _tunable tunable_t; #endif diff --git a/elf/dl-tunables.h b/elf/dl-tunables.h index 518342a300..1773c7e254 100644 --- a/elf/dl-tunables.h +++ b/elf/dl-tunables.h @@ -21,8 +21,6 @@ #ifndef _TUNABLES_H_ #define _TUNABLES_H_ -#include - #if !HAVE_TUNABLES static inline void __always_inline @@ -31,34 +29,17 @@ __tunables_init (char **unused __attribute__ ((unused))) /* This is optimized out if tunables are not enabled. */ } #else - +# include # include -# include "dl-tunable-types.h" +# include -/* A tunable. */ -struct _tunable +typedef union { - const char *name; /* Internal name of the tunable. */ - tunable_type_t type; /* Data type of the tunable. */ - tunable_val_t val; /* The value. */ - bool initialized; /* Flag to indicate that the tunable is - initialized. */ - tunable_seclevel_t security_level; /* Specify the security level for the - tunable with respect to AT_SECURE - programs. See description of - tunable_seclevel_t to see a - description of the values. - - Note that even if the tunable is - read, it may not get used by the - target module if the value is - considered unsafe. */ - /* Compatibility elements. */ - const char *env_alias; /* The compatibility environment - variable name. */ -}; - -typedef struct _tunable tunable_t; + int64_t numval; + const char *strval; +} tunable_val_t; + +typedef void (*tunable_callback_t) (tunable_val_t *); /* Full name for a tunable is top_ns.tunable_ns.id. */ # define TUNABLE_NAME_S(top,ns,id) #top "." #ns "." #id diff --git a/scripts/gen-tunables.awk b/scripts/gen-tunables.awk index 622199061a..cda12ef62e 100644 --- a/scripts/gen-tunables.awk +++ b/scripts/gen-tunables.awk @@ -156,8 +156,10 @@ END { } print "} tunable_id_t;\n" - # Finally, the tunable list. print "\n#ifdef TUNABLES_INTERNAL" + # Internal definitions. + print "# include \"dl-tunable-types.h\"" + # Finally, the tunable list. print "static tunable_t tunable_list[] attribute_relro = {" for (tnm in types) { split (tnm, indices, SUBSEP); From patchwork Tue Jan 12 17:22:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41700 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 670C83896C39; Tue, 12 Jan 2021 17:23:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 670C83896C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610472181; bh=zFJix3JNi7JO3EWdkKyie+NxKGO3KHvB85rTSiy3cLE=; 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=J40WKSGLfLVTHpGlh+VRIjCM+Q++HittKnCM3ZToolGoxLeBdgIxDSOxGD+dBWKIK gLnpKnEag5pXlz5S4yDfAVvvXuDZncMS4wLBZ+BOpSi3CG20+oiA5i3c03DeT1rANY lDFttLErVO0Xj0LXpJTwKNwnUB2zAAWSAL4l2QNc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60043.outbound.protection.outlook.com [40.107.6.43]) by sourceware.org (Postfix) with ESMTPS id 4888F3896C36 for ; Tue, 12 Jan 2021 17:22:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4888F3896C36 Received: from AM5PR0301CA0025.eurprd03.prod.outlook.com (2603:10a6:206:14::38) by AM5PR0801MB1988.eurprd08.prod.outlook.com (2603:10a6:203:48::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Tue, 12 Jan 2021 17:22:56 +0000 Received: from AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:14:cafe::7a) by AM5PR0301CA0025.outlook.office365.com (2603:10a6:206:14::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 17:22:56 +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 AM5EUR03FT041.mail.protection.outlook.com (10.152.17.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 17:22:55 +0000 Received: ("Tessian outbound e989e14f9207:v71"); Tue, 12 Jan 2021 17:22:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c7255f6e068ce82b X-CR-MTA-TID: 64aa7808 Received: from 43a56d4301fd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2BEA5AFA-EE0D-4207-B827-40D3A6A2E29D.1; Tue, 12 Jan 2021 17:22:49 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 43a56d4301fd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Jan 2021 17:22:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mS6L2iHn2Syy/I+IN/lr01/sAvwDjObVXpCUuOvJiHQg0WXf1yCRWglRDv3NcVhr2PrCkvggsJsKcJJH0dsDuLWmq/UOkth6rg9V077wFAxrpP3GUJnVaOAUaLk6ErgNJgfqqd2T66LEfjaUj9a2V3Fpg4EPdR3mjUsRG0j0sUlCgTntdWZ4Qr/gy4S4+GZpDQWbBVsB6xZdMJ7kIv0lMbSrQzIJD/M3TYpoDjnR/4sMzvc+Gw5V0geHTA+GM3JjuxrB56y41XxxkJY67h6V+C4anwRhvkBpSbtU4bD3K0KUN8DvnrILQIgOlTuGL2pe8yoaVj7zeKqafTFNSTl/wQ== 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=zFJix3JNi7JO3EWdkKyie+NxKGO3KHvB85rTSiy3cLE=; b=ilqVY6vp6mz6q+XkKCiGK6rWbNghsOO7zD8bUpCfPseT9iiW0ptJgsi3JR4cKfLEDFq2r9FRuZKfB6oHOtgraG4iYJ16bGod3LQNjilvCF2Bwv0f/FsUYGcq1P1bqpIk4ztO268y9McAMwsbH7BvSwQXhDFjL7tGF38xJH3xMGMhj99NsXDi7nmlLAYl6LhNL2kPy68v3s7tKAwY/lpHNeb5n18hqQFAlI6tAnX4oqFr4edWxlYT7dFav5qiDnwpFIItdmBaYf8icQKy1FYXjf6Vv3J2dOGAA8NAteFtVgfBviChOexBwgpjOuUjtp7jakwo8AsLTLb4MUfLkgMz2w== 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 PR3PR08MB5753.eurprd08.prod.outlook.com (2603:10a6:102:87::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 17:22:48 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f%6]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 17:22:48 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v3 4/5] elf: Avoid RELATIVE relocs in __tunables_init Date: Tue, 12 Jan 2021 17:22:42 +0000 Message-Id: <387267b5cd50f268056db8c89e68fac800959c15.1610471272.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.50] X-ClientProxiedBy: LO3P123CA0011.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:ba::16) 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.50) by LO3P123CA0011.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:ba::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Tue, 12 Jan 2021 17:22:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bc76a3df-4a85-4fc7-158b-08d8b71eb335 X-MS-TrafficTypeDiagnostic: PR3PR08MB5753:|AM5PR0801MB1988: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: A3ipyKy0yBrpSOO8KmN3grfISkLPS9ZiEiN2/Mh7tGjUrxgzjVMBsdSoKfclrUtme6K0PLAjzdmDBW93ZMxJAcwdRh03SFJjRiY3Lsn6wnLvJAhIogZ4BLSkgKRrVIMy8NwZY5gLyOQhS54pt351Td9cC05bgMaz0lNOpFcQnxoeHRJJ/nE1o49UE9C0HGWTveWtl7ujdQSxIUAlUErMpMSnu2HTpTV4p4dwKpmZdcO4YdQ98YEGap38P9Xa903nPCtvUrbOOSp55ZwZUWkFG1WcltqLWvZ+rJJYB7/O4T0bWvFNVbnRJf96cDrF/qECaaSex/ndEAAzNkG5nikNWOcRRP4Oc77j/bTLmUyg+rPR3z13fgRhrvNjDVAmIxYOvQJjDA3mBKwNXa7utEoM2RzLDU+66TRdXicAp/BSLYoHdmrkFg2A92Hh5jweg2H/Mhd/IgWJQ+1JKEwY8/vNyg== 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)(376002)(136003)(39850400004)(346002)(366004)(396003)(16526019)(26005)(6916009)(86362001)(6506007)(956004)(36756003)(83380400001)(69590400011)(478600001)(2906002)(8936002)(186003)(66476007)(6512007)(2616005)(6486002)(316002)(5660300002)(66946007)(44832011)(6666004)(66556008)(52116002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: d99Og5MK5knskdHrw7XukGrry1dAc9a0cHEn+QUA61yJ65mgL1wS0muYiMQMhowGIHU+H0IBQDZJ4xNILm0nBCkz93i6QqweWNSVB+h3n5IBAlvJtDJrydONIgyZA533Yfoxcjdptb0qZHcVQB9JvFAPq2aMvaRaS/s4DC57BxgrNTGOL99iEBkFrrxKaFQyZeYTz3EvaSR6+OoMydq3xPbs6s9BGYEyXYKW4aPG2SYMcfBwHfdFg1DQwhA8xnK3UkwPtoV9I7ugd5DIN5uchJDcZtHMHfV8Hu3+J8Pm9JFkODcYvp6Xif3MCYSeUA2ZRAcoRykW6YAkp1UhHOn0p2U5+Yh4HzAxvOSxC9fvlbfwXPo+rz+4dhQ5M9kzL2KDfeJ5icSSMQOFq3sQYw9w5OhjpeCj+Mzg8RbrxhEX/3pWGTZtPjysjTQIk2jDrH5ynw57dIwCpMSWjjPhnhdCmjuamI+DMb3GxwqHXEYaTY+h4iQqBXVSVeCMbNH0GuArjGC/HZ74MogT6UAN+z1zikCKlWf5q+Kr0Rs7niBGokfK8w7bWN9ji4mQo2WEiCfQh8HcBqBZskxU/wNm/Jb5sjZNR0KP0v8gffEPT2pchy9PMl8hKxVX54dyu/XOCANrab3Tgzrnn+PQk0GDqxs+u+I497B2YTFhmcF6PZE2d6Ou3JuQ5eH1xSIDiac0u/8IV2Ojtlg0thiC0bnlE+PqXgHgMR9gJ5iVql7nRZeKh+Dp5THRmSALYuisQhqndQbnQuZeb4cTp2cUckhvgyr6MHh4oznzJRf4NCTGYPMoOwUg2U1FpbPQYE2V0XQABOoO8lDKcSJEy80ue6dvF/VAbhookm16DbpGm3NwJ7IVA32Be9oDoxu2Jma8JB47v0QZ4rBRHWVquVv/I6C+mcDfY0m1zbY/hBiiJhHTS1DyJdIfa+9xJ7/kVEBlvFbW3fSySyM6BLAnLgMnl1oBUkpJe78d54Ai/RjBL+OAXyaHVA6drUOmqXUolizie60L/Zoa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5753 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: AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a09b77f8-6937-4d28-0636-08d8b71eaef6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wm2JQNl9mbiluNNVfKjXIekShY4TZlIEtqPbWeNpXpntrJvejqBRM3Gr3zgrpFBKScZ8A7JpZQNOqR3osdwZ750D5zeZ37Lm1jFiz/NwvU3NKs5ZEA78F/EOec8KtZm9AgLo92RnWc9FKPbzlXY/5d+8sMRRJC5B5jtnZu9N05dBieYDux6aRTmRAYbDfRrTsznmmk/k2fhUCf36LhEKY4RJHRLsLsC1IzGdxvnO3EyW9j1XtpVfQszt+U5s13YU2/bd+U7+1C/VOQ1H8zwXna7rTOZAUnr1V/kqEghy0xheYDlZ+pLtcpiGMb+Br6PuGVfomKQwKe6M2nlMRnHTUDOvYSWO/7DMG2he8Pm6fkqrgVIda3qE1RXehQfZMsxq+Y3tWoIoVgrfqxXl9FRrbcsWXilTjWnZu67F+5yIJaLMj48smPei+rw9KkfSzX+M019sMVzT3b0b65646FqmE5h8+svlQkAPt+F/90ChnZBY1DLC5//1GbbaFlq6xSBnZJXy1SJr4rnaxUKhBSagkw== 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)(346002)(39850400004)(396003)(376002)(46966006)(478600001)(36756003)(82310400003)(44832011)(336012)(6486002)(34020700004)(2616005)(8936002)(316002)(8676002)(86362001)(956004)(6512007)(26005)(82740400003)(70586007)(16526019)(70206006)(186003)(356005)(81166007)(47076005)(83380400001)(69590400011)(6666004)(2906002)(6506007)(6916009)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2021 17:22:55.5827 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc76a3df-4a85-4fc7-158b-08d8b71eb335 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: AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1988 X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With static pie linking pointers in the tunables list need RELATIVE relocs since the absolute address is not known at link time. We want to avoid relocations so the static pie self relocation can be done after tunables are initialized. This is a simple fix that embeds the tunable strings into the tunable list instead of using pointers. It is possible to have a more compact representation of tunables with some additional complexity in the generator and tunable parser logic. Such optimization will be useful if the list of tunables grows. There is still an issue that tunables_strdup allocates and the failure handling code path is sufficiently complex that it can easily have RELATIVE relocations. It is possible to avoid the early allocation and only change environment variables in a setuid exe after relocations are processed. But that is a bigger change and early failure is fatal anyway so it is not as critical to fix right away. Reviewed-by: Adhemerval Zanella --- elf/dl-tunable-types.h | 4 ++-- elf/dl-tunables.c | 2 +- scripts/gen-tunables.awk | 12 +++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/elf/dl-tunable-types.h b/elf/dl-tunable-types.h index 05d4958e1c..3fcc0806f5 100644 --- a/elf/dl-tunable-types.h +++ b/elf/dl-tunable-types.h @@ -59,7 +59,7 @@ typedef enum /* A tunable. */ struct _tunable { - const char *name; /* Internal name of the tunable. */ + const char name[TUNABLE_NAME_MAX]; /* Internal name of the tunable. */ tunable_type_t type; /* Data type of the tunable. */ tunable_val_t val; /* The value. */ bool initialized; /* Flag to indicate that the tunable is @@ -75,7 +75,7 @@ struct _tunable target module if the value is considered unsafe. */ /* Compatibility elements. */ - const char *env_alias; /* The compatibility environment + const char env_alias[TUNABLE_ALIAS_MAX]; /* The compatibility environment variable name. */ }; diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index 9b4d737fb8..3845b2c04e 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -350,7 +350,7 @@ __tunables_init (char **envp) /* Skip over tunables that have either been set already or should be skipped. */ - if (cur->initialized || cur->env_alias == NULL) + if (cur->initialized || cur->env_alias[0] == '\0') continue; const char *name = cur->env_alias; diff --git a/scripts/gen-tunables.awk b/scripts/gen-tunables.awk index cda12ef62e..fa63e86d1a 100644 --- a/scripts/gen-tunables.awk +++ b/scripts/gen-tunables.awk @@ -12,6 +12,8 @@ BEGIN { tunable="" ns="" top_ns="" + max_name_len=0 + max_alias_len=0 } # Skip over blank lines and comments. @@ -57,11 +59,14 @@ $1 == "}" { maxvals[top_ns,ns,tunable] = max_of[types[top_ns,ns,tunable]] } if (!env_alias[top_ns,ns,tunable]) { - env_alias[top_ns,ns,tunable] = "NULL" + env_alias[top_ns,ns,tunable] = "{0}" } if (!security_level[top_ns,ns,tunable]) { security_level[top_ns,ns,tunable] = "SXID_ERASE" } + len = length(top_ns"."ns"."tunable) + if (len > max_name_len) + max_name_len = len tunable = "" } @@ -109,6 +114,9 @@ $1 == "}" { } else if (attr == "env_alias") { env_alias[top_ns,ns,tunable] = sprintf("\"%s\"", val) + len = length(val) + if (len > max_alias_len) + max_alias_len = len } else if (attr == "security_level") { if (val == "SXID_ERASE" || val == "SXID_IGNORE" || val == "NONE") { @@ -158,6 +166,8 @@ END { print "\n#ifdef TUNABLES_INTERNAL" # Internal definitions. + print "# define TUNABLE_NAME_MAX " (max_name_len + 1) + print "# define TUNABLE_ALIAS_MAX " (max_alias_len + 1) print "# include \"dl-tunable-types.h\"" # Finally, the tunable list. print "static tunable_t tunable_list[] attribute_relro = {" From patchwork Tue Jan 12 17:23:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41701 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 737B83896C3C; Tue, 12 Jan 2021 17:23:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 737B83896C3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610472197; bh=Jwsr8wRZM3yHsHwZETSkkb4I8uvWlJ9bp9FCPl8TVvA=; 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=K05/KGPIYNkKAvJ6GYUoN/dtVR9OohuLXgq+vIMdqqrKQlaeS4WJFyeNfiv10lUKi B92Re/ImqDuahRBeyCeUH+rnNuYCnxgtpBAQWQYi9ojPyjqPQnmA++UuSjujTYyUBy 4cxmODkDOF9IeacpoBVBJIJ91/rM2xRZtMI/l0/g= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50055.outbound.protection.outlook.com [40.107.5.55]) by sourceware.org (Postfix) with ESMTPS id 99AA23896C38 for ; Tue, 12 Jan 2021 17:23:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 99AA23896C38 Received: from DB7PR05CA0048.eurprd05.prod.outlook.com (2603:10a6:10:2e::25) by DB7PR08MB3801.eurprd08.prod.outlook.com (2603:10a6:10:79::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 17:23:12 +0000 Received: from DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::6f) by DB7PR05CA0048.outlook.office365.com (2603:10a6:10:2e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 17:23:12 +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 DB5EUR03FT038.mail.protection.outlook.com (10.152.21.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 17:23:12 +0000 Received: ("Tessian outbound 4d8113405d55:v71"); Tue, 12 Jan 2021 17:23:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b576f3a3f5652ef2 X-CR-MTA-TID: 64aa7808 Received: from eb2735c627d1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A7239096-3C24-4AE5-A5CB-DBFD82218D85.1; Tue, 12 Jan 2021 17:23:07 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id eb2735c627d1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Jan 2021 17:23:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fWTu4lpAvtslaMHs8TpramPVnjtqeCAXkWu/TPzxo6NgEVMyMxFF4nmgbN8N6oFmh2oGUc/btCWQBWnLhbRzkcj110N26eouHlzwtl04yR2haOy2qzUDdUK8PCczE/9/7x0QM6iR1TMMEgSJGXo3aBFnZZvWG11Pl95XUicL77h/+P8vlmnVk00J1NYdu42998OJ3BqEXB/92OOrcT7wjMqj5kJBJhMNqJJC7yPMF+Bfx+/iEaN3iCY/cWWhtrS5eEDsSqQUNI6jC+F+qJ8+MUDbtVdK4c05rox0W+aVwU4dopDz/FQyYtxiHgUySS8WpmQJnaFtxtQD6KSGD20ZPQ== 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=Jwsr8wRZM3yHsHwZETSkkb4I8uvWlJ9bp9FCPl8TVvA=; b=JxlNsFBLMvyIY+z2GZuy9jsY3ai4H3V7ye2kCF8eFxnvP3kdSk5JEfwaBs5QP5lsOptsqADEkmRZxlUIuzjJC+Djb6rHoQJvR7MlNBo4v+9PdoDglp2bDT4d0nz/da5Aq5Ev2qr3AnNdfm1PYLrE+SLn9mG708kxAvSQ4gCpj8uXdbhkvfYDwJXyeeBuVl+OCdG643xRzgMPNM9MbA4gI6zjfQu4WJlIwpy2xB6oxvlux/RGyWIimpESQfu7mZup0mFq1Ajgs+7KjRKi54G+S0nO63cRsWtQkl/YsNi/TPO4+Gi3HKda5JpanHB0Yr2+FewCJWOYiX97/VGX3Sc7fA== 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 PR3PR08MB5753.eurprd08.prod.outlook.com (2603:10a6:102:87::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 17:23:06 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f%6]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 17:23:06 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v3 5/5] csu: Move static pie self relocation later [BZ #27072] Date: Tue, 12 Jan 2021 17:23:00 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.50] X-ClientProxiedBy: LO4P123CA0303.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:196::20) 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.50) by LO4P123CA0303.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:196::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 17:23:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e2b71abf-d1a0-4f69-a6af-08d8b71ebd65 X-MS-TrafficTypeDiagnostic: PR3PR08MB5753:|DB7PR08MB3801: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: XXM/7a0HCwzDn2YQPVeJRs7oOji/OSnip6JFBOkqVdl4+EBCrUsVxYySHlUEGyOCzVduCgCbKVZc2+ZmuKaaC/xkPyYTsoCE+PkwBD3GedKFkionkEsvMhrNUZvhdbcSjQvbZjMcxzY7W/fiyr9nAxcTI8CohKBcnq4AH/P3xOxaXrIN2WUQI5DPVXLAkk0PNl3HoskaSHBdk9lNWZCagQ0XEHvSL6Lw2TxDurHfZaCCKDXy18Wv90fN49c3KrNmZPF1ly+9hHBsj8grRXzZNyAb3qvdDLlld4+bIjE88GFae5gN5IrcGONFsX28ozheDrgMryalugXhBSgL/bj3h3fwlfeyx+W59j9GicgkHc69wcOd4yOypZMjKMGfLOQSVaqCbRF2MJLtcl+ZwN+HfoWzi0a9EbnsiVsSN1nzqbWCnYqcdJnYqpx9IYcN0FvoPrK2fPSQpyvC3GBkWIcymQ== 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)(376002)(136003)(39850400004)(346002)(366004)(396003)(16526019)(26005)(6916009)(86362001)(6506007)(956004)(36756003)(83380400001)(69590400011)(478600001)(2906002)(8936002)(186003)(66476007)(6512007)(2616005)(6486002)(316002)(5660300002)(66946007)(44832011)(6666004)(66556008)(52116002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jX9rsuRZAqVYk+vK4PtoIfXR3gVjUtT3+wZm0Ma1F1uFZCXRiGvfqhNTGbDkZ+i8T+32NJoZ674ryEY5NEAX5e/pPJQhsApdZQk+VSfH7gs4j5h9w4PJstJERY/uTQW7MTwgRHee87YzNIYUs8/NV0qGZ8cBXd37b65sRx8dZM1Ay/HXenHuy7atXnFsxfrVSbIedf6C4aBrfyKrsR1oV1x3rOnJY7tDf+7H6Z7TJ0HyxfR8GdEfYcf/c4BHpwPjP/rfGJe6MIokyMlqg0LLHMPqzbOnPJ6Orzd1blIzTrjHHog91wht6VNHjSlXBI8TXCADyZ97V5laSiDxneHZXBHVBN1fWvIa6shrctWsWNZUW0s0hpLYXszbdhzX9C8OcU+acQ7b2AdPAjT1iHCj+UehiLERFZpWMXmvktdY9inOxhH7ZyGaUD8Y2eiHthCQWjJifasJozNFcIkYouKdT6QPRlZ8GbF7ZNBmk+Ciy8AKOsNp6TeWDHVzPc0yGEfQ41lyhpnUZruuOdIm5HeSGxuVUG2S0IbuZRmLMR8jbp5SoW/zCD5krQzx72SYc9pPgqIMFZNTMDRrZVT/BDuSt0IgRFSQD1x1VHk5UI9ZVIlCbjOIml3yCBMB9ILiSJeSYdYjc3nHiiHWqH0xKPY4+FCvDKL4nn/P0HOwzPj3TdwSJtctMgQQ7Dz+zgoNZ+yJ0zFUxSuyRHFwh9eQde5RXwTlEb11pn1eOrpAh+Fkyq+nY/LnuDUFyEfj0WsrfLBr0bQB+SJsq1axtisv96lL2+RHrkUKMpxuA+fpHZZFD1u8rn6JdA+7QLmBKgtWDAzNJaNfPrT3N6aS4UgoeXMG+fmsI1fQhZi5wD5eqQDwt3lgnoNpKYVvc3YPelM3hWxl7sQ7sYus2ssgFgo0t2jI8CGTDJOe0N7rc8VWJfNJNpJpQPXc3vjCGejI0mHVYyhFYkmsCzZjAS1w5P6mphBQLdxInOyu0+WSJy32evNz/fbH9Xye7cXXLON0m7pxbWD3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5753 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: DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 13d9da07-d237-4684-9a41-08d8b71eb98a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GQZVBtkorcLaixDI4YRw+ZmAyl0wHw+rvFNaSS8cxkD02DusqrzxgtLC4j0tDBJOdHk5jYziWL/9jtuJdbkBlAe524P6DMk1SXDhhmpqYJ6F+5x/PJQw7Cxd4ZEneGS0PBmkOrTfnYo4PncrywxSVckr2OGrtJRKZ87tPA/4vuis1o2XJvd8DrUfmcLTCWJbS46adLyYaJtCV8EWjyz/ucM4v7qkD/wE58QlURZ9gv/atC3z2lh6SipmR1lZTyzhURHUvofmaX1DdYz3k8znkSqXP/XMnZ3Och/UHd1o4/HYXwDJ0Cd0cgSSKdS5kz3DJMrm+qvj/rzDDMH9764mKjryjwCa1Z1on3oFSQcTDfxE6izP+lMAQFht7cfSq7ApXlgxC4g3YPmFrKjia2Snwg565vvx95K7KTF2vTTTA2NnFZ7nMYXK1kGZQ0pKmQ12eMspFFDNJfplml0jJHqqKNug/4xMoAsRDufsGF50iycPH0ZzIztqz1mic13BKzVOan4ss4eESa4192IVjWaLBw== 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)(396003)(39850400004)(376002)(346002)(136003)(46966006)(6512007)(69590400011)(82310400003)(34020700004)(2906002)(5660300002)(356005)(36756003)(8676002)(44832011)(2616005)(956004)(82740400003)(6916009)(6666004)(478600001)(6506007)(81166007)(8936002)(70586007)(16526019)(70206006)(83380400001)(186003)(316002)(86362001)(336012)(6486002)(26005)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2021 17:23:12.7302 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2b71abf-d1a0-4f69-a6af-08d8b71ebd65 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: DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3801 X-Spam-Status: No, score=-13.8 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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 before relocation processing includes _dl_aux_init (auxvec); __libc_init_secure (); __tunables_init (__environ); ARCH_INIT_CPU_FEATURES (); These are simple enough that RELATIVE relocs can be avoided. __ehdr_start may require RELATIVE relocation so it was moved later, fortunately ehdr and phdr are not used in the early code. --- csu/libc-start.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/csu/libc-start.c b/csu/libc-start.c index db859c3bed..fb64cdb2c9 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -142,8 +142,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; @@ -165,24 +163,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), } # endif _dl_aux_init (auxvec); - if (GL(dl_phdr) == NULL) # endif - { - /* Starting from binutils-2.23, the linker will define the - magic symbol __ehdr_start to point to our own ELF header - if it is visible in a segment that also includes the phdrs. - So we can set up _dl_phdr and _dl_phnum even without any - information from auxv. */ - - extern const ElfW(Ehdr) __ehdr_start - __attribute__ ((weak, visibility ("hidden"))); - if (&__ehdr_start != NULL) - { - assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); - GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; - GL(dl_phnum) = __ehdr_start.e_phnum; - } - } /* Initialize very early so that tunables can use it. */ __libc_init_secure (); @@ -191,6 +172,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 (); @@ -202,6 +188,26 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), hwcap and platform fields available in the TCB. */ ARCH_APPLY_IREL (); +# ifdef HAVE_AUX_VECTOR + if (GL(dl_phdr) == NULL) +# endif + { + /* Starting from binutils-2.23, the linker will define the + magic symbol __ehdr_start to point to our own ELF header + if it is visible in a segment that also includes the phdrs. + So we can set up _dl_phdr and _dl_phnum even without any + information from auxv. */ + + extern const ElfW(Ehdr) __ehdr_start + __attribute__ ((weak, visibility ("hidden"))); + if (&__ehdr_start != NULL) + { + assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); + GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; + GL(dl_phnum) = __ehdr_start.e_phnum; + } + } + /* Set up the stack checker's canary. */ uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random); # ifdef THREAD_SET_STACK_GUARD