From patchwork Wed Jan 20 15:30:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41771 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 3A2D3396EC4B; Wed, 20 Jan 2021 15:30:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A2D3396EC4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611156634; bh=cROr2nG0R15ZNZ1ED1uDI0TD4qS+y923pUEAW6v29ZA=; 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=kxzGSfyOUuxjeqQgNECkQWT9ndOj4RZi1g0avNcB1vi4oyxrSFDtj0r31IG28Hh82 qEmpO6dJ/8HK+SPi7ntELsZB4OoBgZjTDmpCr4Lb7tgWbSZgEAKFr5kBLkJsb9lVjZ 93w8jtj1L+8qRoaSl05uxpq6QhiXsMI0NCwYfb1c= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80070.outbound.protection.outlook.com [40.107.8.70]) by sourceware.org (Postfix) with ESMTPS id B846A396EC34 for ; Wed, 20 Jan 2021 15:30:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B846A396EC34 Received: from AM6P193CA0096.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::37) by AM6PR08MB4008.eurprd08.prod.outlook.com (2603:10a6:20b:ae::20) 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:30:28 +0000 Received: from VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::f9) by AM6P193CA0096.outlook.office365.com (2603:10a6:209:88::37) 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:30:28 +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 VE1EUR03FT053.mail.protection.outlook.com (10.152.19.198) 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:30:27 +0000 Received: ("Tessian outbound 4d8113405d55:v71"); Wed, 20 Jan 2021 15:30:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4c8846c176bead6e X-CR-MTA-TID: 64aa7808 Received: from ad3578ee52fe.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 93FC0AAC-EF7C-43B5-8210-3E6CFAE2CB89.1; Wed, 20 Jan 2021 15:30:22 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ad3578ee52fe.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 20 Jan 2021 15:30:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OD+4/5zsabMQjAko2sb4cr4fbfMBdcOv4xDQHEchJ2WspmYXxAHygYzhD8NlPJLhWS5Q/DA+lmimrJN5JwWRKcP4C2x+qh1farsRh4BFhQrwS4Up971UghxT+iXow1n9Z9OnnQPXhGYsmzzhjbrSKQEKZFbYkSOpOnFz70opJz565tasSAnQ0RHXpC9+rElkcYwqzBpT2Hjiy/30oViamxcmrMdD4QWgvcnRN0CQvJsRX5roVolkwaPk5in1cwczXVs1gaaO1yMohxQtpfz7COIG5U/UxkCQM+wWZmFdFTHwVuotKBEZwrm4t2gNI/3lv3mREOX6sGvo6D72LIDiaA== 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=cROr2nG0R15ZNZ1ED1uDI0TD4qS+y923pUEAW6v29ZA=; b=dAKkIUeRymlyvEfXX6WZDBQucthr3BK2mWfFXStThK09KNmBMJZC6TCeEVKqSpYDDSnDVUoZuL3xyRneR9DRfnzsa6R1khr+1OmANDLpfr3NEQInVyskl7Es6dekdim412kimE1AO4BMYlRLnX0s1MxOYQRnNLBaII8uPZ6pPt3OWnvwDec6XJcvZvs6QN7KrAD+Bx2lIKyQDkkTUU9+AdAqYkVduKPWu3SyfFtICgZSKojVA+x9Aqnmd9t2Aul1i2lPjtZJInulqxVuOroC/nuy8dos9nWmw/i78JqHAge5rlAUGVEbPD5SCnOCe2eyWK6GXyK6Y92dh7g3pLZUkQ== 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 PA4PR08MB5967.eurprd08.prod.outlook.com (2603:10a6:102:e7::13) 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:30:20 +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:30:20 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v5 1/7] elf: Make the tunable struct definition internal only Date: Wed, 20 Jan 2021 15:30:14 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.51] X-ClientProxiedBy: LO4P123CA0171.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18a::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 LO4P123CA0171.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18a::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:30:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4bb7373a-40be-42de-2b76-08d8bd58509d X-MS-TrafficTypeDiagnostic: PA4PR08MB5967:|AM6PR08MB4008: 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: nKsyjcb6UKNM3PxKh6qLpFYs2BqTHGgJ8tD7voTCLwCIWvFS79wcda1dgAxsPi92BxB/exo/9mhIU41jnhxjg6EVvVOBvHtVP092mjkTzq9CElXBNabAmsPnL3HFkEvDBrHP1+P4bgsll4OZxdNKNIQ2LpGTRAxjYH6o6QXZnlEGxRR0chPXd6XRzYJ658eUJaN/Q4PeO3KUfPRfjWtnhoFQN9DbDj1DMkPK0dyD3oQr/wK/cspKztnPSoqI8CkcsrS/HKdmvCG4uGYdiWSV094k4H7DTK9CGdRZ0uVTxziDh6dTskESqZPVAjH/ZDzup7cUqN2GBVAN/3M1f0nk0cmDG/YwFILqzg/DEjHG6zEjWV4dIFJWCWsVasEJZAlV0HrZTyNyzZ6LKsGKVOoP23/1bCbeKL1PCy7DhFcI8nK3uaW25QrVL876h0mZeytcuiHh8hqapxHLKXf+q7aFoJrfmAn4EIhDi4k/4nr9XVTOz+GcdYVPAlJFfB0xhVaZTtzYSMYJjqB9a/Ol4g9FJ8dZ9hhwoMyttgatKXsVOH8= 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)(396003)(136003)(366004)(39860400002)(346002)(8676002)(8936002)(2616005)(44832011)(16526019)(52116002)(69590400011)(6486002)(36756003)(478600001)(956004)(6506007)(6916009)(316002)(83380400001)(5660300002)(6666004)(66946007)(66476007)(86362001)(66556008)(6512007)(26005)(2906002)(186003)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1ZEqh8V1m/Ri5QFFUkbP6jGmoJu1NyCg6cHCfqyrR5d2RJ6ysgbwKQJaMwgpe+OoiRvuGB1W/Wyh4JNBN4Bvd5JJzu8wgeQ/FsJAXtv4vWwII8A8idZZRsdXpSAvW8KxswUzwMRY8E0fZHjR1T8E6mQfXC90aGEtPo39lr3dVKDpN9GHPnBnyk8Z1S1H3I2T2c8ePj+dgbyztqr1SOk8UUvGGMqMKBWe35JoHDTfTMdUJDRJMPM/OZYWy8jCDYYInHtxy7ibSN7v29umv4Hf4PlhO4UrdHsSe9BAox/OCgMl3vAPFe2EJkA1/kIqftz1bSf8n5x24DwAUX/3kY0Llhg6MQJAbQDwtrACw/6R11SMfG5C8P7Q8ooMMYIWMfyEuPdLiND3sndfQsbAjYmWALFgsSFCMLzYMEL8zBZRf4QhFa061IBmsRMj0V3SMohUiTNK+jWm6CW+1hHSDxxwjbkuJAGJfYO8gHOsP1278a3rGpyiYipGt3iXHjjXK2HCkXaO8oGM1VVjN92N5jo4sNgooNiRxRAjKYutb72vh2RLPCPxFobIibxa9t/XsUKMOxDAZvHKSAA98/axIFF9RkRcaX45QvalyAjpVT2dnfY/w0hHTzPgweV3qUyJu8+pPncYjSBQUqqsqgxEgVY0gfZNZ3V65kcH8RPcW55bq+t2k4w4N1aTDt8DOGsV26hnAuhxiYl7QPNvWouHiHz0Eqros0ky+gKntKP+nNSZcdm8/KCOurDPye1IMe9XpDoiO0VQuM8upzbiK8p1aXcE5mWLw3kjypduqqHyNTrVeKDG+HgmuHHnd19V22BF3PyxI2DVfa4LGcpzb94iVndhp8rI55OgKLSBHsL1GZkN9abvbzH9idi+94AZIF0r5xkmV2DvbpjU/0+4pldWhMPZqkLkHo0tf/0DD/qoZN+QxpN2tpXni5VXN9KS6E/AjCR7IjQEK7bDNJ1+/qVjM0aYNfo/yHuHK/en2lL1cWONaP2ufJYqmr3BvCWbEimhRoQV X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB5967 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: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 7fbc1540-8f7c-431a-8e75-08d8bd584c37 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P4EchQ/VA+zMRFClZd6k37dxkDzWnG+1DCPbOQGV4P+M+YmJTBynn15YcLgELpkPuuHKYdz23CpbrxodYOBpmFqC7CNX5eCQG33fLwzsr8gPK3GixJHrB8sxvF8nz/sW7bnotyRlbvyjqihW7gsYrzTqBANBl2WiQNY3pil9IIxaWV1Jlkl7DwgFs3DZtVahJH808l9DJlleENWCLKHeSbpjpdCtuAWG3uqUDzpT0mnNmza2Yi7qwrkj0N60sIpiZcFVLghAEBjg1nWxJ/AFzZ6tBJCW/HP1F+kG1rDRxcx7JBYr/Oyr6HLcWZak4t3VMesyo6e/1BO5nzksNxfK6gWKsXWbuypwDNxIPurq5M2lfpX9nk8kAUNFROK0hHGaB+a+17ZfJB1TtnZnqNUlokAKM7KxwuyuoMQkP4lmvS9je59l6aK3ySc8Q/7zURfe5oNFkxAqj/3hCfJ/t30x2efBwtwlFv5wzOnfj6NCsH7ur5crAQBf3AIyZZtOn9MNDsk2GY/A4djnrcpj3u5tE/FmjojLjATlJ1T3u+EhsaO9FQhdmdFjbWsCcrPgMfkrWZThUzojgQu76rBt2yv8t3vrhKBSUpKbYs5jjVFWHFs= 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)(39860400002)(136003)(376002)(346002)(46966006)(316002)(478600001)(82310400003)(69590400011)(70586007)(186003)(6506007)(44832011)(2906002)(2616005)(83380400001)(26005)(356005)(6512007)(8676002)(70206006)(6916009)(81166007)(6666004)(336012)(16526019)(5660300002)(956004)(82740400003)(47076005)(6486002)(36756003)(86362001)(8936002)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 15:30:27.8485 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bb7373a-40be-42de-2b76-08d8bd58509d 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: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4008 X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, 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 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 dfa16c1977..971376ba8d 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 Wed Jan 20 15:30:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41772 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 239C4396EC65; Wed, 20 Jan 2021 15:30:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 239C4396EC65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611156658; bh=KA199iensiCqNoHViABo7DqsWTK/yTw0d2vu4x32JOY=; 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=fhyRLp+kCFAOj3Nt3SLWxc5hh/ClPAuoqCY/h6LUcbV/6P0A5HohRoIxsCnb6BTDU 4klL4gPAlqtS/oRR+biuQCksHIN6GEbjqU42L0dWzya8OI8YO4FGCdpfy+B8zGYeIo kk6nb/P3dmhYxwv7bF8f2JV5Alm3wYlxmIFj7BkE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60063.outbound.protection.outlook.com [40.107.6.63]) by sourceware.org (Postfix) with ESMTPS id 2F44D396EC34 for ; Wed, 20 Jan 2021 15:30:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2F44D396EC34 Received: from AS8PR04CA0001.eurprd04.prod.outlook.com (2603:10a6:20b:310::6) by AM6PR08MB3511.eurprd08.prod.outlook.com (2603:10a6:20b:4b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Wed, 20 Jan 2021 15:30:49 +0000 Received: from AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:310:cafe::ab) by AS8PR04CA0001.outlook.office365.com (2603:10a6:20b:310::6) 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:30:49 +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 AM5EUR03FT018.mail.protection.outlook.com (10.152.16.114) 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:30:49 +0000 Received: ("Tessian outbound 4d8113405d55:v71"); Wed, 20 Jan 2021 15:30:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4f8cf66df6452a18 X-CR-MTA-TID: 64aa7808 Received: from 0fccba8710cc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 09DFC465-1BF1-4159-A717-1C3D560B8798.1; Wed, 20 Jan 2021 15:30:39 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0fccba8710cc.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 20 Jan 2021 15:30:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EeWyame/jLDxx8wiTy6X7DUl1Q4Oy+99xjpqoZW4TwaViK+GL5EojKG+OhoTe1FU1q0MPxsB0cIz2Cn+gMGHx+UoCbLmUGoOuymUWhcUxAmCgpp9z1w6r6HIhZwQd7inzDOos0HoQ9f3rAzKYOk85tGWgsmvpz5G66Vak2mIkvuQQmSpdqFPTVXWu8yGClktmE3eHhlM0xC1mhys1qvHdossYoJsnBN6lD77GXXhAQmOsFnuj0TCdvLTbu2fcir7LOUTznfWtH3XPbRWhWvu8PFl4n1ZbY6cnhoDm/aYf2BiiWJBvCUMSL84xXPiHh9bc+a1BTqhulhaQif0ouvN2Q== 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=KA199iensiCqNoHViABo7DqsWTK/yTw0d2vu4x32JOY=; b=AHW4m9EUv7o+Uf5U6heqRbW0rkv2Z4o7d5QUz8PlqI8jtBh/sWtVa2HOLkljPKvMsfg2Z1KE1+QdV2dH1Wxrcbbvx5HJK0ZmIKwpoaR/NxrmONsS9ZirXnFK+YzkYWUxJUUsq3gpaFLoVdYE3t8eQPj3UJuTPEPoJMNwtA5a8kxDDdmDolZL8DGQUoFQ+bM0AveCm5gIPqZF8UicG1NdDKL36bdOQqnS9m6e39asfD2L/BWn+6Up9RWQh43Bgq1d/z0ISX5CRJMR4Zv4eq7A9klEqNv9B1Ec7eLT/BYadrddmbfIfD3WwisuLhF5kpl9is2dqLMnwC4QN8cccb2O4g== 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:30:37 +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:30:37 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v5 2/7] elf: Avoid RELATIVE relocs in __tunables_init Date: Wed, 20 Jan 2021 15:30:31 +0000 Message-Id: <1dcd94e2f6a0bbec766a276d70e2000b9afbf215.1611155254.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.51] X-ClientProxiedBy: LO4P123CA0482.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a8::19) 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 LO4P123CA0482.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a8::19) 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:30:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2d184bec-a4a5-4eb3-4c7b-08d8bd585d83 X-MS-TrafficTypeDiagnostic: PR3PR08MB5577:|AM6PR08MB3511: 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: F/mdD+fjhAb499TVUmZN7Z7WsiIodneUlWhbWt2xLWHGl32fqy1zl7dHuudLI+nIATwmYEG4iNbMuK+S177I3SPIeyd6wIP4XBkaSjdBlxNm0ci4CfzGSfNyDhR3kCFNFIjfUOErty7pZy8DOz0zq58pLLhLaA1fdA41EpfJlq0d9MOI8njlAIzBD6hYtdZC406Ijwp62bPTuxe+ii45GToUHnGwB1T7S+sZcO0ybJ6rMFUITOz0pthn5cXwRwqL17Cgua6DC+vcGOEqo6LfqLIMHvOVECrDb7QgPqdYweNiV1AZYFMBpcRZjVrSfQP6JBBCaq21ipJnApRFc3k49iU/oRc6Q/NIVKLyVg0sR7D03j9m0JxD1EY6u2NbSA2VTu+1PyCGnehkXAPaeXdw7Cq0KerdoCY9VnclJDptC/P9ViO1XA0OEQzfKllvKamBWP6SgOJDHHIL3S3w0ab9iw== 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: aMElcFxZaUjMAXdS4dYcAWBJGVqDdAl2GzoJflGExU5mO+DlKQyViPYSA6StgluBSEW+hHbYXapPRxw0QP1N3MDcOh/p5sskdgpcHYb2yYIfY3Jq7Y9HcmHbPQ6Cuuw7kcFvXAj4svk5Npu8tjhNdOC9NImi70+ZQoFrbHl63qahi++iVniGKTDkRUC97GCdk0gg7Iyjhx6pjukCCguopiKFnzGn7x1JVW9+FE94BG1E03m7pmH3cUX7X90NS6GRKaJIxmWfcEJZBf8yMQwsMWBu2zfT4+hBJb7/uYMH83uVroXl1ho4ahS3ag+L3xj1Dc+Kv1NSUYmzZju0oKxpMvLDupxGgz1FDTfdOQWyi3kU0SMZWql+4Cg4OVzqQCNtN6vd1yrdVDL40c1qNd+PIyzMWniBPx7y4VG3sDQ2mY4bEKHZ5pd6Hz7RS+VaIkUFnzKqdtKBINrrl+UGTT6rBGpEyUT5iDEZbOkpKJpuYmy0o+asVAF4xPzjXKLjHaJg4IdVZ78YqnOIo28SO/AE1VttSNAR2M0bRr4XQc2s2cPiybK0c5LrG3oLq035xrtMIk2ZptIONTSsvB2Vanf8Z3J8srV9zy8le8/XBpw4F4BpcyN+VGP7duGEp6ZAkCk1PDV2Zcpd86fMdkcsuywLZgnLxZdnsmCDxzhF6x/Nl8Ep/9qKl/VQnwJTax57P1QbvWdeQdSxfoXGevEfHOsHHJlapPmNmo9EVDFJgQ7NrEXtp7/1ZP5BFTcx96mdXa26pgNcfdwAv8D3W/Y/tAIipOnj8DHbDTeJFdqaK1WIu6mG4CFiv1dHC5A2QGb+6UDHqhwff7Lqsy7V41MEByjVf0t9l+jI3yILKUKTBv0ScrpBYjqt2mDFOx+dKWJM6eGJdpjUYFldFiXkoNr883UWqO160p+j2YD1+xY815FbaPpE0Vozt1XqjKnRNYGlwBWfLXuqwrsQuDkQqi7B5pmop4TTW3akgYvJdHX/EmdFnf6KxWUP6KmebI3uI1/GRiQY 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: AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 29f50e4f-c389-48d3-38e4-08d8bd58563e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fAgmfBwawpEbEp8QW/gfgi0LqUgJMSzcDTLWacZ5tYxAz5yJFp/Y2f1qk0zXCI5+eb+ZSXjEW32zteCxmePXViHnwa92iJVAEIIQGafYQxJpCSPqfgFHh2K6oKoAH+CtZTAMJafntE5PsciZpRjI/t2FkoNwmv6GlR4UNQnkzt3C3pQ5MWUV929EMGN1VtNWmK8c7KTIBa8gFGt7AJvxfutG97GSP5JZuV6Ef4jqvYXDjv0YMZprmEelLYOeUemzHdKR44N96JUYnlE2kxr0FWHIDboYxQMgagqm/MWTT4UIqiIPhIfg09Aese+OhfDujXb4f1WebW/InKUXq2RBehIHgc0LZzlOwcYAR8fGCqRfFHKroE75SjXbVt3cqE5YIx+dHPyozNl7WQ0yaGst8kzTa5O1h2YRSkHF1TD1Or86OxCmg3zmBkq9elJDITZNwp+SVP2K0FSX3M5BUIvY34x3p0IAT4x5Hr2OiSLEOWdU0qic0ExsLpgDRPPC/WGv 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)(346002)(136003)(39860400002)(376002)(396003)(46966006)(16526019)(956004)(8936002)(2906002)(70586007)(316002)(356005)(83380400001)(81166007)(2616005)(69590400011)(82310400003)(6486002)(6916009)(6512007)(336012)(82740400003)(86362001)(8676002)(36756003)(70206006)(186003)(5660300002)(26005)(478600001)(44832011)(47076005)(6666004)(6506007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 15:30:49.5923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d184bec-a4a5-4eb3-4c7b-08d8bd585d83 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: AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3511 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 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. This is bug 27181. 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 33be00e447..e44476f204 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -351,7 +351,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 Wed Jan 20 15:30:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41773 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 AC0FB385702F; Wed, 20 Jan 2021 15:31:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC0FB385702F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611156667; bh=lyoy/hecWiEiW/NnaCS/6FNt8KU+CCmHQtkbB6P8lfA=; 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=Q95oDoXJoFBQh1eWd/QFlJ3lKEc770TfklPwrAntlhPwFfCS1qU536I4FdbOVKZtU s6hg14cOS7Zoo0ModQJuRGKOBD/44sawacX7gDbg/Zuwg3hQlx9KsBbzpkdQfTpFnr yNt2ZFXlM+yntWNT2AdkhI4sumB5OtEbvXdx+Y5U= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70080.outbound.protection.outlook.com [40.107.7.80]) by sourceware.org (Postfix) with ESMTPS id E3B23396EC34 for ; Wed, 20 Jan 2021 15:31:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E3B23396EC34 Received: from AM6P192CA0046.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::23) by AM0PR08MB5267.eurprd08.prod.outlook.com (2603:10a6:208:158::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Wed, 20 Jan 2021 15:31:01 +0000 Received: from VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::10) by AM6P192CA0046.outlook.office365.com (2603:10a6:209:82::23) 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:01 +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 VE1EUR03FT048.mail.protection.outlook.com (10.152.19.8) 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:01 +0000 Received: ("Tessian outbound 587c3d093005:v71"); Wed, 20 Jan 2021 15:31:01 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6c86b1463e22563a X-CR-MTA-TID: 64aa7808 Received: from cd52daf1b77e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 454EC2E8-CB0D-42AC-B8BC-59E0F59B8DFB.1; Wed, 20 Jan 2021 15:30:55 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cd52daf1b77e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 20 Jan 2021 15:30:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JegYOrQgnDB2zYvpWN/T0UrqoG1glirJc/qnEaBdBr1o3902HOh9YAFemwdI1MNotLgpGLioe115g2NO5g7I0xCdTv26mf82G0oFMck8V+FenYXZ6Rsx1/2AzgmxwrNXHv21VtffT0+A8UIGHh8NRybxh8CY2fIycgMAFpEDxY1rbaFezm3JQgneKoglhponR9Qi+vCOU2OWDzehr7v52kcvQlBwXXhtY194CFuqMKvtulQ0HIIqqeEzdLvTQRQociEmbL2V0pCLksl+ltX7xlnrejnawotrAz2ILY6F7sUImI2aAfl4P2hkv+duQ9MYs9HJhHDbqirVPpRNK8PtLw== 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=lyoy/hecWiEiW/NnaCS/6FNt8KU+CCmHQtkbB6P8lfA=; b=SCtHaQMllgfTwfbLepRT8cCSg3Tct3omeYlX/glFp97neg5P2HCPxEjwZjAHwR145Q2Skb+clXAQ9UDG5WoKY6trIC/bVMrWwP8Gx305Ej2jZgkcXAfHUCLrsl5XN/RMjrcuMFfdLNpqnd/l3Y/yFUWFf684KXfQuWbkwuU4psr2WzWGz1yaUTbHCW/nqyHeTZxEY7pNIyCHDROG/OEyH3bJfiH0l9qWZELy+974t1BRdnyrhM4qysAY7nLZtIH80oL1RXVIHICd7qoAfKiIUiZWc4djgVXS4xPeFyJcRb/kAI2eU9aagsRG+rkHELMKA9HciWQeYUYOhJ/DO4dinw== 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:30:54 +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:30:54 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v5 3/7] configure: Check for static PIE support Date: Wed, 20 Jan 2021 15:30:48 +0000 Message-Id: <51119c6aa5f2a7ff0966d5c9fda4a61d781591fb.1611155254.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.51] X-ClientProxiedBy: LO2P265CA0207.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9e::27) 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 LO2P265CA0207.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9e::27) 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:30:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bb23b38b-16d1-48be-9e7a-08d8bd586472 X-MS-TrafficTypeDiagnostic: PR3PR08MB5577:|AM0PR08MB5267: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2803;OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: JgMPyuAQh91v3n7au0GEyDFGgAYEDIO+1+FXVg/0jIpE46fZbNKKyprSwFpG5v4C84NKM4Nw3Q+JeQdr6sfACNn+bfuyj0DMbtJYpmRfzlK2G6SGi3dRht6TAnubemu8aw6DiFdazzvPTrEOS0hpNHfRRZ7EMgzybCeSUV3o+SlSfgh5OwKjUT45RxnAvB89ELXBzNzRo/QplFcHW43yG18keyXhRc0I7Sv5W9k9VwR6srl9izaCGOi4mkM38AUxQBT1BF2nN+UwS/AnIxhsVPkBthB24tsHGykqrEI8o2fj8aojC2PN/vDcF5Sa24dBYpLKmW589wu8AN7QBV0t9lvSMpPHDeIfmo2JZzLqqLTyiyPztitY/IBmIf1PkcdvL8GhWiVIF5wPVcIrIwXFBoYwuwkQgY8rvUP/wWaZXxvmmctVTgp/jAVMi8QOVRMJMnqEScBGtYRpVo9vEMIYuQ== 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: KN27fMMblbN4ym0u3S/2wQEZbuwxnj8m7PIBv86IkKcvaKB+n88nzuVkOcO5IUShqV8o58wjKRN+JSEHguk1HY4p9JLA4I2FW2U1ZtOcp0UNk0IgAOSLPV93KyU+gRrzk2eSOMGy0lJYM9ssnjFgenHZGWNZ9URgrtjFqub9xmYYXBmeMtAxgySm8vQUgLWMAm68k7EoE31I2U1VdHSG3sZ9W3Bids+naKB9N8ss7YC7drjL7n/bk3zzsNNY5u4rg+84+7T1hpyfAn7JaEF5H39vxXJK7SnQmtVdIqvlvGXB0Dn0R7JASV7VSG6vOUrmiQnqb+PJehC7LbdMfhxURxAXAmpSNKjuguFhpLq2y0EXGzyb4zYohpv7Sj0VtrE5ksaSG14yXE7wPPm0z6XtBeuFpkUKL5ER/T5kSp/dIjDRZ+5LfWdpsXlN7jpc7X04nTr672Cc9Xhnv5CqWwfWn8lr2pEJsS5yemaw6KmQE/2TSFIEJbcnu4SlZhc3zenyy97B3S+SsryN5jTrWNse29DumWxBs9R+8sDgveR8UG1gaRUOnkkDRE9Mrh6h9XznaF6WoSmr4xoVXwuATJ9HYjI1HrytdeeYSVWYBb7RdR+5PgiDfKSEp98tN9wehTnBAkRI+ZNqpkw4xCj/SLQxIBIkhQIBvZJ2H+SYMbAVp5FIxb9hi+eNo6NQ0bQ9m+VH5I1HwWcK8MWiBWq9H9+loehc/IAcRykxsztE77hE6HlE/m2lhsnYAhwQMC6VyjlZqocbO8H2x9sIb/UlspNU1bLzWxeAPqcchx+A/W2kuUdCUbuloMfFyE6pfT24HxGusrTIiI/V6kh6GCyGV8zexuGGEMYRiQi4IXUmZEa96swzm7wuoXiFXoXWfYTbyi/Hymp1fnLLgsIlkpgDklVQPJ9m6E1GB27is/a2UC+9GfHFZq0/GYzh/0bKpA6bj0bfjjns+Sxidl5RYrw/VAHdZSqCyvWOBUSF8TDPeN+RME/jFgE5QHJlpl1sumJIDecD 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: VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5a602754-9a1e-4757-524b-08d8bd586053 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Iv3uY6LAlVCoIkxnmSPQeaEhZlGMZjCDyRrTF1zRRzUuH2q6MVOS7GHjj4WleD1VmKVxOEJqC2MnAL8aZTgowjw4B99f2/sybyAg8+Elgtxw8vXtdcjYHhc6+a8NVKLALhxU/kw9S3cyocVUNpz03v5DkeD0Sn3JDbHiAKczJJyv26tVAHXKL1l6wyiNAYGZ5xR79Lz10Qs8+1bxcPd2qQiWEv/abqIE6m5zmhGVy+9QJidw1aDhVQyoZSz1YkKsPZ5ztrIYNqK5/FV8VSgs9xeoHIWQgkZMhjXsFc+wJTukdVoBsH1yV7OeIXjnmU3TX5KFAryuUq8qftQt/0iLjNojK416237o061tKQbf5L0nn8fOaOG5ERjZp2TkcvYlomkVEA7o+Rkvfj5op/MXHoYgDAAbvON5SKyY+0ogI0MtEXGeuuLMOYFn6L9j3C1TcMBl0yA6jCDSHghWQOAGQn6+Xcu8TU0EXbSO0jPYiDIAZEULX92pxn/B/bSJZnIDDztVr0N0DTUpi8xTzZ/fs3s/dfE1fFe0iSxlm5VRHK00nibZoi6cP9urqj49rs2Z8bhfwBmuS1k2+pz9zj3dLnWAWqp3jDHFNGaFWseJPKhbvjJ0Lpfd6wXMox8Co+At 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)(39860400002)(346002)(396003)(136003)(376002)(46966006)(83380400001)(6506007)(26005)(81166007)(6666004)(82740400003)(6916009)(8936002)(70206006)(47076005)(316002)(8676002)(44832011)(82310400003)(356005)(6512007)(36756003)(186003)(69590400011)(6486002)(16526019)(336012)(478600001)(70586007)(2906002)(5660300002)(2616005)(86362001)(956004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 15:31:01.1640 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb23b38b-16d1-48be-9e7a-08d8bd586472 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: VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5267 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 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" Add SUPPORT_STATIC_PIE that targets can define if they support static PIE. This requires PI_STATIC_AND_HIDDEN support and various linker features as described in commit 9d7a3741c9e59eba87fb3ca6b9f979befce07826 Add --enable-static-pie configure option to build static PIE [BZ #19574] Currently defined on x86_64, i386 and aarch64 where static PIE is known to work. Reviewed-by: Adhemerval Zanella --- config.h.in | 3 +++ configure | 13 +++++++++++++ configure.ac | 4 ++++ sysdeps/aarch64/configure | 4 ++++ sysdeps/aarch64/configure.ac | 3 +++ sysdeps/i386/configure | 3 +++ sysdeps/i386/configure.ac | 3 +++ sysdeps/x86_64/configure | 3 +++ sysdeps/x86_64/configure.ac | 3 +++ 9 files changed, 39 insertions(+) diff --git a/config.h.in b/config.h.in index 947feeff36..06ee8ae26a 100644 --- a/config.h.in +++ b/config.h.in @@ -259,6 +259,9 @@ /* Build glibc with tunables support. */ #define HAVE_TUNABLES 0 +/* Define if static PIE is supported. */ +#undef SUPPORT_STATIC_PIE + /* Define if static PIE is enabled. */ #define ENABLE_STATIC_PIE 0 diff --git a/configure b/configure index 49f7b32b52..1dc3af60b4 100755 --- a/configure +++ b/configure @@ -6814,6 +6814,19 @@ libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory` if test "$static_pie" = yes; then + # Check target support for static PIE + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef SUPPORT_STATIC_PIE +# error static PIE is not supported +#endif +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + as_fn_error $? "the architecture does not support static PIE" "$LINENO" 5 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # The linker must support --no-dynamic-linker. if test "$libc_cv_no_dynamic_linker" != yes; then as_fn_error $? "linker support for --no-dynamic-linker needed" "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 341d4eeac2..dfebb8a7cc 100644 --- a/configure.ac +++ b/configure.ac @@ -1831,6 +1831,10 @@ libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory` AC_SUBST(libc_cv_multidir) if test "$static_pie" = yes; then + # Check target support for static PIE + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef SUPPORT_STATIC_PIE +# error static PIE is not supported +#endif]])], , AC_MSG_ERROR([the architecture does not support static PIE])) # The linker must support --no-dynamic-linker. if test "$libc_cv_no_dynamic_linker" != yes; then AC_MSG_ERROR([linker support for --no-dynamic-linker needed]) diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure index 5f5f3cc44c..83c3a23e44 100644 --- a/sysdeps/aarch64/configure +++ b/sysdeps/aarch64/configure @@ -6,6 +6,10 @@ $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h +# Static PIE is supported. +$as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h + + # We check to see if the compiler and flags are # selecting the big endian ABI and if they are then # we set libc_cv_aarch64_be to yes which causes diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac index 180a16a29f..66f755078a 100644 --- a/sysdeps/aarch64/configure.ac +++ b/sysdeps/aarch64/configure.ac @@ -5,6 +5,9 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. # The exception is -mcmodel=large which is unsupported with PIC/PIE. AC_DEFINE(PI_STATIC_AND_HIDDEN) +# Static PIE is supported. +AC_DEFINE(SUPPORT_STATIC_PIE) + # We check to see if the compiler and flags are # selecting the big endian ABI and if they are then # we set libc_cv_aarch64_be to yes which causes diff --git a/sysdeps/i386/configure b/sysdeps/i386/configure index 90c63caf35..bb482ca16c 100644 --- a/sysdeps/i386/configure +++ b/sysdeps/i386/configure @@ -117,3 +117,6 @@ if test x"$multi_arch" != xno; then $as_echo "#define NO_HIDDEN_EXTERN_FUNC_IN_PIE 1" >>confdefs.h fi + +$as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h + diff --git a/sysdeps/i386/configure.ac b/sysdeps/i386/configure.ac index 6d2068d2b3..5e43eb0adf 100644 --- a/sysdeps/i386/configure.ac +++ b/sysdeps/i386/configure.ac @@ -77,3 +77,6 @@ dnl via PIC PLT in PIE, which requires setting up EBX register. if test x"$multi_arch" != xno; then AC_DEFINE(NO_HIDDEN_EXTERN_FUNC_IN_PIE) fi + +dnl Static PIE is supported. +AC_DEFINE(SUPPORT_STATIC_PIE) diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure index 84f82c2406..198554d788 100644 --- a/sysdeps/x86_64/configure +++ b/sysdeps/x86_64/configure @@ -143,5 +143,8 @@ fi $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h +$as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h + + test -n "$critic_missing" && as_fn_error $? " *** $critic_missing" "$LINENO" 5 diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac index cdaba0c075..ec776274af 100644 --- a/sysdeps/x86_64/configure.ac +++ b/sysdeps/x86_64/configure.ac @@ -82,5 +82,8 @@ dnl It is always possible to access static and hidden symbols in an dnl position independent way. AC_DEFINE(PI_STATIC_AND_HIDDEN) +dnl Static PIE is supported. +AC_DEFINE(SUPPORT_STATIC_PIE) + test -n "$critic_missing" && AC_MSG_ERROR([ *** $critic_missing]) From patchwork Wed Jan 20 15:31:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41774 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 A32E1396EC46; Wed, 20 Jan 2021 15:31:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A32E1396EC46 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611156684; bh=dcOFZcRWhs1tYuT2FQnrHquNqoP9GmJWShHgam6GXB0=; 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=k+85X4zpwQMoDuneETL6iZJfSDHZtOmHWfzVuwTcz6ut4Hy+o+6ISdEMKrVdpy0+D z7FgEgteMZMI3g7zFtewJu9X4ZbH22jKUgiMwVIWLi5dnIEP0CaRg7KFCxaF/dxT6T yfPT9o6dw7eFJzKPWu3UdEZkD03XacU3THi605Nw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150082.outbound.protection.outlook.com [40.107.15.82]) by sourceware.org (Postfix) with ESMTPS id 6B2DB396EC34 for ; Wed, 20 Jan 2021 15:31:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6B2DB396EC34 Received: from AM5PR0101CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:206:16::15) by AM0PR08MB3123.eurprd08.prod.outlook.com (2603:10a6:208:5b::26) 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:18 +0000 Received: from AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:16:cafe::46) by AM5PR0101CA0002.outlook.office365.com (2603:10a6:206:16::15) 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:18 +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 AM5EUR03FT059.mail.protection.outlook.com (10.152.17.193) 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:18 +0000 Received: ("Tessian outbound 587c3d093005:v71"); Wed, 20 Jan 2021 15:31:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 54337ce9a930f926 X-CR-MTA-TID: 64aa7808 Received: from 838edf763b1f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7A0B08CF-9C4C-4721-BD49-D07F9A72F713.1; Wed, 20 Jan 2021 15:31:12 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 838edf763b1f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 20 Jan 2021 15:31:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AVMQ0zdx8Tsbsbf5p0TX88XlLPgIrhmY+8tjnd9C+nA2b6v3dPZyrisAyrS7N7DYvvDoKcuKbToMuJiqUEalivihCVprTRHlBrVkPnMYYmtksOrA2Okm5/hhMP5UqWg4LMRTvKd0PwY1gPYgA14lSaYjjBxeDarwqt0qDd+PBeX1wMkS8PBqM4eDRmn2zefjP1LTgDV4bSCPpyPgQsjzotFEQQl08CXli/rblHnxPpcFIBzVeqM0+D5x+AeR+C+bK07rvXzOaQQHiHO0w+p/13EIycOKdkTg1Nffvu3cOkuzVHWKbMUSqIdqetKfWUpqLtpKeGqISEjt24v2KY+U6A== 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=dcOFZcRWhs1tYuT2FQnrHquNqoP9GmJWShHgam6GXB0=; b=bvCZNVQ0FgpCMnrOX4QIsuO7Sv/q6NLcYRLEJnNhozJrzVclj7R4SRdN+grQWxfbuWD1/3qkNJSW4tbDEsAELv0O7bhXtpjJrJTBLWB8iwrOdpxBSdMTBl17y5jB9rb6SeSp4AV41gnCsOcse9zqdA3B5pRmjy+b6PeDh27Z1oikm91Kv0b+mUnqKqHdREN0LOCDLAsyKkUzeMEoHJdBfTwoF0mK4u/F8E0TjLnC19CfQAWb/pJzlS7zJbSyuUCCXJYZRdfyvlCDFKCWHap/fk7e0h/nKNn+VwEBIg4Q+nUuLKi2uXLPaZNn76kQpMgfUVFPUelSyyWv0xUZMcrt0g== 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:11 +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:11 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v5 4/7] csu: Avoid weak ref for __ehdr_start in static PIE Date: Wed, 20 Jan 2021 15:31:05 +0000 Message-Id: <4da71cb981057048e8cf9dec8731ad936b433e38.1611155254.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.51] X-ClientProxiedBy: LO2P265CA0382.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::34) 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 LO2P265CA0382.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::34) 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:31:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 49fca39c-a84c-44ee-ab73-08d8bd586e93 X-MS-TrafficTypeDiagnostic: PR3PR08MB5577:|AM0PR08MB3123: 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: 015ChQlczlIki9V4uP2CMFSWIIjDjakSwnAqBdMhGITQIdfjEpZs6Py1YXOOnK03g9KAjwvmSMp8gScENK/hU1DkvUeGVxPkYRxmxF2mqCY8+H56iM8LIjG67v+RWbEfGT9+Z4OKHUZQNMI8RxDY49Z5EosqAQ9IfRBJIGctshxZARo6ceIFkPkLf99OoLlmWTj2e3yfVJ2g41GkIHzdHVS6eB1avFr6ZnyCKefdgj13/z1rWw9c6pJ6BBrnj8ZcJ7hxR4hoisPO5ES2cPXJ1yAO9MR9VVGNCym7FEYm1GfoBCiMaKIafojgCnkjc3ZvJ/Lb7/me0P9AZan429skDjqH6CDHDf+nMuvFbGDeLMqYbKWBCSfvISbPlTYUL2bqqq6iZre1xmjlYD4k6bMZ5pwjnJncLl/fel5itfxRTzQUcX4WlcIfkjbdaE6qCWkq 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)(36756003)(86362001)(6486002)(2616005)(478600001)(4744005)(26005)(44832011)(8936002)(6512007)(6916009)(66946007)(69590400011)(956004)(8676002)(5660300002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: xud21E7Z8ZnMn0UmMExlyLOeeBtG03fwR7NrqQ+YQdFFyPG+9jSAipy2f58fKeIAkkudnleFay32yKk6SH0BcqKxh7xGazZ8x3qxEEKBYiwztCgCFMTN/RHHHdHRDw+2xrv3iuF76uv7z49xOdKTeUa9RRDKx4bbuLrmund/kJqNcfulw0Bx2RWBxhDZxGuefkc0mbJavP3X/9b3314jmq/jRDDdKfC3fe7mXbyBy8aSiDoGOU4mMGGOkIBFThoK9jlBt6a6cD87DWn9rKvY5MiVle8WeXJ7Qjn/Jj6TzHmIzn9zMLiDg5LRRtQeQk3jIDV94eORap2584HJZHU9INqjyaWhOkiw0lAK9CS7tnJVaHG8B9VnRibUCj12TPR1/mJTzS8vXlR2p6kzsnUOvtXNM3jqqk7pNDnPIHeDVE7rLBRdZLqhlyIpX3HdHIZypEh1rJcsyq3uWtTHhAInQ3Lv8qmQMnbMpQHU81UXEOVc2N1RAadY31LZqTBtWrFSuEv9VxAnkyyH+HuSOnRu+LrOvfMX0FBEf9cW67Wutpuww7EB/m3eRF0BiK6jZNZ5tvq7eOpMtbzYHMHby5pY01Wm9vVTHk15BQDt1h1qnuKmQS3+nPt1nNNrV2k7XAI6lfJiQJw7CybOwMoDpkJDo75+XVWfL/o5+an8eYz19T2G31aYk5eQJG6EzxuQX402kc9PNxKKoycPR4QB1b0Bf8q+24AMyVnRBS0ZYvbTdsymPiBKp+V9sIqpVJ4WD0ScEm+I6l/gYB8dahawBtoDsX2JYdh/j3nzBFN88oe9yIoa/wdFQD/2OrBZfWxa1fRaxJiNo7lNVOkuwOazi+fqjJ/MWHfBjWEyuY9lLKUbuyRQQuBzdj6crq8XW9TU7kzVcbmsChUtQjcjFy5dYqpyBnXg4Sm1OIeQ3eBTv416ZmCY+X2CWb6bKE81K5gGd7NBsy0ZHUlxL7jB+jM6VZiKjgKoJ9hl+eMiqBlFX0K2XK43mKMHU1RH4OiR6wPZfGbe 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: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 78b73042-fa29-4704-c398-08d8bd586a6b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2YInZpo8A7KepYSNoVmvoXToQzfiQlbzbIj7UMyTz1hLfMlPGB2MRvZgCXVEVEoDUpPH1/sNQAPrmW9Y1kLRIuLe8B5xJ0NVFA8JILdtnZEBx5Vq/dXOyUuMkjBYKxn252ZJW+Iy5ZxQdi3+Pw9TYG3URdB5i9OrHzWPCGljymWt9UvOqwnq4yTVyX12UMHG9lJG0i3CuywE5wcUlYfURyLhBb57FqSPFAGFb6idzmVa0oWx1BcT6wMVwHnTQTDxlblVxbTObX6lsSQqBQhHkGbrT+tbhp78Wbz7nVf+2KpQyD3E/UMzfjo563o3voSQlYYmN24a8A1ZpkDSxWP+esEfYhkaAIlpgb/ajJEV/YrtI+YjjvKtRVcZ0ST3o1qwoZyd60v6tY4zQFdJ1uxsqA3Wuqh7AQoi+DCVOqKSYFl1ElSEG+nsW6HAwjpPcUTAm/zrDTXDNA6U5Ut/nalWchv7/MchLFYbOfBtAGL1EgetHM/v6cgep2biqwiY6Hizy99h3ucXS5bbgwwj4UTOu5iPAL4llAE/d0xO/rauEFtGoreuww6Yi/0Ozv0KWdO3GuqVVfWGecvquysir0Vd/lTjcEh/jzGyYai0Pw5RTxE0gY3MhVb3+0oi/0hviBzY 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)(376002)(39860400002)(346002)(396003)(46966006)(70206006)(5660300002)(2906002)(47076005)(70586007)(186003)(81166007)(8676002)(8936002)(478600001)(36756003)(82310400003)(6506007)(356005)(6916009)(2616005)(6486002)(336012)(26005)(6666004)(16526019)(316002)(6512007)(86362001)(44832011)(82740400003)(4744005)(956004)(69590400011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 15:31:18.2268 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49fca39c-a84c-44ee-ab73-08d8bd586e93 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: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3123 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 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" All linkers support __ehdr_start that support static PIE linking, so there is no need to check for its presence via a weak reference. This avoids a RELATIVE relocation in static PIE startup code on some targets. With non-PIE static linking the weak ref check is kept in case the linker does not support __ehdr_start. Reviewed-by: Adhemerval Zanella --- csu/libc-start.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/csu/libc-start.c b/csu/libc-start.c index db859c3bed..5b9ce1d158 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -175,8 +175,12 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), information from auxv. */ extern const ElfW(Ehdr) __ehdr_start +# if BUILD_PIE_DEFAULT + __attribute__ ((visibility ("hidden"))); +# else __attribute__ ((weak, visibility ("hidden"))); if (&__ehdr_start != NULL) +# endif { assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; From patchwork Wed Jan 20 15:31:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41775 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 42ADF396E83F; Wed, 20 Jan 2021 15:31:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42ADF396E83F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611156718; bh=MD8os6ogBhc/djnpi791uMhtujkzAbvC3E0DJ/D5oo0=; 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=EA1XJmi1weCkS22FqUecL5KUbed5fvchxL8+Edac0POn8UzJOW+rcd/cXL9lmNK16 29EE5GmiZOCWaEQNz7fhd3pwyPBZKVdiXASAIHysyRiqc4umIqyxNrLdr7hArsHUGB a9QSGsvXx2Z6+XaCyFCA2PeDfDSvNamQRT9OUowE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0628.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::628]) by sourceware.org (Postfix) with ESMTPS id DB7C1385700F for ; Wed, 20 Jan 2021 15:31:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DB7C1385700F Received: from DB7PR05CA0024.eurprd05.prod.outlook.com (2603:10a6:10:36::37) by VE1PR08MB5727.eurprd08.prod.outlook.com (2603:10a6:800:1a5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12; Wed, 20 Jan 2021 15:31:39 +0000 Received: from DB5EUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:36:cafe::c9) by DB7PR05CA0024.outlook.office365.com (2603:10a6:10:36::37) 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:31:38 +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 DB5EUR03FT019.mail.protection.outlook.com (10.152.20.163) 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:38 +0000 Received: ("Tessian outbound e989e14f9207:v71"); Wed, 20 Jan 2021 15:31:38 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3428ffd598accdc0 X-CR-MTA-TID: 64aa7808 Received: from cecc729764a7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 47C50E69-7060-41EE-9579-F0CE510CD4A0.1; Wed, 20 Jan 2021 15:31:31 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cecc729764a7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 20 Jan 2021 15:31:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VmtQrJE1ZAzbo5peU1h0W7zF6tdmkqSkD+QBiMBANshfiuWXnky7j8LWzwLjAxiO2zaN3dkVfNvnTFRp/kfuA0/KgQad7BKl+AAgPlIIt9b7V8iAVw9Gyox6Z/DZm4MEIq40JDSvtjDglJyQsNYMwWXGaOBs4kCjFsAaIjgX1IhTWkxNB5kY/TveVee8ij91Y0rpetTQBgL41jvV+oAtwi3TMkTLlXAxZTwrHHZiNUyNG0fPIN4mZLtwiVKYDvhPJZD2WgJwV69aVX2QMFSYHlWgMp27QEDLeLxrTJOER3JfDtl/2PMTwf2hjdbHpblNb4bKKzbyXAp+zSYVOHb9lg== 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=MD8os6ogBhc/djnpi791uMhtujkzAbvC3E0DJ/D5oo0=; b=hve7taWSVPpOvRa9baMxirgAJSCvCNOId7593yVpGGLhwET1L3y19QJ4FrWfaJsfE8//WHqZStDW5zNaDh8TGEMaQNlSCVAWQRxwktdUom3mkkfMi21rvJkFd1JIYWQYqBP4XW+xUvhn0hY+bmB0Zdaz2R+SlgNf2gH3tq1Y/saMZqFctSKf2SSVU2tAKzHijx+g6N7x4T0hboDugvPfMsD5qGSsQLmUBCJk6Kls4jhFTVgJw+CYuUBOUbC3UgIaXZL3b4Tv5nuDd/VHTAIougO+ugPoiQ0nrdAFfjSxhO6hQQ9q5ByFgUoYxxYxiNG4J35nrrX367xTH0VYMI1/3g== 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: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%7]) with mapi id 15.20.3763.014; Wed, 20 Jan 2021 15:31:28 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v5 5/7] Use hidden visibility for early static PIE code Date: Wed, 20 Jan 2021 15:31:22 +0000 Message-Id: <54afd0132a909969862bb2ce96bd5e95beab324a.1611155254.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.51] X-ClientProxiedBy: LO4P123CA0487.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1ab::6) 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 LO4P123CA0487.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1ab::6) 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:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 744655f6-f482-480f-d3a2-08d8bd587ad7 X-MS-TrafficTypeDiagnostic: PR3PR08MB5577:|VE1PR08MB5727: 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: K3FxYjNp7ykFjeGDFZg6sdn5ZF3FeR0OT0VL3Bft8tmGAHvW0nsQSZ2HcNEgOnGHkS3tmqeqwM9YJ7FIzv1ZjKp1BP30MT8s5mAEg7uXgUQkoMZVaXAxUSxhZQ48mgVilwk5JqWetX3J2cR6MBbiiZTytTtjzQbF+nltOXaHEkW7CHu/well2/PRZ0i+zgqMnK+pTnHA6Iyj7alrFZtYruR4mMfH7CQ6TLsudnnrjc3GH4nJDuCKuvxcp0hVzcf/nkqyjAreV0tRx0/N47ZcA5EGRFvqRG/1QhC6oYdxzwvbwF1h+1qMu/soCetR82EkTElyliP86mPiK2QFh4ghdK3sBSMJseaez9708dlCCzWPIXjaQlrnFm1/9TGzedVD1MS+fqqCJctufO8JumdhnbL+c+LybeAWA9DxuwaD1QLwY8c68peLFWk2z0d5m9lLE+B4K2sVXrV3knT7eYzdWR4DeCiakGmnwOnUieZ0/eXNG9VGbSKT+uNq3zHsadEoSPCfa8TGS4zhusYkn/RvNg== 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: lkT05E2ZAcFGMJD7BJw8FG0rBXoSCPzn6Zr1Tr83d7xRUoL7iDj9YHSryrsqZX31EGN2o7xCvKixJylwV9BQkgOajjfNn/fx8ICdVqv7jtC9CZmHDCjTQdqGq9AjGqfgyZDjaZda+CDtjBsKlqHYwUwFNE+t34b0cnBpwn5crEBoOrb0W+4f75cEK0nAh8fIz//zViKHSkrAyT6YpFR15dqE9c4u2VKwVLTN7HqrU7M38YrdTfqxOD68UquTyQJDfxFAmcZ1VD1KAROXg5moFKPLZOlv3NeApeWx3vXFoaOLQBPZbkk44O8KdZ4pXTvh/A/7cXfQf/g5MQb9rtrpCawOSATvqD2mvTUIcch6Qr/CH9YoFl9HW7csZUdJA/tVKJ+PkUeUVPIE1PaOo3TYrHOs0idtUAW2UuYN0TT6iQLheMPPKtijNgUmcy3cfIcjCHD3spbuaTlrDyD9you6qqMMyDoPh10g7iNL4hP9G8q9FUTIFV2/g44Vi7huX2oSQktjQRzHl+jkwc0BhZb6TFArIvPyLjybQ9jQqeKRRgkdLeKu9XqbIWGNxkmSjoAZ+rE3t7P4ByT8VoPeSELy0N8uXrrx8M1RLkBA5HKm3G6C2Q6NpzUJgzsm2/KDgVJAnSwMo/Ryb9UwSz5cnuaKW6g/w+k4LcHGKklnNcef+mT/O5OxTZv2Gervcv+/xJ28JNXNq0am+914eMrwpPMXiKKCU2+FmV3hiWP9aWmX3hPZJZUR/UyA08MhxS+FBWymPS+cVMPOtjiPJZm/xn/NYkxkiXk7s5tihcA5+57VNYFH8iF5p/fobt1I+tbopUkBfHifB8URiaoyHeqZIDwykzZeIL1Mth1ZnraxHC3ovJFVp6fF3jCprfak7qF9LAHVQCSnu1cTR3Xaqouh/VhEgtPzW94sHRzLY4vRedcRU5vddy4NF4yuuBOHNrxNCaZO4RPuf4xDhNauWvwNUEB3TrKWXGfK+zoLjfRU2JYQkbmSxxVYNHj2Lu4W6VoVtefT 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: DB5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4e1d93c0-003c-4b99-3d9a-08d8bd5874be X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cqCGM88J56u1gTTcbe63ENrM/1X0Swm2pBNGuZ84VNkcS4DCMtcNNTtagCSNVzEm2e0v0p5jMs/Ey71jA6aGSbKc6xqwnzPshga3jlwuVOenqTEpMOFZ9H+2mjeimvrKpFAKTVxPRiA59XJP9QKpQN0geSgrC0E01/n2SoIAHnarJlsVbL7FFq9dBBjldw+x7gji2EjhrYzASlJy5vzRS+3lrsDeg6FUebidOjEg3+8EMVKkPNHqShygRazj18EAsFnal0uZJAifaLhtybp3H+cProlgI20e1UvryHUCA4kDiZg/ZTAj2Cmxf8nitL7vZaV5Rx7p7CKDnv6tIfEEQM99gFdnCk8GB+hIUm6sUazY62573ARC0AjL+T156XKwRMGRxRcaDnQgwqoLEmxC72Muz2hA0AsOdopb+ufll50pQC5tDWxQ+STvRPiSTazo8xIta8AWKn3WHo9oDWsKdqMzU69z/xJ7q0dbD3g5vRd2p/2RDUuimJ5vexoYCxpjWPvmYdxfC2QpR7T5nCLJTaKyJXqXhqZJypjQo7zP4HoJi3br6fPD2qMW8Cue7IpalFT1U/Z46MkqJVfRaiHReQ== 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)(346002)(376002)(396003)(46966006)(2616005)(81166007)(6666004)(356005)(82310400003)(6486002)(82740400003)(956004)(6512007)(44832011)(36756003)(336012)(478600001)(5660300002)(70586007)(186003)(70206006)(6506007)(6916009)(316002)(8676002)(2906002)(47076005)(16526019)(26005)(86362001)(69590400011)(8936002)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 15:31:38.8591 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 744655f6-f482-480f-d3a2-08d8bd587ad7 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: DB5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5727 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, 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" Extern symbol access in position independent code usually involves GOT indirection which needs RELATIVE reloc in a static linked PIE. (On some targets this is avoided e.g. because the linker can relax a GOT access to a pc-relative access, but this is not generally true.) Code that runs before static PIE self relocation must avoid relying on dynamic relocations which can be ensured by using hidden visibility. However we cannot just make all symbols hidden: On i386, all calls to IFUNC functions must go through PLT and calls to hidden functions CANNOT go through PLT in PIE since EBX used in PIE PLT may not be set up for local calls to hidden IFUNC functions. This patch aims to make symbol references hidden in code that is used before and by _dl_relocate_static_pie when building a static PIE libc. Note: for an object that is used in the startup code, its references and definition may not have consistent visibility: it is only forced hidden in the startup code. This is needed for fixing bug 27072. Co-authored-by: H.J. Lu Reviewed-by: Adhemerval Zanella --- csu/libc-start.c | 4 ++++ elf/dl-reloc-static-pie.c | 2 ++ elf/dl-support.c | 6 ++++++ elf/dl-tunables.c | 4 ++++ elf/enbl-secure.c | 4 ++++ misc/sbrk.c | 4 ++++ sysdeps/unix/sysv/linux/aarch64/libc-start.c | 5 +++++ sysdeps/x86/libc-start.c | 5 +++++ 8 files changed, 34 insertions(+) diff --git a/csu/libc-start.c b/csu/libc-start.c index 5b9ce1d158..a2f6e12728 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -15,6 +15,10 @@ License along with the GNU C Library; if not, see . */ +/* Mark symbols hidden in static PIE for early self relocation to work. */ +#if BUILD_PIE_DEFAULT +# pragma GCC visibility push(hidden) +#endif #include #include #include diff --git a/elf/dl-reloc-static-pie.c b/elf/dl-reloc-static-pie.c index a8d964061e..d5bd2f31e9 100644 --- a/elf/dl-reloc-static-pie.c +++ b/elf/dl-reloc-static-pie.c @@ -17,6 +17,8 @@ . */ #if ENABLE_STATIC_PIE +/* Mark symbols hidden in static PIE for early self relocation to work. */ +# pragma GCC visibility push(hidden) #include #include #include "dynamic-link.h" diff --git a/elf/dl-support.c b/elf/dl-support.c index 2434c470c7..7abb65d8e3 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -19,6 +19,12 @@ /* This file defines some things that for the dynamic linker are defined in rtld.c and dl-sysdep.c in ways appropriate to bootstrap dynamic linking. */ +#include +/* Mark symbols hidden in static PIE for early self relocation to work. + Note: string.h may have ifuncs which cannot be hidden on i686. */ +#if BUILD_PIE_DEFAULT +# pragma GCC visibility push(hidden) +#endif #include #include #include diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index e44476f204..b1a50b8469 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -18,6 +18,10 @@ License along with the GNU C Library; if not, see . */ +/* Mark symbols hidden in static PIE for early self relocation to work. */ +#if BUILD_PIE_DEFAULT +# pragma GCC visibility push(hidden) +#endif #include #include #include diff --git a/elf/enbl-secure.c b/elf/enbl-secure.c index 5dcf649626..9e47526bd3 100644 --- a/elf/enbl-secure.c +++ b/elf/enbl-secure.c @@ -19,6 +19,10 @@ /* This file is used in the static libc. For the shared library, dl-sysdep.c defines and initializes __libc_enable_secure. */ +/* Mark symbols hidden in static PIE for early self relocation to work. */ +#if BUILD_PIE_DEFAULT +# pragma GCC visibility push(hidden) +#endif #include #include diff --git a/misc/sbrk.c b/misc/sbrk.c index 99b3fb517e..95800b32aa 100644 --- a/misc/sbrk.c +++ b/misc/sbrk.c @@ -15,6 +15,10 @@ License along with the GNU C Library; if not, see . */ +/* Mark symbols hidden in static PIE for early self relocation to work. */ +#if BUILD_PIE_DEFAULT +# pragma GCC visibility push(hidden) +#endif #include #include #include diff --git a/sysdeps/unix/sysv/linux/aarch64/libc-start.c b/sysdeps/unix/sysv/linux/aarch64/libc-start.c index f816f04ee1..e1604a6ed0 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc-start.c +++ b/sysdeps/unix/sysv/linux/aarch64/libc-start.c @@ -17,6 +17,11 @@ . */ #ifndef SHARED + +/* Mark symbols hidden in static PIE for early self relocation to work. */ +# if BUILD_PIE_DEFAULT +# pragma GCC visibility push(hidden) +# endif # include # include diff --git a/sysdeps/x86/libc-start.c b/sysdeps/x86/libc-start.c index 4bbd7d555b..d30aec2aa1 100644 --- a/sysdeps/x86/libc-start.c +++ b/sysdeps/x86/libc-start.c @@ -16,6 +16,11 @@ . */ #ifndef SHARED + +/* Mark symbols hidden in static PIE for early self relocation to work. */ +# if BUILD_PIE_DEFAULT +# pragma GCC visibility push(hidden) +# endif /* Define I386_USE_SYSENTER to support syscall during startup in static PIE. */ # include From patchwork Wed Jan 20 15:31:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41776 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 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 ; 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: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: 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 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 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. Reviewed-by: Adhemerval Zanella --- 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 (); From patchwork Wed Jan 20 15:31:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41777 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 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 ; 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: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: 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 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 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. Reviewed-by: Adhemerval Zanella --- 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")))