From patchwork Mon Jan 18 16:23:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41744 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 16CFD38708E4; Mon, 18 Jan 2021 16:23:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16CFD38708E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987018; bh=ZMVkXXVdEGijnILf4M3bmD1FrXqiTGw+DyU8l1lh43A=; 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=DoPEkhzlgDDSKiQN+z+iqG+y9gKaAYIYZ6R3U3BwVPOMvE53kQJiz4q0ahWEC50l/ x96hFcekZh1O4jCnhc7iTK9DR19oFogq9Opyo4FQuYkREcxTczM0MvV36ilZe9+xbn 0adtaBWZux37gj2GvTUA0RXz29xIogWt8y4Le1aU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04hn0222.outbound.protection.outlook.com [52.100.18.222]) by sourceware.org (Postfix) with ESMTPS id E5056384640E for ; Mon, 18 Jan 2021 16:23:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E5056384640E Received: from AS8PR04CA0251.eurprd04.prod.outlook.com (2603:10a6:20b:330::16) by AM6PR08MB3639.eurprd08.prod.outlook.com (2603:10a6:20b:51::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10; Mon, 18 Jan 2021 16:23:23 +0000 Received: from AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:330:cafe::6e) by AS8PR04CA0251.outlook.office365.com (2603:10a6:20b:330::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Mon, 18 Jan 2021 16:23:23 +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 AM5EUR03FT052.mail.protection.outlook.com (10.152.17.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:23:23 +0000 Received: ("Tessian outbound e989e14f9207:v71"); Mon, 18 Jan 2021 16:23:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 48b71004867e5306 X-CR-MTA-TID: 64aa7808 Received: from daf43ba67b97.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8A862D6F-E060-4232-B167-A8DEF79215EB.1; Mon, 18 Jan 2021 16:23:13 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id daf43ba67b97.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:23:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XdyQnu2GO+HHxSX5uE754IgUi8bF4hGhklbpOfuDfn+Xtz3GOI5i7Kjtz6W9v4c8PNhU34F+JwqgEGyzEvVHnffUYwXzjdk/3n3FSJW+ACb2T9IEJeZYX8ExKS9+4wLceTLbWqx6eWnY5f6Ww++ssRGlEKQnjfmqwa9imyGPGHJA0MgsvqdIP0XwkSSFjo9TK4v/+odiaQcC8mRqg5MaCzJWX3CfvGI3SwBE2c+kypTF77MsTYaK4hUL+HAt+qBvvXcuLmPcSEU0YZJWpA3CzTnyFzS/vJ950q5uuBGkEdjgmA112BS3qZ1Nj37S0vc4srqZRBO4M0ePIkl/qr+Mzg== 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=ZMVkXXVdEGijnILf4M3bmD1FrXqiTGw+DyU8l1lh43A=; b=LBoEzU/eCgm6LqnL2BnHIE5t7aJhCVVO0rZ594n37ms2b3pv0rzRlMh0bmJ3SqGImvf+diPEF7cDU/irS4p9AiIl0uorvCnNffzdquky+/3MkkoBEsRv1NvLY6a7Auae/eCohmTC1EFRB0CQ9gXEw7eqtrzaOrm4bqZ7rrajQkj0TPlTrBPpMPXgfIztBY7LqOP9+LqTV+0nM8buS71pKM5ZBeOA3N5cSkAGWHiAX1gXuSbfaXNb5XupFcjwEPzjoJRD373NHcSho5CLp4gCHPAi6/8qk5eZEPIYeZVOdFKdBtFYBi1JtHUoYDTTbqik8fAaNDLubVCymjImJmFzqQ== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:23:12 +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; Mon, 18 Jan 2021 16:23:12 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 01/10] configure: Require PI_STATIC_AND_HIDDEN for static pie Date: Mon, 18 Jan 2021 16:23:00 +0000 Message-Id: <9c7e869002d50d6d97e1655458b34c262fcc9c01.1610986541.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: SA0PR11CA0001.namprd11.prod.outlook.com (2603:10b6:806:d3::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.54) by SA0PR11CA0001.namprd11.prod.outlook.com (2603:10b6:806:d3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:23:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f9927a4a-c041-4103-b95c-08d8bbcd6054 X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|AM6PR08MB3639: 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: nurrMAttpyVshSbFKRfEuf12npKfK/ESFRycLVGoF9arc3xgr24RKk+iA07mFLrZ8czGid5+fHtQDTv8tMG94rIzuQkmJUOPuOAJ/dGo5uslCM3ju4AfEDRJXyYfXLL2EANp/KXw7VQbz4h9xOtInHmGOIbG/sh8W10vor/isQdSV/1wqMxDQkpTuT2qO45ambpMMO0adDF/UzwufmlR4xMx06QTRDzKNQjcgWktip/nvJnNaWnUgtnjlqROYOBd25FHLBT5eHFEg1YnVqHQWIxkapjUzX2SKLqZnmGMEDILi0PhXjfWHeDb48NWTNHRYmOc1+iGOSdltS2HOILPgrqfN7uAhzxydxJh3oM7EYJ6rIFleNx5Sm8b2r3JUlk8QKhcn8iNAFZq1qt5wK27NybiXmZ2OpfEjnpZTrTQbmOx5xjeqeXkZHXqyBJzgaFcBF3UZhxRH6WsiSSGRVuuclqqvJFf/aolGbpxJjiAZ0wSNrUj4LZ1W1jg3BxR2RirusmCL/WIGq5hhBJIfPEjm/bsq/EAoTgaciWO2x8fQ1GoIDPlj6/R72O5yLAy2ebu3BuslTsAgAzUIFevcvuKQA== 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)(366004)(39850400004)(376002)(396003)(136003)(346002)(83380400001)(6486002)(8676002)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: un2uygcnydi64GnSkCJ/RUzEJAdulT2dohudC5skrSPNTA+uHklY5H7zdDVyaWenFCEkDnw9fFh7bVkDa5PYz69AEzJbjidYRLlEG9O60hzm2O/xk9oOkORGF+kpAEdtpNp+8uFGOfC2VITAEo6xLnog7L4VfRFkO6Ggt27/NwotDo50m8U8euVftjE4l48VMSsObvnIbw35itaJT0cEIAKYNnuq846J8XpmORgypNJYbW1Rei8YUdgSNi3AshOEijtcIkoWmN90pO0sb6AueN16t+KHrUk7zBO6mP0XddGn52MgEGwS7z9e+h59/WPAITVcGJnPqbwvP35pgNNWyyWoopCQ2Ph1QR9j05A5v5rW+kpqNMW1AQwvcf2qaU+vno1WDEr73JTDNfVlj4CoTNxM6trjcWj2eF176TNpOtPQeTERFCouaVLHfkmj1zEaLEWDIQsUom0bAf/XnhCdxNgknSY3JjEiNw/1aUxU8cqDhBnbBYYXaeJexdDGQc5FEUyjJv5J57p/AACwjGn0PEZJDGQoixHdk95a7iaAn6jKH0gX9BZ+TzdHcrjgP9U0wsbEZXAXY7RF/Dd3VgFaFtEBzI/aTbTAhPckUJz3GrrUj1H+FADL+5FZsMTcQYwcbp8f3CYHuyOcc35VVtaqP+4T4B9jqsLUvhChLMf906Yk+ND0hnAGskd1jQmSGlkasiPKkSr6/RsY5Abvscn8MW0DDN8+6P+61GGWjGAkxV2WSHrdniOjs6L5wGp+b9wzqdnZ9GK4t6woEGUWSnkRXzSjrxmpgqvcf+2WeG1ZFMmYc/CuzfuyFZVvokwqqSlt9Xn0YHMd+2h+2GxpTfxH5J0gjQafYsqvp3MT4lF+1EKHN8cgtHXCC3eCwEPynejGx/Tvro1S5hWJ/VcyLb5UHgQB8U2yHuvRok5fFF83ALfMXSemrU7Ng1mMmNGVEWIGtH91e7eAdTB56lQVXFMY3PgfL4nLP2LeNZEGB1sp5ofnHmQCj3weYGf4tjZUJzOD X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a7e2f5f4-df6a-4a59-47b4-08d8bbcd5992 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mCyd/+9KI2IEK1PQKqAg29i7FWkvGDxyh5Q7IVlgm6kNzRPaYhg4xfXV6zLvEdYJZVaKEVbtuzmF8FjRrfj1DjW3VhZrVFi92Q8ZkDLgSCzbWS9Vla7j+pRTnZzh+VaYKpkFFre6x9ykayvSEw0BLlsx6PjDNrakVQukC/Vwyt1+7DbHRut4uImLPu6ssK83gx7Jiu6m8Faom3krhL9sohKNslHA/JLt93HtXPHxP6HBXKPb+NdanTDTiDfJm0RyXc7n8sqzGQanPFK1sgURRj6ktfX7YFdk7fwqxcj05b77Air4Ys0xt3dSeRtkw5X6L0L+sRi/tD1D81Ixdme/XcAZssKu6SKjyt5FNv1VZQzz/32wc+Qt0zkRfQIUwz/Qtt8fInZnnecDIOdrboOxp3xIBS0UQ7gAdmfKzDnDHcNxMXfz+KbncPYtY/PqnjFPWSOMusH27xFo67MGxxlYNv2SJx4+XoM26OqaRaWdjYAL+KVTL47Op0zHxVyu0Qu0 X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(376002)(39850400004)(136003)(396003)(346002)(46966006)(336012)(81166007)(6486002)(8676002)(16526019)(956004)(316002)(6666004)(69590400011)(82740400003)(356005)(82310400003)(6506007)(6512007)(47076005)(186003)(2906002)(26005)(44832011)(70206006)(34010700045)(83380400001)(6916009)(8936002)(2616005)(5660300002)(70586007)(36756003)(86362001)(478600001); DIR:OUT; SFP:1501; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:23:23.1220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9927a4a-c041-4103-b95c-08d8bbcd6054 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: AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3639 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" The glibc static pie self relocation code relies on that local symbols can be accessed without dynamic relocations in position independent code. Reviewed-by: Adhemerval Zanella --- configure | 14 ++++++++++++++ configure.ac | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/configure b/configure index 49f7b32b52..dfadfdf84d 100755 --- a/configure +++ b/configure @@ -6818,6 +6818,20 @@ if test "$static_pie" = yes; then if test "$libc_cv_no_dynamic_linker" != yes; then as_fn_error $? "linker support for --no-dynamic-linker needed" "$LINENO" 5 fi + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef PI_STATIC_AND_HIDDEN +# error static pie depends on PI_STATIC_AND_HIDDEN +#endif +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + as_fn_error $? "the architecture does not support static pie" "$LINENO" 5 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + # Default to PIE. libc_cv_pie_default=yes $as_echo "#define ENABLE_STATIC_PIE 1" >>confdefs.h diff --git a/configure.ac b/configure.ac index 341d4eeac2..702c98706b 100644 --- a/configure.ac +++ b/configure.ac @@ -1835,6 +1835,11 @@ if test "$static_pie" = yes; then if test "$libc_cv_no_dynamic_linker" != yes; then AC_MSG_ERROR([linker support for --no-dynamic-linker needed]) fi + + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef PI_STATIC_AND_HIDDEN +# error static pie depends on PI_STATIC_AND_HIDDEN +#endif]])], , AC_MSG_ERROR([the architecture does not support static pie])) + # Default to PIE. libc_cv_pie_default=yes AC_DEFINE(ENABLE_STATIC_PIE) From patchwork Mon Jan 18 16:23:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41745 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 5ECA53834436; Mon, 18 Jan 2021 16:24:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5ECA53834436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987047; bh=AkMVtZ0NDvy1CtLZj4u5skjnm5ubkPWRHjcNzsGztW8=; 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=eplC3DNSgwhoH1n2xT03V6IJNm4z6qVgdMEr0ixD5gZgB+DNofO42On6MvvYFYDnF E9wsAhLCQ2Lo07JGitP0nhZe+Ev3QkhAE6UQAsmk0PhvBHDHYScEyZ6itGzvbP4UaW lr+n5YG1CndzNDe2kloddiuNYMM6euJtR4RlfCkY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05hn2230.outbound.protection.outlook.com [52.100.20.230]) by sourceware.org (Postfix) with ESMTPS id C57863834404 for ; Mon, 18 Jan 2021 16:24:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C57863834404 Received: from DB6PR0201CA0015.eurprd02.prod.outlook.com (2603:10a6:4:3f::25) by AM6PR08MB4583.eurprd08.prod.outlook.com (2603:10a6:20b:84::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:24:01 +0000 Received: from DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:3f:cafe::3a) by DB6PR0201CA0015.outlook.office365.com (2603:10a6:4:3f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:24:00 +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 DB5EUR03FT037.mail.protection.outlook.com (10.152.20.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:24:00 +0000 Received: ("Tessian outbound f362b81824dc:v71"); Mon, 18 Jan 2021 16:24:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 83dac7f161d66e49 X-CR-MTA-TID: 64aa7808 Received: from a94864fb8540.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 484B9ECB-310F-4C72-B87A-47B25685CCEA.1; Mon, 18 Jan 2021 16:23:36 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a94864fb8540.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:23:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R170HcL2o9N6rcaVRva9pogrIPqgaveg8XszRBxtyTcZ9B6AkbkuJc8Tm2NR/ot5rqzivvI+qzawHxqr/bS1kD6+p1aR+b5LLJuScONrzbdGwCapdCaMTDLWEz7CDu96W2uO1BZNsmnWHWf9DR45HdJIRHIDCdXyXBxZAYC96EfWsXgesj4D0wLKBhM+6yqyS5TJpO+Oa6/6f5A8Ss1LO3DLjEhray9hUkLFxJ8k/qvBNGTU7MyQK1zIhkEyuJOjU3QIGPjJYTJXIgBwBr/gqiCqSXHuiNBGp0h2Hi03f0Yh1XIqp6oFP0s/qaNMshMYbNs62QhYRPQvLZcf+kolMg== 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=AkMVtZ0NDvy1CtLZj4u5skjnm5ubkPWRHjcNzsGztW8=; b=JCKHVKqAZu5e4yH4ExLx6H9HgPmlLF/gHpZsf0rChAMTHRYwdd1qNC3A62jXq7J/1H+WVg+JSNQ3cyFgzfLP1C7J5SKuyY7gzT+VRU2uVsu2IEhz/eURowOvUD9vcMOKwFUxZlNHnX746v4OjUJj1P+1s1ERW9kqks3kFLHdIafpmLa1962fpjkva8nUsPjEpvYgzhXS6u3QzYpAxsILWGaOKngsM51ohHCaZBQbm2XQXvkTZkfGWAzksmBt5yNVYDVggkz12aRH945dP0+n2UyOiiAmV+xanhZH/wOx+LRFj9tPVJvP1D+j0wTlOPrRNUQVpwGpf8H9siFq2gw/VA== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:23:34 +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; Mon, 18 Jan 2021 16:23:34 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 02/10] libmvec: Add extra-test-objs to test-extras Date: Mon, 18 Jan 2021 16:23:23 +0000 Message-Id: <7bd28c328f72f26418a19efd151660381a8b597f.1610986541.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: SN7PR04CA0116.namprd04.prod.outlook.com (2603:10b6:806:122::31) 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.54) by SN7PR04CA0116.namprd04.prod.outlook.com (2603:10b6:806:122::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Mon, 18 Jan 2021 16:23:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5f28d1be-bb11-4910-b5c0-08d8bbcd76d4 X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|AM6PR08MB4583: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1201;OLM:1201; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: XzQ13g2Z7ejEcttWPeqYUauGjm7tOh7hcNoMqu4A4AA2LthCdmqONfUfWZp848yYnEKfZ/mu2X/z+owBBAT4Py8hrPrhfUoDIXlQPJTzqo2SXPmXzb67mzZ7ySLodbctC738tICm9WI2IDiChx6OLf+/qjDwH7I5/XfjZNWW5nNnog8R2W4IL41sxnPhjDmIBOUR5y7l3/1DKPhfzYqSvlFvRj1/bubjOwHgY+mKK1q8QUShNGzrCgh84AD63oNhY9QhApI5LiY54Oi6cmOPOffVOrHbO822WNW/UhiDUeHZEmaOZrmPl4xT36HI1orgPBD4+S3sWnkRCTTKThH3IXNo1EmH6QPpHhFhmCE3uOLyPG+MdpiXnXvENsEX/AMKrFnpmRf1KXLssUXAWTKd6Wx+0FWWuUCLn9ybt81EAU662xEs2UVT9/GhyXTehBAQjWdwAmJwUOwDnRVN3ySdzBB7Xy5ArGWHdvbv4LR+7295L2pBPFx/Npl/hNfusGrmWmzzAGM3pvnOTZK3FNODxPY3L0zmeHdGI618NU/LyJeEinGLkDz11usTR+bqoTfj4fwKrz73RGt65cl/dTC0nQ== 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)(366004)(39850400004)(376002)(396003)(136003)(346002)(6486002)(8676002)(4326008)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: eY5jgvrpYWCGAl34ZNV8yQNE2w6j/W7gw3WubzG5+qWLNyWUQe0znEmLuOSzGTj88vzD3OyTTV0EkqOqa61kBhxAkG18upaVNQ5K4OdKydMvWTgGXHv9xkkSP3xLERnY/R80vbXO3Ssfee9jsv0mxsUSX9T1UW818byVwq6xq7rR1Zhm45m+Hq8/12neG5P1Q2S0dNZUVIxCcu3Pmod7NpTwI6YguYyOqwJAaWSm7nAlxxuHXbg+OySb1bu6KwOnzGzCSSmG7ydraTZb0c2IgWCCzH2Agb60IGUzG/CXVdlxffdgEhbV5D+C5JlbjwVTlYrS8fjaE6hKds92iaFY4AsMPM30gX1Y3XYjQjRlgnPZWEi1h7nnS6yaWkBhWX+MM+eIgY+0Rr2GbZa+3hpaPkLgFIPVmR5f6cYVKt4oGD6aP9CyVwlMDh0zZKgdSGkp9kmJkY3xawtGL5xVnCyd2zw60mrkESbnTk013fV8Sap3RkeyziAecAqaxJ4QJ9Q2DXI9xcS6l2Qv5x+ZU+3SF9IjfNNSB4XS4ysTZW3W+MUoIK3h9KWM30mdw8oQeHw/pIOTkeBzkS2dViJwD9sGBFXkSBO4DOuyRvkqjHED522AAkmdbIdI1eZKlml4yZq50jXZFi2LTrXfhzr6ecDUVhnZz3+wT6O7bSnKSs+yiPLVUexAB+q9oQHNfWQiVk26oXfjb/tO6jCwE2mGSlE2QwX+X30sp88N/if6xeZULmfYM+7IXm5mDoBwsqJ1cyPzhA8hpnj0qlLO++l4uYdHdCYZnftNGKMGHIjgCO80UNGR3ju8nMd3Or3dHto3hiJ9j0r9oeJ8bswFJmayA8Uz4HW2GrYqCiszCFm1Z4/yYQWTUbcVaMAINwILvqMMJaDECevLV+eO1NBBy8dOnZCj9zmhKBUktUXgQ/jBP2sQ/dwKNmZPQtMWxh3Jp+tYTw1TrTIVmzzsi4r22wnLJf1RsCTxrhw40l3lafmR/t8fYvFR4sTJyRWtnDd8M03pBsaL X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: f033b1b8-fc37-4fcc-9282-08d8bbcd66f0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W54h3WyGe8smteLMbjgeXRl9TEOalmZHZay4Z5JAhHaxTfnZXXgenBP49f3prfBSm9a07xya9ZSQfD/MxQWQNorrSc1Od+5eyXsiL5T9kAx3OtLhU0IR2sRsaZ6Y9HMOFBZyMI98AgmCvumEgtLH6AC+3NYfHZCF3LsChe1wcVEQUSl72PsyMIPaN+hE2iTNRd1I1DbR+0gHWRCjVF4TZhZ6nAPZBDr5r8MxwkGz/L5ScFg9brelfx8zxG0Z+jtKmZOSRfSLDKMjVhLWJ72SGAFl3d86yXxEBfBsxxLiQnxDGDfnzjZQURja4OyLwSkeew/Eg0Yn1ojmN0Mz8BpA8Fu2Wo2aQz4UmE5qknlhGxl+vslvgXFvxxNZQMmfQ1SfVKD7tGV2QrjdI91sRsxxwA+EMowDpQQBeYiUsXG72d7tZRoBvZNbfLkQR6YczuXFCcPIfnAuFvhoD5cn1lFtuheEKDjJ1ZkV0KiC3Bgm2LUCFOuLiR/2gb+hUjDuDIlq X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(376002)(346002)(396003)(39860400002)(136003)(46966006)(956004)(70586007)(26005)(6506007)(2616005)(6666004)(6916009)(2906002)(82310400003)(186003)(70206006)(336012)(8676002)(316002)(34010700045)(6512007)(36756003)(6486002)(4326008)(16526019)(5660300002)(107886003)(69590400011)(47076005)(44832011)(81166007)(356005)(8936002)(478600001)(82740400003)(86362001); DIR:OUT; SFP:1501; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:24:00.9196 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f28d1be-bb11-4910-b5c0-08d8bbcd76d4 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: DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4583 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" From: "H.J. Lu" Add extra-test-objs to test-extras so that they are compiled with -DMODULE_NAME=testsuite instead of -DMODULE_NAME=libc. Reviewed-by: Adhemerval Zanella --- sysdeps/x86_64/fpu/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sysdeps/x86_64/fpu/Makefile b/sysdeps/x86_64/fpu/Makefile index a4ff2723a8..9a4bdd075c 100644 --- a/sysdeps/x86_64/fpu/Makefile +++ b/sysdeps/x86_64/fpu/Makefile @@ -31,6 +31,12 @@ libmvec-tests += double-vlen2 double-vlen4 double-vlen4-avx2 \ tests += test-double-libmvec-sincos test-double-libmvec-sincos-avx \ test-double-libmvec-sincos-avx2 test-float-libmvec-sincosf \ test-float-libmvec-sincosf-avx test-float-libmvec-sincosf-avx2 +test-extras += test-double-libmvec-sincos-avx-main \ + test-double-libmvec-sincos-avx2-main \ + test-double-libmvec-sincos-main \ + test-float-libmvec-sincosf-avx-main \ + test-float-libmvec-sincosf-avx2-main \ + test-float-libmvec-sincosf-main extra-test-objs += test-double-libmvec-sincos-avx-main.o \ test-double-libmvec-sincos-avx2-main.o \ test-double-libmvec-sincos-main.o \ @@ -66,6 +72,8 @@ ifeq (yes,$(config-cflags-avx512)) libmvec-tests += double-vlen8 float-vlen16 tests += test-double-libmvec-sincos-avx512 \ test-float-libmvec-sincosf-avx512 +test-extras += test-double-libmvec-sincos-avx512-main \ + test-float-libmvec-sincosf-avx512-main extra-test-objs += test-double-libmvec-sincos-avx512-main.o \ test-float-libmvec-sincosf-avx512-main.o From patchwork Mon Jan 18 16:23:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41746 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 A2270383443D; Mon, 18 Jan 2021 16:24:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2270383443D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987081; 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=c5MhroqKyKpCmZsswxwfFvReCeKJphA4oXRgeDl8xl0YWTDFVqxVTuFGUIlAQC4QP fwnkKgXJZoKUfjLJtWdepGE/GA5EKQbT20rGeYcd2H+netMmPj2r9rb7E2wr8UKzKA 5RHpZr/t3AfBXvUB0EZty7HnopkuudNMYbVILhvI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130072.outbound.protection.outlook.com [40.107.13.72]) by sourceware.org (Postfix) with ESMTPS id E4D923834404 for ; Mon, 18 Jan 2021 16:24:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E4D923834404 Received: from AM5PR0402CA0011.eurprd04.prod.outlook.com (2603:10a6:203:90::21) by AM6PR08MB4567.eurprd08.prod.outlook.com (2603:10a6:20b:b0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Mon, 18 Jan 2021 16:24:36 +0000 Received: from AM5EUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:90:cafe::c4) by AM5PR0402CA0011.outlook.office365.com (2603:10a6:203:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:24:36 +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 AM5EUR03FT016.mail.protection.outlook.com (10.152.16.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:24:35 +0000 Received: ("Tessian outbound 28c96a6c9d2e:v71"); Mon, 18 Jan 2021 16:24:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e1a13cf188467e94 X-CR-MTA-TID: 64aa7808 Received: from 30ba2a8df3b6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CDEAC6F2-D691-40B5-9DDB-29F50B36B54F.1; Mon, 18 Jan 2021 16:23:58 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 30ba2a8df3b6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:23:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VxsZSqh91jc69HexriJv6BhdPsvjR/FA+RwXFhAB1mR81d6nWx3NEYS4En1QB76IPBIrG1DDK0kUcZ//mdKurIY5T6QJkePG5nBAz3+J5Qn/YToixeIVTqb/fglFoJzCl1RDg6HpINbkBx0oRrpveD7A+Qf27c17nxI0T/c40w2QF/M/yWHVxa2F6JbgVJy76+x8By9OOKDc3XsUJM+2K6Kvvhydd34x2uj+NN53F5hysHwppQHQ5+UFDKGdJeb0paIYgYrsCZrqYEKvMRwmmLR/zNM/OOCp9l48rIzbsa6IExHq5a+WQE6ZGPzi3z4lEWPQ7/RZgXrlXMj3+I5EhQ== 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=eiZ/r5PDEmq7w5aVsKMjwsgK01U5UY2jSQFcsBKwHBB0ycLdaT/7m7/vwRa68e2zo/8UImHvILoOS4JpyqyUCfols4KBR6SuBVvxiOcZWxlBr919+wlcPSMugfro7MB3VQfvMULt/gl40tqj//zEqmsPRAQQlwvVZTG2cwNvupVhht5W1SrTiLQBRXW7ZSXXHqg86e0RAs3ID0BKTc773Mx7qArFhu1uiKxBSHLbTElDLT7+gR+/z+UehSsiLLrCLIeSx2b+OIxTZ7f0VKkZ3iSuYdL+EzLrPLSPzu2FepPWy/sAhoQwUZRKUBb9jp8D7vKWCDO43HKuiQiTi+fIBA== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:23:57 +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; Mon, 18 Jan 2021 16:23:57 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 03/10] elf: Make the tunable struct definition internal only Date: Mon, 18 Jan 2021 16:23:45 +0000 Message-Id: <58d4e6b7948d34f948b7a04386f5ec6baa82b9ff.1610986541.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: SN7PR04CA0172.namprd04.prod.outlook.com (2603:10b6:806:125::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.54) by SN7PR04CA0172.namprd04.prod.outlook.com (2603:10b6:806:125::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:23:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: de1cd43d-c52b-408d-b28c-08d8bbcd8bbf X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|AM6PR08MB4567: 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: kWml++j4LbFjpWFEEpShp0cWNRyBXyWeNc9kSBTp+yCHds9d80jcy/RGGghRS+3Fi/mW+OwDIpTn1Xi8InuBLs5hV4+XHlLbhblxAEtCBKx8WMw3SmeWBp9jLNsl0npgCenVQ+TXDxBA/ociG3rtmYg+MP0AekAWFXK8OFBbsC+kV8uAmywwYkUpQ3gD/AH2KGt6BXn6R4M0pcLep5tpcO0jJOcTb02B8JEliH86+i1mfjzH3c7c5+UeDj6eE0auCyNn4dWCCnV9xOEef/g9u81vi2EFwnSAaKHz1bni57BluTG9ideqCNkj2sL4o0m/zYVBYcwkHSPmZWDEYW8CSYD4j4ZdgMg8zMZ7fIi2RRR77SnF8M5zoCkq6ff+/10Ej+5gm18SXGw4TJil6Ty7FfYJT801WWhRcwc/OKLwv4jt/xj9XAX2fnH9zq2SP39w4g5fj7OLkVq1naCv0gTwow6rd2CqSvk3ggfflg1N5mzVuwUuziCyPLQYv+l+3v/9YfyFX5BY/cH9vdqFN17IJZ+xlK1QT6u3Cd092Tw6SRtbZDUL8wEbs87yGpXrAvHYXOI2GST4Kz8mpvb+EXERA07GO8xUVhPm8meeTkZWqe0329MpKJle48KHJ+5EY2OT91ne4PwsXRmm9EthJdEWutXJAMNwTo8F66dNerIqOdzQWX7frHkiRfKHOVj6lp9c 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)(366004)(39850400004)(376002)(396003)(136003)(346002)(83380400001)(6486002)(8676002)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: n1IVi7labUId1J7vsG5YGgXGJFQNuAjea01srwehOpJYc9uW3S2wkuxSc88U8A1et2Y2FV+KZreE6nI705qBaXzwbzMm4QbQqh0BHD5dNYhbYpuO1n3nfUElsrT8fK5usym9gxUilqtQCsYQVoTDQGYWj+l2p6hghk1GnyNDBpWtRgkVg+p61Is9qk5J3HVDGqc+EAHLa3FfEEJ0taza3a0z75957XXbXU7ss2Njpg19VWhx+XXLo2cmOx4Rho/NKDDgR9XOn31C11fqx5kiT5Qk17fGRnVIDVNZpWtdxU+c9crBxVmCSfIBDjDbJhtTEH59UdYERGzWQpMLsm81SbSFyhbToD+CO1PCq7p0LUTmdap3rZioKMf2Plo9vZA2kMA1b02xAfjzw/AYAZ7vGCKdaFtCFRPH5G1i90Sm2Nh7ByOd7ATZRuMZamixSEm73e9eOOeXZOCKhdCYBwhM7WlyVuInGPJK5eIFyNAOBPTacP2OB8Nhjr8yu9Rgh7MttrJTexfCQlRXJeOMQZ3CDmN1EXCdP4YgES7jUJT80eD72hTbZhFD4DOr2f/1PbM30dTfrVfYzFyGrQTVfw8+43C1x1lSCHY6sSK6KZzmGYAZVO+iOMGqhBXiiBWMQVsI3Opz2gDqaFWIEKJ213SUr0TVLoeSBv0rL9kRT0pxHtL4miiz4Gas6O9iBSknHwWYZUWxyzl//Yi1VC+97WlNwtpRKU+PG7uaFRMLiemJrCcFMAsLfvVMsSRvGA0+3WsZ/xRvBwKYpusargPTplfpbDpwfoCzNW8amWvQiE9dM1iDUQEZrW44enDAqYb5b8axtG67PzfjYoN2ZkF7/L4zJR7agFsLNcdFVQH1il7jutRG1WcB6BNr/Vo796xOOA3q6D1tZv+mkw5Pbi4nH+9S8ddeQQshJ7O2yRKSdMsR+1a6IRTyg9lwg55yAk8E/heWInvt2Ocd35/qAh6L+3fdWpupNx8V3fpvHrI0OhVLNZbqrd5uRgf5CMpU7r3qqFsr X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: AM5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 295b1467-483d-48d7-18ce-08d8bbcd746d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6UnUw8SZjDYo1lpCGbX6/eYAba4tV+L1vlSoPXWDK3Hx75GYEZhOFYdrCTTyxitQmt2jEmxsu2QUNSvLvkxR+qq7sdlqI8Tq13IwmaIr9atJXNkdxWxuRyW7SbbVxTwcDq8Puc8qez/1Ac4a4oKN4Dz7ZO4Bp81LSxhYmKpYE40Sr8ckC3Rz0lCl3FUGqe0XqNoIG7yQJrdL8ggoFtfooGqDAtsbOD5TWaLJkSJ1h01Z15T/hhBgmq5ZPUVIxHzoPS37DsFe1W8TJpuNj++brV8Cwn5fK36LtBWNR4KgDPbjoyF9DX8w4bAOMCBJPvgKTF4Uq12MJW4eowwLdtfwqhO3QFTMUQZsEVSzbvlizbe1VC2GM0om9xstcaWQTyQLQXi+LcHdVFZpoGaxF9NoMjt3yKEQrOdzQW/cbUZ0rtgz7Bt0SiMBMSmioDMEOQ5wcfGkNB1eO/OIKmtve/vm4AuN8u3HOW/MY4CAveski+t1O1WwiwrqCn0ChqEMmDS/etUfH5zvJXDziLy2XCm8jsKGWZ+cRpkMmuNVuI4K0QrXqIcnYmGBkB5GObuw8xwpVNzbLGkY8YL4vaijYYn05qvW4+RS2uZOyKzWstxw5+w= 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)(396003)(376002)(39860400002)(136003)(46966006)(6916009)(70206006)(6666004)(36756003)(8676002)(6506007)(6512007)(83380400001)(82310400003)(44832011)(336012)(956004)(6486002)(70586007)(2616005)(478600001)(82740400003)(316002)(5660300002)(86362001)(16526019)(186003)(47076005)(69590400011)(8936002)(2906002)(26005)(81166007)(356005)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:24:35.9601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de1cd43d-c52b-408d-b28c-08d8bbcd8bbf 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: AM5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4567 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 Mon Jan 18 16:24:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41747 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 9D2B8383440B; Mon, 18 Jan 2021 16:24:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D2B8383440B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987085; 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=VLfD5MItojgxpXDsJpf4y/G8DQu7EQN+xljwPSdBebpWNeNESLEyAMT3bgn1PsdWA HiCNEHc4bbEV8TMvHRv6XnVZEi25AtCEmJVqER9Y6jQoNKPOxmXNjedzXmiQ6Bqoyc 8N3Va07/CSVvWO8BAsTy+AzBnk40XrEqgpcdjs5o= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02hn2231.outbound.protection.outlook.com [52.100.10.231]) by sourceware.org (Postfix) with ESMTPS id 1A4BA383440B for ; Mon, 18 Jan 2021 16:24:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1A4BA383440B Received: from AM6P193CA0142.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::47) by AM6PR08MB3926.eurprd08.prod.outlook.com (2603:10a6:20b:a7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:24:41 +0000 Received: from AM5EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:85:cafe::6a) by AM6P193CA0142.outlook.office365.com (2603:10a6:209:85::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Mon, 18 Jan 2021 16:24:41 +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.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:24:40 +0000 Received: ("Tessian outbound e989e14f9207:v71"); Mon, 18 Jan 2021 16:24:40 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 703767d0863b3712 X-CR-MTA-TID: 64aa7808 Received: from f9aa9d739290.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D2F50564-BBC7-44E2-AD2B-B8B23392ECF8.1; Mon, 18 Jan 2021 16:24:16 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f9aa9d739290.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:24:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ftMnXPDoj5nO/mLeUMrsQggTcrhGNerv3bG6g68bpbWfpeCOQ/kSdz2mfG8C3IC5YQefwwhaLvmnht+/DJelEqTbuGtlImo1Hqp74qJ6eChLf7HFEOKKaZlNw+YJg7pVXOPl1Sb3c/mhoAsQfjn0mUvJHW+KKfLp26m2n2zfQiq43F0ooy0JvpRcYeZjyOryHmbT2yojvIHadcpeIVpQjy8NJnFs3aztNa1nXq3uW/Jy7qXwQlW79buBmX4kpawFUCJT4wwlnomkaEAVD80Lp7YxOTi3yv7ry1cU3qtWR54k4/qeeJsdqqpVdg2CyRFkOYw7nPOh/36eSbf5fWof3Q== 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=CbSrswru/0NdkNNurF3WNdizfv/OguIolt6KIkQQYHaH/y7xcwFkSs4jkh6dXQ1xvBAnUaPm4X2gCu1T6YMmubJUrpUhX8drJIHkyOUXq+MK/5BQN61luVE7kfLTqKRGYE3baayoElinrb8/0DPsVTrs4YeCtNygQxM+lS8BMJ3Srl8MkxH+sRWdUxcIwKyL6C9oV3MbIllVVHeMy/NkERZWpw7zmP+t7MGwTCkwR4BqNllyd69lTN2WHxPbUHOynDvNUPo3eR+YEdtOA9mRvJYK8ThZXybuGg3TJtQQeL+xMUcCz7q0u5Lrb2CoWYLYRvfOAcgqIdq8PCUpnS57Zg== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:24:15 +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; Mon, 18 Jan 2021 16:24:15 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 04/10] elf: Avoid RELATIVE relocs in __tunables_init Date: Mon, 18 Jan 2021 16:24:08 +0000 Message-Id: <13b7b3186927350d9037a855b0b767c3be847562.1610986541.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LO4P123CA0057.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::8) 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.54) by LO4P123CA0057.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Mon, 18 Jan 2021 16:24:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1b370800-50c8-425a-eab9-08d8bbcd8e96 X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|AM6PR08MB3926: 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: g7oaLSKpjLg5mq7zUm9ULBlbBN4hT9YhluYXNtuSLt6bTu+1gUB0KGuOo+pfx4hWWXGpHKNSr5wkwuhErgNwLgAkS1zanNwxnHvZDMnGz2e2tiCsEOO2B/LviT0/jFwt1xfF485awHmQPcgZVT8ZNqE45NY0GKs4XM83dIbxicGgl+hzBUKTlEw1zQT6A5zm7Tdl9rMwWwjKH54dtsG4ffB4G43pOjLzB+wnC67cDs2b9bejeF46FMSy2F//htS6HA3u7p34Hg4XQup65+SqJZRsdRfgoHGsnLyLksLAcKyveWqRpqtZ96+Pzw1c9Zz/EXYs8mcElxSTe6ke/JkxbkXIZIPTRF2N9f8aEDH49uM2wCxwm/Mwmcqn7OIqN85lhxALe8MYnBeLh02lANd3Z/brUH5ZOs8NCZpy6XOox5HV3CTuvHTSVtuxlU5uv3Wn1rnrwl3BPK8foO2FxegKklPmIlCYLEKyVvRR0OMxxAYatPrO0uLr138tKrNR/rIMlI42X1qnFfFdWkKLATSB+5/r7psnVHQToqpiZYpBGzdqp9A18Ypd1h/834EoePrX8sV6BUBTHFnsLNVt3oC4tA== 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)(366004)(39850400004)(376002)(396003)(136003)(346002)(83380400001)(6486002)(8676002)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: bHshbvtPD5wxCpFsVzP3mErh8vHv4YfApXZ/wE1YQ3aYQqYJLfU0xVDnVg61iP9OZlb+ikIWAuleE2azC4a1xO/pSwXACieCKQ14m1LjsXiNBYI8gYmDmPdrCA7vXiX0Cjl+PZ02pyPYSoifBhpUHANjs2ctWzVfVv1M3W3y2WfxE81B7lol4x5DI0UYfk0euQVxsAsk0YA8pXObIWOfq1iXIooNtO4o8HPBVfwZp3DJ2bzcbZ+vDE+g9V9zTAGrNdJ7WqH9/BSz/6WFIkyxj43xM+stnX0EIW25W7VlSjsYZ3rJRiJFQVuXl7XGC6VhhAI7jM4Krk4EhB7mBey6qSQ6k/hkxBNElN6rN8gkzFvqeutUaN1TWL52CRF41gDnUUee7Qryh2a1Fj+g50rc+EUvs9eUhOc0+azKtBdQCV1nVhUF2wtX3oFtWQuCFZHd3eh1f8dI3tgejYPW+x1izzgvlbv+xo+fTCu4dmo9uhX1N2HacBx7szGA5bwewgk+oLkgdnRW4PFSu24w15Bqiw0RL1FfRdQO31hfeYWOE8UqVG8Ti66eQlbmrlvtXbkrIk0xsr82YZLIMKTYdqX0r5K4A5xhQb2232bW0QV3VJC1PMnZ2c75HugtnHeuzyXHz0gCI1DCzC5O1pBDx7R7VvYbZG17F+adq0Ad6jGoQDczhYvwDnlznnx4AK5rWQjrkLfEZyONBmbvZLhmp4bsbNtekc5uPg0IUmyxxIdUGjig4+3/Uyhfcii90Zb2qyV+0BSGohqQx2wyRPjNE3X6CGy8CMYY5vq2TLYBU3lzmDK11RBG/PcB7ftcWhLvqwclNDTf4E/7ZFDT2lQ7VwCTRu0X0gI7X/v5c/Drzb62ZhtUkTFmFOCNVtuMPzUpr6Dg2lB2ajT5pXlay3lGZOdHwQMD2Lesxnwvpg8TpLN4lD3kLWUkiXcEZx+tXWn1UOuj6XS7tXwmXmxFJgARwd4dtyl9y3vRJA3r3wZknSCT7G7yHWhWgEOK/vPm4DZuNPq8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: 441592dc-8275-4f90-f2d8-08d8bbcd7ef7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YOFpEWrzVf1JLY/+oB09zPEajuZhRYWUQQQZ2ba3NlGx9M1LDJ3vlQ8+MIowyUewpNg65SLrtiaL9NiaeEFeoDGXTEYv1wPYo1p3XQjKkJEHBbQsUgOWwlKP4GBVjMGwHrR91O/W5CHj4WoXxIxJ8ynYtBbw3TNN5rmGPXNhzJzkIEQCQ4QfzwC2uisawxzRamodAF7OUlMfKM7Q3mxfM5jZf1J+9cHJfUW6UJ5k3moZxgB/dPDFbxREeUfh1g1pKhgBpnKXQ9wd3T1IOZfiUkf3qpnPcjYsQLgXl1z6Y6mvMj54kKq2XNdihw0R4tKKUrmVHac4/xTVNj00FNoNM9uxSKiVBJa6J0H2pAxE3JsYpJqlzB7JBayxt1STSPaWPLgBwcPZ5psRbCaPDcUoz5xuM6gc0Dg1XFpiAPjnt/1KmxHrmryiGTbRoMmQwQNj0frNpDkUiG3J86bnEoOdPbgr08z+V3FyQnSJ57zTJuhheSp/nnaK0zL9ENHQs2Qm 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)(376002)(136003)(39860400002)(396003)(46966006)(70206006)(336012)(356005)(70586007)(26005)(86362001)(956004)(44832011)(83380400001)(81166007)(36756003)(478600001)(8936002)(6916009)(2616005)(47076005)(6666004)(16526019)(186003)(82740400003)(82310400003)(5660300002)(69590400011)(2906002)(8676002)(34010700045)(316002)(6486002)(6506007)(6512007); DIR:OUT; SFP:1501; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:24:40.7260 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b370800-50c8-425a-eab9-08d8bbcd8e96 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: AM6PR08MB3926 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 Mon Jan 18 16:24:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41748 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 8FA0D388701F; Mon, 18 Jan 2021 16:24:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FA0D388701F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987089; bh=NdwbyvWSA3YCPHRItzLCa3R+fOtIU67FL366m3JQ4/M=; 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=MmDIHIAHsytb41zPvMcRFi3MaqAkyMBZ3z5Xgp3/yZBSbPmonHM+nlTR/AkGjzahp fgqVxBECT6OuoRUJamzCpQjsCaR6ERNKqVifn7RSGYPYxRk9FjiTTZoDg7SN/NYNpC vW5QRsS+LiMXWf7Uenea1b5ge9aHFKhIf7WDmSzs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-mr2fra01hn2239.outbound.protection.outlook.com [52.100.177.239]) by sourceware.org (Postfix) with ESMTPS id D3045388A826 for ; Mon, 18 Jan 2021 16:24:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D3045388A826 Received: from DB6PR0601CA0022.eurprd06.prod.outlook.com (2603:10a6:4:7b::32) by PR2PR08MB4748.eurprd08.prod.outlook.com (2603:10a6:101:1f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:24:45 +0000 Received: from DB5EUR03FT017.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:7b:cafe::8b) by DB6PR0601CA0022.outlook.office365.com (2603:10a6:4:7b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Mon, 18 Jan 2021 16:24:44 +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 DB5EUR03FT017.mail.protection.outlook.com (10.152.20.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:24:44 +0000 Received: ("Tessian outbound af289585f0f4:v71"); Mon, 18 Jan 2021 16:24:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 57731025d9654971 X-CR-MTA-TID: 64aa7808 Received: from f471ff8196be.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6665C44F-950D-478A-BC80-8007308B3CA4.1; Mon, 18 Jan 2021 16:24:39 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f471ff8196be.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:24:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WTSFG0WqfcW4PB2T9l9sUGKe9SmvRQ9QRp859VHEJOiREVdKYQBqe6NGm/4lI2A/fLwtxZOTgXczN6BIpkHyXA5jDQA+JfxB6oSXpRXLng2yUhrFEqNJNjYDi5OqbgE28FC5Dpu0AM7oSWCw50LhTgo5ZAP6Y3zYxhBFr230fdhN/jMw3zA7whPbe8LVBC5CHZNPCzUop6GJwCWGQXEvUDJa0JeXXlTOfjtG5QJLu66C9ZFYRLl1JqDYlbp1ovMYL6RwMV6nQqM/C3ZxznWgd5bEFehjsNm2VOSXTu1tDS1+hrQs8JT+VFv2tKJMXyIQnzg3Ozrh7wodNaMLL4zUMw== 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=NdwbyvWSA3YCPHRItzLCa3R+fOtIU67FL366m3JQ4/M=; b=nMHEQ3jsNhqBs6FrdBHr/bXD3OXqN3famTzSsB3HUMKKTn+wlLHz6lz0Nm/gnh6wRZu6TcFNFIenyGHelSJWR36Gn/BYDDy0IsGBzeazFITF9t2fiit+afImh8Msz2PUGNW4lqcq1SL8qZ9KBluO9WvfskLw+oMu8guiSjnM+8O7ONzW4T2JEgc5D98WJI6vSvzsu+QwH3tPPtTBvUCLiQoqOzzTk31a3aKePw7GHk143goAJ1SJh6llZtxjjLASOrld+eVvtjiopzxRVeb/S5azp1cHE4nTErMnxDLPFL6kP3IL6/8w7VRHYXpV39AbjR/U7m2ZyQaXHv1tZT127A== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:24: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; Mon, 18 Jan 2021 16:24:37 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 05/10] Use hidden visibility for early static PIE code Date: Mon, 18 Jan 2021 16:24:25 +0000 Message-Id: <78d3bf1bc9e9f7c1eafbcf011bbd815e7f6e90b0.1610986541.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: SN4PR0501CA0101.namprd05.prod.outlook.com (2603:10b6:803:42::18) 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.54) by SN4PR0501CA0101.namprd05.prod.outlook.com (2603:10b6:803:42::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.6 via Frontend Transport; Mon, 18 Jan 2021 16:24:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8ab957ee-cd52-4a1e-0a8b-08d8bbcd9103 X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|PR2PR08MB4748: 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: wfbr3mXRzChNemex2rtEy/EN5aMqn3Yd4j0Fl61pFZ7Wv4eDpo9TWiKz1uw1ltQq1HXR6upTn3xKmA9IkeFYcOs2U3SZ1Cb1db2T+iHv/ulfv7ddPWCzZOCJ61xpKz5RPocpn+BLOQacHVKtmcGpCW8Ni8xS/DSgNpYNPKslj8N24ej1L5KSMkuGVqCvA2DCx//w4gxXOrh/QGChD5Z0yAVspy50WZu5kBBjAQ7q6t+UyGCoiWo0167F3vo1RmDphypB8aDBlzo99Kgd5pm+d5ThIcLk3S0DaG06Rfo15K8SqfqEO1K7c6uZj4U84Xs5C9u2HqEnjE30p3xkIyxKOLwRvAR30tuQSey+AlJ+UWeONqzqk83Z9L4Rv393m0/kLLAif6i2EpAe4o1rzac5ceWuYyIjaJ1NIKn8ONITTXyGJA5A8DzsXRB1y/HRxRlRiRBg58NB/Z7QQK4zCBP21/ZdRnrBGeY/mh5frcFywWdPb0p+BbpeQZ1jykqTnbYF7FFoCXzTpHhllzMX5cyuYGa7N+Oy0wxXRG53+mmpmj8dkep5typizCSmIWeK33v+ptP3eKj3KE3eKVpfRPHv25wjXNIdhFrZl+aiY01e7YyWX7YYpFWgBZaSZ1GIhLh/MiDZPKdRdrU7p6avqLvCSzWMnTX7jyZwH/jzixQxp0M= 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)(366004)(39850400004)(376002)(396003)(136003)(346002)(6486002)(8676002)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jwiHPZ0dS68FRYEhPIzQEIm9RbtSNEBXNaPXbZSHzjytdbM8Y+c5x95l2q0hBHg0zyMdMsvmEh+/SKUtZFDxFFq4BIDnZHLB33pxHM5jXggcesqHMgAjO6OF0pAt4mK3qJBUv2GhGn8FN6tJVedAieoS266yuVwTTilskQsGwoIJxU54JrnKpdYnGkXHR4Yiy+K3yeG+l5ZKuAP7zp5uEaSOd+tqdrSO682GzLbRkG8LhWy6V6fQUEGxT5y5sJtXmmVgldmW31Hbvl0tQIR+ijlALXkgVlK7Fn8hChb9XRLbL713iBErFqpTytPUfS29bxjxUMUhI2Lqo5aYiYMeuAujDIHrnkTphLUt7fpGc08pbJ9yqjRuM42gbX98aA0mvTpTN/fSeH6bhfoStfzyO51UEHWr7P3QbRuNp5JD1a8ImmfHGfGR3B2+SVVTJKJMy5RxP/TL+qetubHZP1pon0Ele7oQumHxeEpABaUj6E8RrfiXj/RysM98tNQFHw9SkutKw7ijGZQFB65BdJ5ESIrt58Uf2SHkPefNzT+UI4KozhIsVP1LH0WieSsTwRMKpu4PNKghyV7Ra9FKIhprtwqreMZe762GkRghbDKT+x3Uctsit8+XT4hX6u3JoSKYzZaWMHEDL+cun2thuXUm/l0wO+kKxhk66/gzShRZY2qEgJi1LEm6TrgwzG1bpdp9ibpEwEK5xg2mTbNWohs1umh5YsoLTc1u5qtKg758jbBe4TAKItYdobEYSM5q8ZLcrhIboLLENiSFFde+hKhgjQ3a1sEdmWrUynTWG3POrvEE3oZJqOH1qeWMbOfWKzs92pVEhmBMgz2M+rVwxZ4gsh8yHycHFb6RXv+Dk4ILG/Ryy0PmpGIW3v9J7IhSlYNEVT0J+nEOcek81ToxjBeny9vQ1LIqfnE3h06Esbyc80c+APEjq8fqLs3fwEkmm1ILUwoZ7Te7Eux1HfZPdKc4Vdndg3Gbm2xqjg7JdEXFKo8P1ROVuOJ6a4/kgdz4lTV1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: DB5EUR03FT017.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: bad3b8d5-f83a-4d1f-b228-08d8bbcd8c4a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IP9JjzqVEVdzQM1dUs/mpYtufnggRGEFVo4j2xwbPovCkkeBqKlTLkzqVbzST1cRPcomur+HhJue//7mzFOIsuY6rwFx4WY+0+2N9xBcVCDAczueelk0x/atmlLH2bdFcd4B2YI9q5dCmENhZD0P/Pa1sZ4StM8zkxeSUtL+AVE7URurcS6tMtLJPZ06VNGZubnfUaq64i0B6HRX+zND0Bwp3R5+33IC3wFm2XZnZUlCoSH9rgef3dpeK9siDxm578C3QR/3i1C9g1hmFG4x02s9Kjv4PaXmPCm6eiDwYkxz8k6mdYaZBA47DRmQFB/nbsoeSnR+TSB2mAiXaC+pEiZfN926u/VhckrH19oJumgKF+RISzq/5pRjXu6IxQgwHDilyj1NojrqCkPpxG0CwmAVrMAmahckgzb4xIMo1xcKMDIImXj0nSsMb32eZunw9+gfyYOyRWS9TSGXV79dCboNPpZx4ovddql7cFbbYKRPTT68a1h4TXjGleoL+lBeOXCXxFMWSeHk/wd9D4xDnaQ2pm0K6TNsFBiCzWVnXNmxkTAWyustRPriDci+jDAaovoOVX3hGrtYQT6KDTfDQw== 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)(396003)(376002)(46966006)(8676002)(47076005)(82310400003)(36756003)(8936002)(16526019)(34010700045)(2616005)(336012)(186003)(478600001)(44832011)(26005)(82740400003)(6506007)(5660300002)(6512007)(6916009)(6486002)(956004)(316002)(356005)(86362001)(70206006)(2906002)(6666004)(69590400011)(81166007)(70586007); DIR:OUT; SFP:1501; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:24:44.8430 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ab957ee-cd52-4a1e-0a8b-08d8bbcd9103 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: DB5EUR03FT017.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4748 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, 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" This is necessary to avoid RELATIVE relocations in code that has to run before static PIE self relocation. We cannot 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. Even if we can't make all libc symbols hidden for static PIE on i386, we must make all symbols used before and by _dl_relocate_static_pie hidden. This is needed for fixing bug 27072. Co-authored-by: H.J. Lu --- 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 db859c3bed..1e90dcb0a7 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 9d468d5a4b..384080dd80 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 bc8c5e96d2..ffd7938605 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 Mon Jan 18 16:24: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: 41749 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 29B833834404; Mon, 18 Jan 2021 16:25:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29B833834404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987107; bh=AdyoSE5CMXjAE5vYaJDFruUjYXDyPfVi1c2wMX3xpIQ=; 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=UhpJQaUhKFVeL+/bGTpEu+yts2KhZyKpEt9IuvdN0Q5vQjwPVSOQvjaWnmlRiQJ4W yH+YZKIlrEXrZ+m6Ix9fIQLCIqKwlsE/OAJ78/e6xv63raMg+3DPMVKweuy4zBMIfc 0TYgXCgfaSnrYp98k+9czrnvBYn6NHlatIAsrZmA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04hn0249.outbound.protection.outlook.com [52.100.17.249]) by sourceware.org (Postfix) with ESMTPS id BF5BB3834404 for ; Mon, 18 Jan 2021 16:25:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BF5BB3834404 Received: from AM0PR08CA0022.eurprd08.prod.outlook.com (2603:10a6:208:d2::35) by AM0PR08MB3172.eurprd08.prod.outlook.com (2603:10a6:208:66::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Mon, 18 Jan 2021 16:25:02 +0000 Received: from AM5EUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:d2:cafe::c0) by AM0PR08CA0022.outlook.office365.com (2603:10a6:208:d2::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:25:02 +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 AM5EUR03FT057.mail.protection.outlook.com (10.152.17.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:25:01 +0000 Received: ("Tessian outbound 2b57fdd78668:v71"); Mon, 18 Jan 2021 16:25:01 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8eb0bb8a311de959 X-CR-MTA-TID: 64aa7808 Received: from 2f20a7066578.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F1D249C8-9798-491C-8E4F-C1BE7811420C.1; Mon, 18 Jan 2021 16:24:56 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2f20a7066578.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:24:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=la6bta/wJPA4wYhzS0cvu1GsgwyxYGL54gUXXzYBXEDDoPvmKXQZZ+8qQ0ZQDs67L4de0PwfOAJk1qy1DH9JthEBKnlyaOeosmg0CXV7RTZt+HXO4s++wrss1bjXyChtPfHglw8rfdQS2E/2XH5o60vM8ccOXraRDYWBJAZznSAlA8PbDlC+coHHEir39NW47VaXgHCTPXfzHaZSI0qvAzwJnms9XntiYnd9I4LEFDivEn73JlRmH1xaoGeSywMI6Lb8NvbLLG+bbF2c0HFm9OPiYBdS6b5RfzlTadaJiC7NcWD7wnI5TbqMi2dJzNYvSaUBADpulvPODRADLMu3+g== 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=AdyoSE5CMXjAE5vYaJDFruUjYXDyPfVi1c2wMX3xpIQ=; b=mNC5CV3f2RO+K6IHg6Jrkxf1pi1MW4Jczt/E3KYO8+GopeUP4vxbusogd2t57wI2B/VjuUNEJKFjaEMZmV93IH7PR27jdzxojJBMPUEK6UhIhxJzDtAEofMt9gzHG7V2Lq3oD4+rG5HSaTK5qVuf/SxvpKvQ7ATjP5EaSWspeHtrPHZ24vujipP8mKR5ySiSVIqpm6pp/Ma/eDz/Q+DKRLv9kw00Cy29L48s9sLswd0n2/is5efo/+xTn/c453Wb6iEouVojjyVHUZUL4MH8N4kb3nWrKv3ZhyiuErpf4YNQWVqenYVhp/lT3hPmEdbnxj6k2M1ooGjlMcRCc2kOfA== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:24:55 +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; Mon, 18 Jan 2021 16:24:55 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 06/10] elf: Avoid RELATIVE relocation for _dl_sysinfo Date: Mon, 18 Jan 2021 16:24:48 +0000 Message-Id: <3ed8c627e3f1353e5539b458e596c4112121b3ba.1610986541.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LNXP265CA0065.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::29) 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.54) by LNXP265CA0065.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Mon, 18 Jan 2021 16:24:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8ac28741-209a-4fe6-a643-08d8bbcd9b3a X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|AM0PR08MB3172: 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: rNTBTMoHI7o2QXhXbnVqm5Aihz8/IrMmVDIqlN9CwMX6BTZmzXCWkILHQSGnkhm8FwZqLr7X9myUbobKwIcAUoLaCwVH6vCYPFeyDoMLSxjU767tbNOcMYLfFYkVulIAFKP2Wt02NmmtDTZyItNPLTEmlQrCHCUfkJ6IskoK0OFGamhwFYeq9TIw8H2tFo5gLGfwHb0V9P/APy/SEYIgoqaSBXCtiJpmHYmPctz4kfM7oiJHwLiXJ1ebk0LPI+TnKCuOt/auEXnZ7z4EMdRT0cd390NCi9cz3v5L0O5W7qGegi1GoqmUZ982Hp4bWX6ZX/6bSHgQVj4gT5V8d3jYo7P07hWMatkrHm6ZmJY/TBu+kMBNSQrD80W0+wqHNc8/9fooPhePeunpeJl24zzVHutfKEPYpRhKA9tiJbc/T6bwGt2EUOcERdlIt36wlYw30B0YC5dlUCc6WH8Kv08vvVcZ4x+sU/MqAKiJD5wjvDLRfDMz8CkkMFmhebF+yZjhcSZM+3HAmSDLee7J8NbnWg7KeNhJ511CmqUME1LHggLOmzdIJYRPXL8VWs+E7NXzJYajmDeaPgEWR+GvC1afrw== 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)(366004)(39850400004)(376002)(396003)(136003)(346002)(83380400001)(6486002)(8676002)(4326008)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Udas7VN5mleXDHttjJJGQk0J/SKEtfOvy6uMaNaOKMbSKc/1YCXWwZmTCb/Ptttpuwt1/XNArR8MkWqXV4d4IL7i3gTcc5chkAcgogXs08g50N1JDEnmPdAG6Vzw6lSpLqBt6U5DK/kZj6H+ZXNdZd8ehVQKra3f1zozDfj6bBqQY/kQK03EzkijKArWaK6Op02ZiUIE/VlLeSmBpsw1hDxDQmTiiPoY0j5+vQgC7Qf7d0zQKk9mPQ6iAPRqeF9k/uKtdHk2sstIo/D/hHKt9smsiqzlpidaRLFT5oqidxx2c5jp8hs9yYkBsmnN+TjFhUd6g4cKWkwnwyqjJwrPcpZvgRLGAhzc/fbitGPxVnyK4imm+9LLKqorSYCyH3F70m0O35ZmNvsGIS8u6r8MAwODaL+ZvPw0saJ2a4QeLle+ZCLMxm+UppkPclqEU1TupKcv0GhmW5VlQM5WwPQpNtEtj8kjBDFsvUzGXuD0NF95HxeaitTSRW0pXbUtLtx5Z/xxVuR6+1i4Jo0KyppDzJScXF6FetQrxMM4UUILTVXnpekmo3GyecRIgdlbDGZ27/trvki6B9DNsP2RQDvcwIHQxPCXOMteAzUEVmZ3LIk2dxg24cDoE4hhj03u/kj8HYNldLw8lQ+kYVNnGvBXDirk2zurQ7/ViwRyGjM2aDtA0PaDYtbJEYryJGQS15+426fOWHkjxjjwcWEp7TIhPb13rWjzwEe46f+tdgGw0zfXdddq1WtIrd0XWfxjt26COnpG1emf0+u/GcG/qKW3IyZkPyzq7GsqAz74MoCIPKnszcHwGpRde4A6Hwv/lSN09Dvq4X6FssSvYi6SiBtJ6/G6mN1tVF/ZnQqKg0ffyiPiB32cV/ndW+rw9U0EkAcMDOmpBkW/lKaaU0qzBNl/tvXMJe2TfMFl3IDh6OsI7ZTTHpNIE8k+0nfw+smdOJGBNKmCdgckZbYwe4FtrQMmZyD/igtqM7v1k+wFRs+oQj2wQsQIrVw5XbNYWDdHvjzQ X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: AM5EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 46ba3502-f89f-4952-3efa-08d8bbcd96e1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: We8rzdducK0HfpMJSGShJidcjoibwrlGT92PXWUeoZnJyVokyJVjs9NYBnriKJRxa/dPFIxywxyO/aChEwk4W7CKk6MCtPkUieYNcXy6d54uVKA+9lntUrfWUX/Eaps+RN6TC8EcmwZcXbESBPLlHHEbnuxCa8BfYPXcJoXLk4kRg9B4ucuKlWDdiQ30ztiW5mPbQ3T/2UWG3O1nI9/sDRWTsTx/2riB/QW2oq3DFNKvreSSj/KL9RunVS8uVGLB0KL0PGDxwUxzEs5nepb0Iu1TqDuMUJ843DF3vjoC1bcFR4L8Wy8gF4++jCRK9mK7MFcqnylDaSsjPhkzlLHzH+2oLA8hQwBvCUVAGxwCa5dljt/2/VDDh5zuYUuHSHmtSfbUj7rS18EDislFDCgVYHfGLhmGu86ZF2POqtu7kKhHLWM+VZIhOTsU7vcB+tmCSE/PTnQzmvzx0paU1HHDGkB9Zs76GFjHB0qszdCjJt3LmZiudLciODAA0UanfKPh 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)(396003)(346002)(46966006)(6512007)(81166007)(6486002)(107886003)(2906002)(47076005)(356005)(4326008)(70586007)(82740400003)(26005)(83380400001)(6916009)(5660300002)(8676002)(86362001)(70206006)(6666004)(316002)(16526019)(2616005)(44832011)(82310400003)(956004)(186003)(34010700045)(336012)(69590400011)(478600001)(8936002)(36756003)(6506007); DIR:OUT; SFP:1501; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:25:01.9367 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ac28741-209a-4fe6-a643-08d8bbcd9b3a 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: AM5EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3172 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_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" From: "H.J. Lu" In static PIE, set the default _dl_sysinfo in _dl_aux_init, instead of using the RELATIVE relocation to intialize it. This is needed for fixing bug 27072 on x86. --- elf/dl-support.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/elf/dl-support.c b/elf/dl-support.c index 384080dd80..5acd59290f 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -200,7 +200,12 @@ struct dl_scope_free_list *_dl_scope_free_list; #ifdef NEED_DL_SYSINFO /* Needed for improved syscall handling on at least x86/Linux. */ -uintptr_t _dl_sysinfo = DL_SYSINFO_DEFAULT; +uintptr_t _dl_sysinfo +/* NB: Avoid RELATIVE relocation in static PIE. */ +# ifndef BUILD_PIE_DEFAULT + = DL_SYSINFO_DEFAULT +# endif +; #endif #ifdef NEED_DL_SYSINFO_DSO /* Address of the ELF headers in the vsyscall page. */ @@ -238,6 +243,11 @@ _dl_aux_init (ElfW(auxv_t) *av) uid_t uid = 0; gid_t gid = 0; +#if defined NEED_DL_SYSINFO && BUILD_PIE_DEFAULT + /* NB: Avoid RELATIVE relocation in static PIE. */ + GL(dl_sysinfo) = DL_SYSINFO_DEFAULT; +#endif + _dl_auxv = av; for (; av->a_type != AT_NULL; ++av) switch (av->a_type) From patchwork Mon Jan 18 16:25: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: 41750 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 C1183388C013; Mon, 18 Jan 2021 16:26:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1183388C013 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987161; bh=UN454289J4yQ4WzBXRgiF4A340sy66+FfJ+Fy2OYPbM=; 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=NiUMDnuWapIXc6SxV26UOs0xr8ihGrgP0L0EMk0WJTO32hu1dpW5Q5jIGrFPM0YCJ GbmYeAQ9DuNKDerdWOpufEiwQ4E9ayKOjWLbTBOvAwGKIxuzfk3tCGD8xVF15jQ77J IUE+hHOY2vA0AmOslYAuflXciD8P2Cvoq52EtkNk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04hn0222.outbound.protection.outlook.com [52.100.17.222]) by sourceware.org (Postfix) with ESMTPS id DDD3C3834417 for ; Mon, 18 Jan 2021 16:25:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DDD3C3834417 Received: from AM5PR0202CA0002.eurprd02.prod.outlook.com (2603:10a6:203:69::12) by AS8PR08MB6550.eurprd08.prod.outlook.com (2603:10a6:20b:31b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10; Mon, 18 Jan 2021 16:25:57 +0000 Received: from AM5EUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:69:cafe::24) by AM5PR0202CA0002.outlook.office365.com (2603:10a6:203:69::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:25:57 +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 AM5EUR03FT019.mail.protection.outlook.com (10.152.16.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:25:56 +0000 Received: ("Tessian outbound 8418c949a3fa:v71"); Mon, 18 Jan 2021 16:25:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c96b1b69635cbe37 X-CR-MTA-TID: 64aa7808 Received: from 0a1eb37e297c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 50B0AFEB-1594-4F72-83EF-0804AA5F5115.1; Mon, 18 Jan 2021 16:25:18 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0a1eb37e297c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:25:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=efL9e1QHKjKO9qnwqHWuWHN6fnPyuCk5Om5Mw6x1FU5dmEQ4olh8HA87nSaD7uMeWT6vTZXcOuNZ7AfBo3ZfjUdwbcP+0yL4Hr8AvvwCy3PM1h1VM6rYO1vAcWWnJdKEmEtiByN+YdvG+BlpLI8sJWWCdAuNcaxaoMFvNkYsnBPhi4p/owU6Vc5ceOsxokx82muu5PKKmBdGjUN+ZqbpMLMmLihwxbdFgYWXFfMVDx87OCeeHbp6Sm7RB6G2juzmK22F/sKErzrX3eQwN5dLPT94fMffh8VdlCKrWWHvkL8fBvQTJINAgQJAvoFKiVELLYkiuKLLieIUmefa61RXkw== 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=UN454289J4yQ4WzBXRgiF4A340sy66+FfJ+Fy2OYPbM=; b=eS2js+2Z7bgVT1TfTbdBUJeT0Sy2Yx+EuKXojgSWRDQ+2aVvz5ZovEZzkvfA1HgNSoznNf2XwZT4F6MSdYUct+imcc/NQOdqiPGHMKCfAuXWPx/8dCcaLa+m0LmZ0as5cHiuPUZhxE0306QzB0LFQVfFRWJklPnXW8mgZTWeD72Lteq6GpSYkfoByGD2+baCz7gF+LYcUY2YUK+bQHfHDPyLmSJQxgAoudenKErAM5nv+McT3gYNREytp5Rg3rJ9twEYuDmgmP1PoOEd4RQYYMqzZUak9wnNELoTCV/YNVhl58KV4UhZBbs6UyvZ4UpPgb8C03n862QkeGWO7u98/A== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:25:17 +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; Mon, 18 Jan 2021 16:25:17 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 07/10] Use in __libc_init_secure Date: Mon, 18 Jan 2021 16:25:05 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: SN4PR0501CA0002.namprd05.prod.outlook.com (2603:10b6:803:40::15) 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.54) by SN4PR0501CA0002.namprd05.prod.outlook.com (2603:10b6:803:40::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.4 via Frontend Transport; Mon, 18 Jan 2021 16:25:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: cd3668bc-eb0f-41b7-fc70-08d8bbcdbbd2 X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|AS8PR08MB6550: 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: mX2ql/XWzmV7rplgFYqDXW9l3jPv/nNA3xOlJ3+CvsgiSToVnnRgjo5Vvk1S+xbLkF9iNcBEGBUjqexpvTNUWLVvjT7iXZFl+lA1lk3rJAtXP7rnL8vjx28w+Z2Zy99OysGCW4UhxN75wMsaJJIlYe0xS3FPc/vnJ4mI099Hqn/ydlf9aMymGjQ2fBHZLWE5HwRbhAwdt2ftUsuk2wBHJqbjYXX1VSLIQdYNJcYO/gcdkvFepEYusSaaGbc9ZraneUYvnp4szbBDlWZ77xIW9LjtVV3LsnpAPDZClSzNusNNRM0tsDXxvfRTWE9d9609z5CFOKwScmbo9WU9mXq3J/xRWQJmikkhmp8YJLfmbQ/X3LL2QvNX2C7DVTaaSPMAN3E1AYh9HrafjTYLbEFrncgMOO+rB6EnMyo7f3rAO04CfUUq/yphNocX4Wq8Wp3XrPuq5Rbeqi2CUoIvq9gH4Whn/ehIfqjZMyn1MQYkSb2+0mvjyXhpDBZBG62yHhTsFGVUMnrUGVUsbdj1vReJn0VeOZHjPbppdWqN1bq82hOOzVpiCsIHMblLiPaKBM8RPmAk9dLf88B8uvBe7C+4Q/glDI1PrBnwV1YQ3sO6YRvXWxeACGBlXFUN+V83vzcvgy1vZd+SLDaStymIa+EF6Q== 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)(366004)(39850400004)(376002)(396003)(136003)(346002)(83380400001)(6486002)(8676002)(4326008)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 6v/rBo5Vp5dpp92LXx1VY3BpQtTMHcYfQPhmni26EfCPSbDO8I0nlgALJEpJsKU9Qvog63Nf/Iye0qAP55S29ttLWsrek3aet5aHvQtmoz8IjYcKDplSJS6uJoyp2iFHBM0oMAhadk3XyXCB2Z8OCHTCz4r/LrQXiulETxZ1iS38hQZ5BvCeVEJlQHRKCtkueCTSDzMDO9ySZDUgLZhWW514NCjYI+vnDWMqETMvESi0z/qcEhRcs3yUuEMCthzj/S0jq19cGVj9bFLXAnwmY845wXhO3jEValDVA2TEZmXVUJMDqCtdOxjTOi6X2d2tzcnNbENyXKJYOw5i71jKKy2/JKu3SgQiErGtXqbHF1hfrpaEvzMnaFjdsgFM/dBd/1KdBfOmQRYLOZ3aJHeNh8xsi/3omqebZBTl+RzpKVJBnlEEFCQpONVnngqY6Sp3ql+yMgCZ0b0N6EiqhpK23Eqmd4B/J2qpIEAUYKLHdCBBqSAhKDGFUrAFyWRgzkDf5ECmWdbqilIpQbLoyc/7ksazzK04HJjAFIu0jZ+OIgN6C/ml3GJI8nepDnYLkcSY3RqMb15F/AKAIoRdnxlqN199maUMjVu5RUWEigOvuPY/szXXlml0hy+dc16cmhnDk1iW41kvc9N+R/Owh8930KIOv0xghvqXB8PlkdQ2hNwmTYmdBj2tSRe/iHg8wbxTxltBx6przloRA2+yhQXKt7qet6ev13knUV5NAUSYkdZAg0BM8IOSWU14ZipD192NvqIFiOZ41P3d0z0IJRAdl1ce3c14/8IUN0Bu0tM1+IKkCZ+uGDMo7HpG/19S4Gm2xe3JU89iB+3IfryOiAU59dD5D5uarElOmXalEJSMbzEh7WZ8urQPXYuG+uopOmRFfquZ9N2Tb2Z5TVFHVYpAwUCvUTNKMXM3vlFZLONu20thxCmeg7Jym10ypJGspiDHOvEvZbPB4qp08cAtRVpVXUjuJMnd+fvIrJedmpUqDDN+TN9twX9CR5TF7zTnikpd X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: AM5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 19fefb60-89db-4d42-da7a-08d8bbcda42c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rUAL0AGguqnFLzeBJj82SohZdAr2wt3NVkciAwM+i+UbzGltlIn+J+GKMAQwc5xhNGTg/gmCi887WO2YiMT8pylUxldaoLAassVvMrl0d/Cag/RzBmzGhbwx/aEmnKHQZoB2RXXEdlz1pP4R6E9typGmX3nv7wz+TM9uKy8ckdH0ayHvNbI/XEwRaKCVpHcSzWIsbkNNX5kyCJ8/mdISIFEth+NrmLYUueIggXHEvOJ1A4zlKFtG4VKNzQRz+CSZ7jhWvUDONq0R6WnQ81eRZBxn7gvQH1egu0pTHclme/g9r0WFDWzT1p0XpFqrwDyIccMe10HiHswRDJzRvOfxbrBgEIZoNdKrOWmQbZuhx7UMWSMHmjq4zZNtqQ2xQKsE+A+Sa14mJalqkAQA2aOm6Eq17OS8DEXzwfK7dWoFnsaljWjtv2Zi0I/Exv/1i4b05lKB8TwOvf7WwuJdTme5ejHHs9N3GLLRGUj5romPZNeiSteItdsxcWU3byIq7hE0kXBjNacthsXp/Fso8ReMlMn/eLk+JVXNDFyMzrMWWwiJMkvYAPAbYf4oS+fdiFZe 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)(346002)(39850400004)(376002)(136003)(46966006)(5660300002)(81166007)(8676002)(478600001)(82310400003)(6916009)(6512007)(69590400011)(2906002)(47076005)(26005)(316002)(16526019)(70586007)(36756003)(336012)(70206006)(6666004)(2616005)(8936002)(356005)(186003)(6486002)(82740400003)(44832011)(4326008)(86362001)(83380400001)(6506007)(107886003)(34010700045)(956004); DIR:OUT; SFP:1501; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:25:56.6251 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd3668bc-eb0f-41b7-fc70-08d8bbcdbbd2 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: AM5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6550 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: "H.J. Lu" Since __libc_init_secure is called before ARCH_SETUP_TLS, it must use "int $0x80" for system calls in i386 static PIE. Add startup_getuid, startup_geteuid, startup_getgid and startup_getegid to . Update __libc_init_secure to use them. Reviewed-by: Adhemerval Zanella --- elf/enbl-secure.c | 6 +++--- sysdeps/generic/startup.h | 26 +++++++++++++++++++++++ sysdeps/unix/sysv/linux/i386/startup.h | 29 ++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/elf/enbl-secure.c b/elf/enbl-secure.c index ffd7938605..9e47526bd3 100644 --- a/elf/enbl-secure.c +++ b/elf/enbl-secure.c @@ -23,7 +23,7 @@ #if BUILD_PIE_DEFAULT # pragma GCC visibility push(hidden) #endif -#include +#include #include /* If nonzero __libc_enable_secure is already set. */ @@ -35,6 +35,6 @@ void __libc_init_secure (void) { if (__libc_enable_secure_decided == 0) - __libc_enable_secure = (__geteuid () != __getuid () - || __getegid () != __getgid ()); + __libc_enable_secure = (startup_geteuid () != startup_getuid () + || startup_getegid () != startup_getgid ()); } diff --git a/sysdeps/generic/startup.h b/sysdeps/generic/startup.h index 56c899a65e..04f20cde47 100644 --- a/sysdeps/generic/startup.h +++ b/sysdeps/generic/startup.h @@ -19,5 +19,31 @@ /* Targets should override this file if the default definitions below will not work correctly very early before TLS is initialized. */ +#include + /* Use macro instead of inline function to avoid including . */ #define _startup_fatal(message) __libc_fatal ((message)) + +static inline uid_t +startup_getuid (void) +{ + return __getuid (); +} + +static inline uid_t +startup_geteuid (void) +{ + return __geteuid (); +} + +static inline gid_t +startup_getgid (void) +{ + return __getgid (); +} + +static inline gid_t +startup_getegid (void) +{ + return __getegid (); +} diff --git a/sysdeps/unix/sysv/linux/i386/startup.h b/sysdeps/unix/sysv/linux/i386/startup.h index 3eb4cc43a2..dee7a4f1d3 100644 --- a/sysdeps/unix/sysv/linux/i386/startup.h +++ b/sysdeps/unix/sysv/linux/i386/startup.h @@ -17,11 +17,12 @@ . */ #if BUILD_PIE_DEFAULT -# include - /* Can't use "call *%gs:SYSINFO_OFFSET" during statup in static PIE. */ # define I386_USE_SYSENTER 0 +# include +# include + __attribute__ ((__noreturn__)) static inline void _startup_fatal (const char *message __attribute__ ((unused))) @@ -31,6 +32,30 @@ _startup_fatal (const char *message __attribute__ ((unused))) ABORT_INSTRUCTION; __builtin_unreachable (); } + +static inline uid_t +startup_getuid (void) +{ + return (uid_t) INTERNAL_SYSCALL_CALL (getuid32); +} + +static inline uid_t +startup_geteuid (void) +{ + return (uid_t) INTERNAL_SYSCALL_CALL (geteuid32); +} + +static inline gid_t +startup_getgid (void) +{ + return (gid_t) INTERNAL_SYSCALL_CALL (getgid32); +} + +static inline gid_t +startup_getegid (void) +{ + return (gid_t) INTERNAL_SYSCALL_CALL (getegid32); +} #else # include_next #endif From patchwork Mon Jan 18 16:25:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41752 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 56D61388C022; Mon, 18 Jan 2021 16:26:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56D61388C022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987183; bh=a8noJ/CxNzPAJZ7mQ3fA/tA9+XDOvYiygNvTFIWwnVE=; 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=P/sUuj+w015NAWeA8TJ/B553/7Esq2tNt6qTV8DFCfC0DSfpdcRcSVypMttSxCc9+ R7X1rr/F7ZnCJ+ziA+HXOLF4sCxFHivxuStRmp7ZtMG3vcE7TuoOXWQ6zbVYPs4TnT vkupnCIxM7+VvST33Vuj+3WZ8N5tvFweBNkG0fM8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [52.100.19.12]) by sourceware.org (Postfix) with ESMTPS id 38655388C01A for ; Mon, 18 Jan 2021 16:26:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 38655388C01A Received: from AM6PR01CA0062.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::39) by VI1PR08MB3997.eurprd08.prod.outlook.com (2603:10a6:803:e0::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10; Mon, 18 Jan 2021 16:26:18 +0000 Received: from AM5EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:e0:cafe::96) by AM6PR01CA0062.outlook.office365.com (2603:10a6:20b:e0::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:26: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 AM5EUR03FT025.mail.protection.outlook.com (10.152.16.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:26:17 +0000 Received: ("Tessian outbound 4d8113405d55:v71"); Mon, 18 Jan 2021 16:26:17 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 42b85a8277846d30 X-CR-MTA-TID: 64aa7808 Received: from 3fd372ec92e3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 28240887-0B7D-4CF7-8072-60DE2DEAB3CC.1; Mon, 18 Jan 2021 16:25:40 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3fd372ec92e3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:25:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ed21z6gl+FS9QZ8MPfe3V0LAk1MigNP4UeduZUNUUev2xF5hQy6Wagc0dz/xnfYmVylQRZIibTPhWflRWUMS143VNMMLiyItuLe1vCh5K4OjKYqcb5Ze/hjZ4MSW/N7cz7hSobSbwal5iPhiTzhAKJW+a+rgrNB4/7FkZALiFwkAgZD9IOszbSLUtwT1n6N+YrvPyZhPo24Q8wUHqgJexVmm9akrgsknqfgjeDR2I706Hp+dOb7ZkkOtWYTbRulinNXLQQuTQpnXch8X48hPl0VffkLWTq0EAWTTzOFO92OJM1oNTH150KjMQ7mqL6cWH0gavm6Gkf+YEi9GNWNnow== 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=a8noJ/CxNzPAJZ7mQ3fA/tA9+XDOvYiygNvTFIWwnVE=; b=LSktN2iW5/YMwTq1fmoQuqltPxCuC1V6j1qtsAZ/6uYBugTottmGZCEkGTipSYEq3TTtBfRy9Mla7LfKem+8dydeL2cCmz01mgT1Wps2nKdbQuYkTWPuRFwCBSlkHoqbXiRWS0gOjLn0XJW1t2cUzesZoKypggZlelxqgTJ5iO1V9b+ij4TFNIO5HFnjo1xDEhK6Hr5dZyxhUAQ8B13V6/cQiLsbGVude28SCm5kMozcnucsRgQSFZOXfYjgHqARqZ30TmORjVlxzihI5IquLxrRRBbYkgxnIW+WQreD/PKQzX8b9Ek77em1HM6o2niDaJBDYo0g1oA3djF2X08GcQ== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:25:39 +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; Mon, 18 Jan 2021 16:25:39 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 08/10] csu: Move static pie self relocation later [BZ #27072] Date: Mon, 18 Jan 2021 16:25:28 +0000 Message-Id: <4224b7c0428492696fe6d6c01739adcf69fc677d.1610986541.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: SA0PR12CA0030.namprd12.prod.outlook.com (2603:10b6:806:6f::35) 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.54) by SA0PR12CA0030.namprd12.prod.outlook.com (2603:10b6:806:6f::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:25:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0f748f70-bae7-4654-62f0-08d8bbcdc863 X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|VI1PR08MB3997: 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: KwEPsjn139mnnMBNcQwE1EHoikwisDMLUrGlxhJwxuoLbcbzPXJ0IdHTb4zkU5+sqXjphg2AqnyYMSkcLeiJs8JOx4nH/KuklEBrrnzafaSyN9IuJg86Vg7Vq3DBqnM7nF3FDpyOdwtlRufSv6lnX3xa+nIiCK8zWe0qmLicPcRgtrr9dix1HGvS8GnqV4M894WPp9wprsVaBCeaR59wxnJSUcqfytPXf8NXFZcGWJigVYJln6w25CdIN/u0cWxL0LKkLAhPiniLjZm4z7FflmW3dF569RxmXaI/p7qCd+du+6WvCxy4lLAV85FLQrRVtfcYieAg+ZFKDc5b9S/0PbhYT6rnXY/JOEDUNzs+JGy/mBKqVjpbpkr7qofMrB99JLRaACUjkxNiRk/CvaFCLBbDAca9hMFlnjxIXPidUQI4gK3cSvVfP/z2msPmn1MDsHL9YTdY4Dyk6SiqlsQzNpDmUUfcpicDStw1smJFxA0qMVXWGWX0ELMQQShPe5hXmNPCPsNsUba+M1prPuB1ts3oAsitIAlxidOtG5pJ+s374+afQVGzLASj7OdKJHwZNLJFNjPnpRuwc5U0TseABQ== 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)(366004)(39850400004)(376002)(396003)(136003)(346002)(83380400001)(6486002)(8676002)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: BDfwOvgtqk2MzLjkYZY1I8Cwu+S/f5chtQXdqnc9DyEO1KVypO/PgtF91ERIgOtaHC3DofTqJ9b8PEgUitwJRF7ydtiq5/FQkruOs8WNEOeKFA/bJ3NYwyTZeZS5IcpXWk/o7MAYNMbW8bLsYDU8YIMV3N6IAkxcsWzLUmoka3R8e0PQtMYbeN0I5goiDsYo0ifD0NEzmH7DuimlTXrpv8+A3U7s+wrVMzHmXX8a+0WViM4DbKqTO8SFNMCxXJUHWTaINjt4ut7yz5eemirhWa5YbF3Xo7QQglzVx5uVgcQSG+nNOmI4/JtuvlWgzxzuLLOAEp4noMtvBO85UA+gLGR+8t3mLwlDSU9s3AT6MNyc5BJ9z4rDmDbENfkn/Gbpen/+7cfmA44aZslb/4cuf1SEX/xSvrwD/J0aqw9mY2q111m7+BevKI+J5faDNHGkIBvQrkJVVT/o2de/Q88i9XigVow2q1RfK/40V1PScUwMYQCCCLj+WMuFkSZApkKtPaeiCFdzRGSslsz8bMF2whePUKN7Am04VAtC5bDvgGepnjx9R+VxzggEJ2GmIA5bozBbz8FwbuV1wG73EVn/Rt1241l3FXsTMVJ7BTFNUsBYEYszr7kt6HI8aCiopsahozQnN1x0huRDhiG5RBa/q1i9Q4BnxjRJdviYU42sxmk5jnzTfMSKsYTUfNo1oe96xwr9so9tcYbE31DJbppZ/lglxkf+91xuCx7mhpD6UJjLnMZMf8wE0egDiXIcbvxxcWTPZvjSsuN5UyKw1xdCThSa1nYni+pE/O/0tbxAsB5+uHuUGuYlJIXQenOloUSMJxsMMH/4C/r0radT5m7t1OWRVpuT1tr9t8ckWDIRDTDTOEaXYmIFUVWzSnzaT+QdVr+dVxelZQnsFTezUN37cBUdl2q6wP9hM/XQU7i/gPXSCzAB9RI860a/OjO+1pNAZFN5ErtdVGpMYjLYJgDGJiojiXlXdVOP5B7WMakVliRYQox87EBVrneyVEFe1CCa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: AM5EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5e0829fe-2dfa-4099-c67a-08d8bbcdb165 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ifarzTZQmMCTt+Vy+1phlDci1ViChAypcx6UlKqGhtuFDkHK3g9msdjUVuWenipBpIsOVrNZFwlz6D4X6ysrTDxvK1WhRSwvDOOtEZ31SvbwLzwpjmvfiOIqjaw+X4Xn4MeUVW+O0SiNPezfUfbR+rwstDuTa3XbR9f4j1U1UMoxZT0QrGwWgEexCH34+JKq2yJzocoChiFUcmeFTJD1pkHoBacMVfC1t2u5YY7laInLtDVE3eZg7TiiJHSPs+WmYsfjvnIfRVUmzh6GS/azCQIDj+LAHx9OtBNlFIHnckkoWDFwy4z00SDQ61dcrCQfnu7DwZ9ugyj9H7oM4CEmfsXHsAj+M3sHsH3MzZwcA647pTA0q5HCYTCtzpr1FygrYh7jtg8SuXRkoIX7rqOwXbTybuyUcsG1A4pHn3QGzK82DEsIk2ZrTI/LvEgs5vOlG+BbB0N+iPGWj2fFpj/114hgPfXjyeFpGWju+GhOQBHsuUWN8TkD2UpIV7Mua29l 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)(39860400002)(396003)(136003)(376002)(46966006)(70586007)(83380400001)(47076005)(8936002)(5660300002)(26005)(86362001)(69590400011)(70206006)(82310400003)(186003)(81166007)(34010700045)(356005)(336012)(16526019)(2906002)(316002)(478600001)(6666004)(6916009)(44832011)(2616005)(82740400003)(8676002)(6506007)(36756003)(956004)(6512007)(6486002); DIR:OUT; SFP:1501; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:26:17.6761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f748f70-bae7-4654-62f0-08d8bbcdc863 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: AM5EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3997 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" IFUNC resolvers may depend on tunables and cpu feature setup so move static pie self relocation after those. It is hard to guarantee that the ealy startup code does not rely on relocations so this is a bit fragile. It would be more robust to handle RELATIVE relocs early and only IRELATIVE relocs later, but the current relocation processing code cannot do that. The early startup code before relocation processing includes _dl_aux_init (auxvec); __libc_init_secure (); __tunables_init (__environ); ARCH_INIT_CPU_FEATURES (); These are simple enough that RELATIVE relocs can be avoided. __ehdr_start may require RELATIVE relocation so it was moved later, fortunately ehdr and phdr are not used in the early code. Fixes bug 27072. Reviewed-by: Adhemerval Zanella --- csu/libc-start.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/csu/libc-start.c b/csu/libc-start.c index 1e90dcb0a7..c2b59431a3 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; @@ -169,24 +167,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), } # endif _dl_aux_init (auxvec); - if (GL(dl_phdr) == NULL) # endif - { - /* Starting from binutils-2.23, the linker will define the - magic symbol __ehdr_start to point to our own ELF header - if it is visible in a segment that also includes the phdrs. - So we can set up _dl_phdr and _dl_phnum even without any - information from auxv. */ - - extern const ElfW(Ehdr) __ehdr_start - __attribute__ ((weak, visibility ("hidden"))); - if (&__ehdr_start != NULL) - { - assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); - GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; - GL(dl_phnum) = __ehdr_start.e_phnum; - } - } /* Initialize very early so that tunables can use it. */ __libc_init_secure (); @@ -195,6 +176,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 (); @@ -206,6 +192,26 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), hwcap and platform fields available in the TCB. */ ARCH_APPLY_IREL (); +# ifdef HAVE_AUX_VECTOR + if (GL(dl_phdr) == NULL) +# endif + { + /* Starting from binutils-2.23, the linker will define the + magic symbol __ehdr_start to point to our own ELF header + if it is visible in a segment that also includes the phdrs. + So we can set up _dl_phdr and _dl_phnum even without any + information from auxv. */ + + extern const ElfW(Ehdr) __ehdr_start + __attribute__ ((weak, visibility ("hidden"))); + if (&__ehdr_start != NULL) + { + assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); + GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; + GL(dl_phnum) = __ehdr_start.e_phnum; + } + } + /* Set up the stack checker's canary. */ uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random); # ifdef THREAD_SET_STACK_GUARD From patchwork Mon Jan 18 16:25:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41751 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 C2A07388C011; Mon, 18 Jan 2021 16:26:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2A07388C011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987170; bh=5OVDezr3l+N/AdHBcKN09mbGUiBlkM7sM1TI8QaqTKc=; 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=COPJFHVNVsZpYZJ5+geSgrxmQdC9sLzCYq8xc0A1nGENWbwFs2QEdMcSwn/DHgC81 CK2cEWaVY8stHIs1bug67Vn2d7M5q0bn2IjR4EsKNJd/+MGL/jgNYA1HuTM7Z7VdFw IhJjAFNEuE5/3GhwJEkZo/RSs8VK+U6IzLOI1my4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04hn0219.outbound.protection.outlook.com [52.100.17.219]) by sourceware.org (Postfix) with ESMTPS id 69563388C011 for ; Mon, 18 Jan 2021 16:26:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 69563388C011 Received: from DB3PR06CA0013.eurprd06.prod.outlook.com (2603:10a6:8:1::26) by VE1PR08MB4816.eurprd08.prod.outlook.com (2603:10a6:802:a1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Mon, 18 Jan 2021 16:26:04 +0000 Received: from DB5EUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:8:1:cafe::30) by DB3PR06CA0013.outlook.office365.com (2603:10a6:8:1::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:26:04 +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 DB5EUR03FT060.mail.protection.outlook.com (10.152.21.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:26:04 +0000 Received: ("Tessian outbound 8418c949a3fa:v71"); Mon, 18 Jan 2021 16:26:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5733c8db3015ce4b X-CR-MTA-TID: 64aa7808 Received: from 35e2a6aad8cd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3EE6D85F-5B52-48A4-9EA9-374E2C56E2B3.1; Mon, 18 Jan 2021 16:25:58 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 35e2a6aad8cd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:25:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iF+HqSPosrMKeinlxClz2A+gIaHPWiW4JviGjwzmbnAFbv2tFrhPz9mSS0zo/UHrwEXzVjo6VTM7pxJ7s9z7NzDzopRNRHqWqQlrlAC0ujEh3L9rQvkBEHWeSAo5p+wZth+5uaWylePT8A3F/rDeQ6AU+OZUBL8bbSsHg/C0NEtXOOk8y9jOWLT69aROVUH5DmFa0i/YS85SfWqCWHClKm2YVmVTaH75doxI7jiL4pDyhdK9v0M1w/nkuUcLqGDFavlN8vwsCyo2OpAvaATkJ2koYlHHNXi5XcTbpV6wYZoeHrU4NQSMRhK3ZLutyToIlPWZoLrUOwhLGhGFcZhCOg== 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=5OVDezr3l+N/AdHBcKN09mbGUiBlkM7sM1TI8QaqTKc=; b=S3e6dRxm3RuU7dw+BlVeZ6BUj5mdkXrqMMRVLodS8xuFiiVYHeN1EsJdP7PCAQVMeu65eGmDMg3VY5USWoWMXel0U7gO6ZcH5T/GorOi1kvyLyAQnOaFd2dQIPPEVpJvBelosnorwfQhx2z3CGPPcNWV6RCihBDe76YxmohKryclqidKG5lXEYMw1y9ILVFI3HGXcoCVVtcyp1RDKNlW8yqV1M2U8IWyCwvMEWRb4FJfwOez5x30U8gIUKu1p7CclvErv6Aqr//rjzKNA05oHcD92/f7gB2y8A6yWBIk2cezbaKyc+ddA7QoHoHXw7QCZelDucxtmQ3CY/Nm9E+/5g== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:25:57 +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; Mon, 18 Jan 2021 16:25:57 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 09/10] x86: Check ifunc resolver with CPU_FEATURE_USABLE [BZ #27072] Date: Mon, 18 Jan 2021 16:25:50 +0000 Message-Id: <9d9d859c0eb4060d631832291f927a9d8d9b52ba.1610986541.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LO2P265CA0226.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:b::22) To PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.54) by LO2P265CA0226.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:25:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6a6afbe4-2f0c-4529-1cea-08d8bbcdc032 X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|VE1PR08MB4816: 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: KIwH1ku7w/5S7e0QVEM4xOklF1CQ1jPYlBw1W3dqQGFTl6ER5hIkq3EhIhvue3MX7FT5lTkEpzXSHUusWkt0hXRpMRx+P3i4PUHCNuukyztbmqg++h4zavjlwCIFGtMERlZrHbjfRqj8pzYpUFmXs/s6+oimXThwQWx/fCd6s5UnKoN8plTcLL01xAdCQX/iwR9kJ0A2YaBFFu0Qv3xF+PvKuwjzIkC9BYqdcARypkDfPiWIXbxQdTT+ujRr+PYaHlVp5D5YY5/8DFYFpCM6HxlKOGnctjDTxc+0xhjUbql3qUbrWR4oymZYMolJQuLzdmwn/JxIXprx95SQNcDqLa20y5b4AW6BRfAHjISyJmIEsSWVT/IC94Cg4XhgtVmuhuBAnlvT0FVsZm3OpH4k2jBaI//PDWRlk/EiyuiNY/vtiZ3m2aTP+h7dkqT1y5KIJ+47tNPRpY83YdFmWw2m5SODHJ0jPOWDaeQXWQtOkCI7luJFL1s1mJV2We7E1aR/k0Nb2b4pCmTvgqZPBv72eoC1QOJdp3l0YHt42IiNQZTA4Eus7cPEvd2CthrRbXTqdObPpGa8sS3irPRXuuL9HPwK9b52mke1OZKjHvon+Ja9iDiT3T0i3tLBpP5WQV/BcbEZgIc7KRDd53l3/OfET6Gpn+RM+6v7szC7bCfWTcqbthyvzBOnt2RHfLrAr3Po 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)(366004)(39850400004)(376002)(396003)(136003)(346002)(83380400001)(6486002)(8676002)(4326008)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: XVicQYAPCgDL6+x4whpQORSPsHljw87FOrBLJm28ub78taqMayiq37aqgBbK32RXADZMGBPhKCHiLa5fPLRPqa+QHMwc8vDEqaK0KJoZ7cJG7cojnGDeN6/ki2P6ydnB6zITUNMSmA2uJ/C7go3kdBlC/IcTPqPsfSz67Jx7UYfl4KoYi51EFcTU1BiQQ7LL6X/EYZO74qu1+Zo7oEIwtGMhYHeeKyj7UMbklagtHYyHJ4jYydOHciPI2IPxbGxdUsQt2e1ElH/xlt4Dsb15YDP1TtQQb6o4sp0pKHmA0QjKskRl3h3qXqg0Z7LialArlZR2reRHFU8Dryze5HhEqt2No2l3SHVPqciAbW/xAKb7YGHbVp6wpHRlR8Yj89SZpAM2rFap5TB2IxINz54l23E7k8KQ4hriQ5jAviatp3w0dH/c+tuho3PWKEKPXdEeEvtRSLBG0sHOnxQuvDyXMfiFtgFl6LkzRXKDSbNC+QxXtq9+k2K6elajOL6lxQ4mf+vSTvdK089Ekj1Q+r5yUpDDqlxxxbFZE6aRfIUVcwHqBvIIBRV/Z+7HnsQwYLlW8Ygo7/CJzwoneTK281mSH18qLtNMjgpzTSCoMzq+hNzCCaZOTLMO82DeKPC4VSOLIjsNOIdm88wPnGQEcX71AKsHhV4L3NqxJKLiQ09MkQkgD8JpUvURjGJFYjHGxt8Fd813p2N+1ZkVflTtEd248xdixo6Y8xtBFimA4ztewtP/15ya7hqmzo2++xTaBCMvFNTYhdffG3T5PwDqhRFABseaRFi55q4Nyj7bIqf8pXT8bH15pbhC7/LS//DLEOiEkRMkVe7e0TY+Ygxu7wgyQ9L1SM9IArXQ99eASRtzVfcPpNJUBCKH2kHvwbx6YIMBv4lU8IHNiPBtPUn4g/45mDu+4c1MnR6TKZ/OI7SOUdKUpTGevDA6LmeL3serL29EvV2cH65WkaA7kXzJMTqaaSyTuKQpQSY3vbB3IdmLKcPXMyOBkJ0nopbPClQ603ms X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: DB5EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: d38fa198-7201-4a19-e5a0-08d8bbcdbbaa X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /55fX7goKbeDBswSm3OneNq5/28CBIfFt4Oo+2cDF3aXFA4J4pIB2GhQdNnRXM9dOxNVVQ0/uraXmSExJP/KqjGBDTBHZzmbEcHMAUr6tRyLNUZcN2Tsy5Hkx8zfoDsLWa5rhPEvoP+UaELkgdIoiNMz8OrDlHC4eGkyrn4Xb9myuPBfx5KVlv7D5FbRFgjgsD7uKeUr3jbsUIVt/zMelCFC1ww4kMMmDD7x1f5jPIwlXxERXU1kzDqYlRSYIelMuM0zvDBJ2SDUkcuRmQk8YzND9dMN3zgVLRSyq/dKFecFivRNU9eJ04nOIpvbwzXUssstmQXGqvfzYtyzRzc275MyEgVJfbc+4UCX3XHBFqJJvmqXJwes6Se+mOPZ3KDqff6a8YEw4mdbvcqGstfYN6yCHn0spFCL6KGLl6VIbatxLYO6rMIsceT3PD0QGsonFQ77KAFhQJVyiqT5//hTWsaYc90e8OMWFn5FQGgko2bE6dPRX8C2g4Z4/GqDuaoz3a4vnGVsnZ+iwP0uWq1PFpknUHcDQepqS0xHtRZlKxJ6949duoH6axmmlHykgEnAVoPlRsyPVWrii0S7zui7K8wP1+BeF72boMJmQMaEpVo= 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)(346002)(136003)(39860400002)(376002)(46966006)(6512007)(82310400003)(316002)(26005)(336012)(186003)(16526019)(107886003)(478600001)(69590400011)(356005)(2906002)(6506007)(36756003)(81166007)(34010700045)(4326008)(86362001)(47076005)(44832011)(83380400001)(70586007)(6486002)(8936002)(82740400003)(6666004)(6916009)(2616005)(956004)(70206006)(8676002)(5660300002)(2004002); DIR:OUT; SFP:1501; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:26:04.0054 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a6afbe4-2f0c-4529-1cea-08d8bbcdc032 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: DB5EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4816 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: "H.J. Lu" Check ifunc resolver with CPU_FEATURE_USABLE and tunables in dynamic and static executables to verify that CPUID features are initialized early in static PIE. Reviewed-by: Adhemerval Zanella --- sysdeps/x86/Makefile | 14 ++++ sysdeps/x86/tst-ifunc-isa-1-static.c | 1 + sysdeps/x86/tst-ifunc-isa-1.c | 115 ++++++++++++++++++++++++++ sysdeps/x86/tst-ifunc-isa-2-static.c | 1 + sysdeps/x86/tst-ifunc-isa-2.c | 119 +++++++++++++++++++++++++++ 5 files changed, 250 insertions(+) create mode 100644 sysdeps/x86/tst-ifunc-isa-1-static.c create mode 100644 sysdeps/x86/tst-ifunc-isa-1.c create mode 100644 sysdeps/x86/tst-ifunc-isa-2-static.c create mode 100644 sysdeps/x86/tst-ifunc-isa-2.c diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index adaa2a92cd..f7969309bc 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -9,6 +9,16 @@ sysdep_headers += sys/platform/x86.h tests += tst-get-cpu-features tst-get-cpu-features-static \ tst-cpu-features-cpuinfo tst-cpu-features-supports tests-static += tst-get-cpu-features-static +ifeq (yes,$(have-ifunc)) +tests += \ + tst-ifunc-isa-1 \ + tst-ifunc-isa-1-static \ + tst-ifunc-isa-2 \ + tst-ifunc-isa-2-static +tests-static += \ + tst-ifunc-isa-1-static \ + tst-ifunc-isa-2-static +endif ifeq (yes,$(enable-x86-isa-level)) tests += tst-isa-level-1 modules-names += tst-isa-level-mod-1-baseline \ @@ -39,6 +49,10 @@ $(objpfx)tst-isa-level-1.out: $(objpfx)tst-isa-level-mod-1-baseline.so \ $(objpfx)tst-isa-level-mod-1-v3.so \ $(objpfx)tst-isa-level-mod-1-v4.so endif +ifneq ($(have-tunables),no) +tst-ifunc-isa-2-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-SSE4_2,-AVX,-AVX2,-AVX512F +tst-ifunc-isa-2-static-ENV = $(tst-ifunc-isa-2-ENV) +endif endif ifeq ($(subdir),math) diff --git a/sysdeps/x86/tst-ifunc-isa-1-static.c b/sysdeps/x86/tst-ifunc-isa-1-static.c new file mode 100644 index 0000000000..0e94f6119b --- /dev/null +++ b/sysdeps/x86/tst-ifunc-isa-1-static.c @@ -0,0 +1 @@ +#include "tst-ifunc-isa-1.c" diff --git a/sysdeps/x86/tst-ifunc-isa-1.c b/sysdeps/x86/tst-ifunc-isa-1.c new file mode 100644 index 0000000000..b3bc2a55a2 --- /dev/null +++ b/sysdeps/x86/tst-ifunc-isa-1.c @@ -0,0 +1,115 @@ +/* Check ifunc with CPU_FEATURE_USABLE. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +enum isa +{ + none, + sse2, + sse4_2, + avx, + avx2, + avx512f +}; + +enum isa +get_isa (void) +{ + if (CPU_FEATURE_USABLE (AVX512F)) + return avx512f; + if (CPU_FEATURE_USABLE (AVX2)) + return avx2; + if (CPU_FEATURE_USABLE (AVX)) + return avx; + if (CPU_FEATURE_USABLE (SSE4_2)) + return sse4_2; + if (CPU_FEATURE_USABLE (SSE2)) + return sse2; + return none; +} + +static int +isa_sse2 (void) +{ + return sse2; +} + +static int +isa_sse4_2 (void) +{ + return sse4_2; +} + +static int +isa_avx (void) +{ + return avx; +} + +static int +isa_avx2 (void) +{ + return avx2; +} + +static int +isa_avx512f (void) +{ + return avx512f; +} + +static int +isa_none (void) +{ + return none; +} + +int foo (void) __attribute__ ((ifunc ("foo_ifunc"))); + +void * +foo_ifunc (void) +{ + switch (get_isa ()) + { + case avx512f: + return isa_avx512f; + case avx2: + return isa_avx2; + case avx: + return isa_avx; + case sse4_2: + return isa_sse4_2; + case sse2: + return isa_sse2; + default: + break; + } + return isa_none; +} + +static int +do_test (void) +{ + enum isa value = foo (); + enum isa expected = get_isa (); + return value == expected ? EXIT_SUCCESS : EXIT_FAILURE; +} + +#include diff --git a/sysdeps/x86/tst-ifunc-isa-2-static.c b/sysdeps/x86/tst-ifunc-isa-2-static.c new file mode 100644 index 0000000000..4a5af9a270 --- /dev/null +++ b/sysdeps/x86/tst-ifunc-isa-2-static.c @@ -0,0 +1 @@ +#include "tst-ifunc-isa-2.c" diff --git a/sysdeps/x86/tst-ifunc-isa-2.c b/sysdeps/x86/tst-ifunc-isa-2.c new file mode 100644 index 0000000000..bb0f76c3e4 --- /dev/null +++ b/sysdeps/x86/tst-ifunc-isa-2.c @@ -0,0 +1,119 @@ +/* Check ifunc with CPU_FEATURE_USABLE and tunables. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +enum isa +{ + none, + sse2, + sse4_2, + avx, + avx2, + avx512f +}; + +enum isa +get_isa (void) +{ + if (CPU_FEATURE_USABLE (AVX512F)) + return avx512f; + if (CPU_FEATURE_USABLE (AVX2)) + return avx2; + if (CPU_FEATURE_USABLE (AVX)) + return avx; + if (CPU_FEATURE_USABLE (SSE4_2)) + return sse4_2; + if (CPU_FEATURE_USABLE (SSE2)) + return sse2; + return none; +} + +static int +isa_sse2 (void) +{ + return sse2; +} + +static int +isa_sse4_2 (void) +{ + return sse4_2; +} + +static int +isa_avx (void) +{ + return avx; +} + +static int +isa_avx2 (void) +{ + return avx2; +} + +static int +isa_avx512f (void) +{ + return avx512f; +} + +static int +isa_none (void) +{ + return none; +} + +int foo (void) __attribute__ ((ifunc ("foo_ifunc"))); + +void * +foo_ifunc (void) +{ + switch (get_isa ()) + { + case avx512f: + return isa_avx512f; + case avx2: + return isa_avx2; + case avx: + return isa_avx; + case sse4_2: + return isa_sse4_2; + case sse2: + return isa_sse2; + default: + break; + } + return isa_none; +} + +static int +do_test (void) +{ + /* CPU must support SSE2. */ + if (!__builtin_cpu_supports ("sse2")) + return EXIT_UNSUPPORTED; + enum isa value = foo (); + /* All ISAs, but SSE2, are disabled by tunables. */ + return value == sse2 ? EXIT_SUCCESS : EXIT_FAILURE; +} + +#include From patchwork Mon Jan 18 16:26:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41753 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 4DABC388C01B; Mon, 18 Jan 2021 16:26:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DABC388C01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987190; bh=lE19Zs5MyMreTy3y49zKv0Dscxf6balahUu15zSgLLM=; 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=siWM0fHW7iNA8aOgU0i8Sp9CXNW8zgjnP1gqucxWRigYsMyqXk0ItCkWVHU3LcA6m xgQGWRPC42EbrLK/oddAgGq/k360O4zM8COtH1eR2oLXL+EL5+ov3+KD1YnUzKHJLk wfjlvjoJzEgU8kveNHicuGFcjBcLv2HPA+OVQNxc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05hn2223.outbound.protection.outlook.com [52.100.174.223]) by sourceware.org (Postfix) with ESMTPS id E2C6F388C01B for ; Mon, 18 Jan 2021 16:26:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E2C6F388C01B Received: from DB8PR06CA0014.eurprd06.prod.outlook.com (2603:10a6:10:100::27) by DB7PR08MB3788.eurprd08.prod.outlook.com (2603:10a6:10:31::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10; Mon, 18 Jan 2021 16:26:23 +0000 Received: from DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:100:cafe::b5) by DB8PR06CA0014.outlook.office365.com (2603:10a6:10:100::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:26:23 +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 DB5EUR03FT007.mail.protection.outlook.com (10.152.20.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:26:23 +0000 Received: ("Tessian outbound af289585f0f4:v71"); Mon, 18 Jan 2021 16:26:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b094ec6810dbdbe3 X-CR-MTA-TID: 64aa7808 Received: from 85c6bb6f2cd6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A0BCFF5A-21C8-4C03-AF6E-D76D60641BB0.1; Mon, 18 Jan 2021 16:26:14 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 85c6bb6f2cd6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:26:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kTkprN6ZN3x/ADuIiRm1b1b9/0AZ0QFrk90oAkxiXVa093dBqHVR6sZfvvETsx4Jaiqfy86ASTH85oEch/E8bEup8LNBDTwpCrhh/Po92UcmyUqeWx+pU9xUfZpe0j3eli3VG21E1UGyueg0Zol+KSzOWpnzU8eNFhKarPrDRSPOEomnFZupZqnp3/mN9Aw7ZbfBxu4WHpEjn7dTWp/Egp04FqBbnVp2p2vGKSFpa8A+Vj7HyomD42BT0KnLaV6GfVXaOCPDHfgF3ouCg1k4Lxo092jHiT1arYerRO5clRL6lrkrwo1/bRL+4WLxTPdV4P42TBv+ZvHHbvfm1deaFA== 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=lE19Zs5MyMreTy3y49zKv0Dscxf6balahUu15zSgLLM=; b=Dc2yr1IPEc6f89KJgXTgjIf8pHnEItam7enq1WpDq8/JnXVvv7B+z+FC0S1g3+VUORdVz8n92wkPReZeStWYTRtl8+bjNA0zO5FKfkKStjGm5GIxJk82l0J1hsbKyFYj2Zx1K1omF3zUW4EjadDqoL38CLWNYbMy5f22nYDOfFEhcAPdmDnkE03uXzDQ+D0DGPUshmY97PL0bvV2xXDZP/4gp6kpe+u8wGXIOUieE0k/8VO26dryZzzymGPjh7W2r5kB+2aiDUFGfSL0KAUE/iOQ7NhbvUVMXxw/B7OCygFd9MnZwqH+qQ+L+dRAfWO8Pyb9ZO6hlSbF/49j6i5Qdg== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:26:13 +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; Mon, 18 Jan 2021 16:26:13 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 10/10] Make libc symbols hidden in static PIE Date: Mon, 18 Jan 2021 16:26:07 +0000 Message-Id: <4b939181155fc70ccb708530c1244eb0c2fafbef.1610986541.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LO2P265CA0146.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::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.54) by LO2P265CA0146.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:26:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4d32eda8-3e74-4e95-2a41-08d8bbcdcb95 X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|DB7PR08MB3788: 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: AbsG+uU3s9UNpexrKBlY1UCCKn7GGjx7SAirxGuI8Ez30LsW+M7VAb7RKRvKjKFM0FK4M5XiJnY5cAiqWkXF8Zs4SZza+qYh79RN/HNDlM9bj0XsdpZl84ompe652hwDt4IxqHBM6aBmUqPocEjv+qro1EMkE+hqh8fEriUK0f+wKqUWAWOvwJAU/hv4pBkfxQe99aDw437TXmTNzS0z+d5ijkXkV3cClUSwq2MID8jbwOeaVQ+f0Krr7GXpxFcDpEG2WjA3Kbxm22gXLAZcMyEfN77Ra2KaMF7zLZ/4+emXUb3q7ccpa4HGFolrobVO8l9+8QbZBu/EQDhSkpZ9lPnUCstOUNkgMtd64tgL9FDlmNbwlvb6lR7VrmY323khb05ZHVqjRKa0XV9+IBs7wutOq6C90QC9iFHtEiH3Gqe/W4A5Ug62TzLAutq4CfGGenPmUeAJHKFbc7PQH8GQDKzP8gt2PMFHJ7Eo3RnbarkJt3AIDSfBsKcpiNbB4glHU8Gxu5PiqCAKuxCH/8LzBRTewor/+Lkmx9Z5z+YAC7X3zQDVWDbB4nX5bDAFtOUy4CRf3gjpI5cF8jMBnG2jmg== 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)(366004)(39850400004)(376002)(396003)(136003)(346002)(83380400001)(6486002)(8676002)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: nJiaYovlZIUJOwV/jPz5LX499RdZodX5Z3GNglxCN9fWfGprJ0ofX5Dwi6Nwq5B0i24v0ReTvXx3PBi+l2kdcHtjQEldvPgFqDrjATW4DMcDg/scaxs1UV1y5IcUfMPNsH0uBkbg+mVOnX3JRI8WVlb97GBGbPi8VSJLz3agGkpJ9PwWVEKhEvHb0NMDyzrIvJgPu5cqTevsRq4sxI6py3aJtmluW/lWAgY5KYFx1tE8VxIIHu25PNAO1FJdFbqqffRX/PcROGByQacdgtVSwkFScRA7ukX1Vsmry8YhlvA2Ok5+R0l+S21oAvAKsOqOw8LaT6sfOhmWErLfFWDIadmuRmsJUUyh+m1zvh5drJXTERmhj1f62cPHcKMnq55mOGepUNopgU/t5mAj1V22F0YgsLiylKmPB+GO5r0sN+yiX2LzjHp+ouVnmdSJTGr20F9eUqJN3KGJutAf+Gc5czuIqYXPiu5EmoIshMCdwZtJbVgw2Q59+ARRD1OYzR4nkUi4jbUW/Pzj53ObLpC30GRtnv34PISjMRHHsvtm6pcPf0Bo0i8pcE2TvWxf/70/JVCtOg6hQky3D+gdFJwkdr1cYegrk+/YUiOpbDptMysTXojiEs9T97SBaIEVFIjDh5hLFvSz5JSeEZbHUuVn5+A5p0F9+Gon0pSqB/SS+L35woq/nwOuv5lb6lOIijGeu5cV2OehJKpe3XfgcwYvYFYdpxTgjzwFJmea5jFmbas1zq1sAOCtdfulKuHrgow9DVR76vnzavRbrrQ/MrKiiNK4tLv8wMnzjaXc/5Ngk77QMjoqAJAH2LIHgKgPwm+A00XGWWRzhoy1FRGFgSmND6/P1JfSBw6NBlr9qG1GxDUkiTFnWWSOL6Km5BY1y+399JjLaE60rLy0KLvOT11ehGkYOKOQv1URo0Lxb6IFlsrDl7xFjaTYIFKkUXbjrI4m7VQWTdHpva3Bo0jf8VyWwwcSRgqjNCTsbHVYQcxud0CXoo5x5xexrkcsrPpR2WfN X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4860572d-c029-4cc2-6b60-08d8bbcdc5d0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QJFO7ryPb9pB6tLU9YAmgKnez3hiLRnT+h5tuYaX4kVewxy+UQw//D6V8r3YGmao+GBWA1Ve+lQEez81xWlkK3uqZExwji1MxkPain4DoOuCWBuk4yxc2pgMSUeCg79SaNZNGwTXFqMVO1iD/tvGSGJvDMOYt5VhboNULGXKta2+DAotVIV/bVFbVq5brNbznRDbfjehS8JOVlr6vBHhoYq0WiMOU347sN5JRi0imP3TbyzTdeFsn1R5Gj21FD4xbDCStTmTTA1+M3amhH6itwanAl/7h1vCPNGZkyY7Dr65P4y+hbvBE4JrJsdTVM7Hsu76I4FZtPfBPS6WyrU1CQrDJU+opow/HsIiUuBcl5Cf6oskc3Y2nf33EUvMHJ8u7gUJK43FhjspxQyDZoccFetoUoch88ae3MC9939SZn8mnq1YzyRREkHriDfXdScvy4wJ6ipCasH9lKOWD5wGNb8BW9KiCFSnEaLZypqYGk+NzXQCW5Eo+cqp2uGkYju2 X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(39850400004)(136003)(376002)(396003)(346002)(46966006)(8936002)(81166007)(356005)(6916009)(82740400003)(478600001)(70586007)(70206006)(316002)(6512007)(5660300002)(82310400003)(8676002)(83380400001)(44832011)(26005)(2616005)(36756003)(186003)(69590400011)(956004)(34010700045)(336012)(6486002)(2906002)(16526019)(6666004)(47076005)(86362001)(6506007); DIR:OUT; SFP:1501; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:26:23.1095 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d32eda8-3e74-4e95-2a41-08d8bbcdcb95 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: DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3788 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_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 matters with static PIE: extern symbol access in position independent code usually involves GOT indirections which needs RELATIVE relocs in a static linked PIE. Hidden visibility avoids indirections and RELATIVE relocs on targets that can access symbols pc-relative. The check should use IS_IN_LIB instead of IS_IN(libc) since all static libraries can use hidden visibility to avoid indirections, however the test system links objects from libcrypt.a into dynamic linked test binaries so hidden does not work there. I think mixing static and shared libc components in the same binary should not be supported usage, but to be safe only use hidden in libc.a. This is an optimization. But on some targets (i386) it cannot be applied because hidden visibility PIE ifunc functions don't work, so it is gated by NO_HIDDEN_EXTERN_FUNC_IN_PIE. From -static-pie linked 'int main(){}' this shaves off 71 relative relocs on aarch64 and reduces code size by about 2k. --- include/libc-symbols.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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")))