From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2055.outbound.protection.outlook.com [40.107.22.55]) by sourceware.org (Postfix) with ESMTPS id 2E41A3843879 for ; Thu, 9 Jun 2022 08:13:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E41A3843879 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=EtAW743rGuTwP+4mAFZVWohK9UiXY9HWooA6q2oRIlwr1Nrl61nkBT/cEYF2ThZfZgJ2Y/NtfZWc6CtvgraB/+kuF+CM0q0k7EGc0DtFOz4TI3Seibc+lFdWdD/+cyqkToui6z0oPVobGzHRqyL//5o950iXIuwDOZKSh0uBiOpOIm0AzO4Pdo63ATLV4dL5Ri+/hnI6018QrlRb6cij+0O6YVKmAbLjP4xy2//L3mO4FwcRZ1NTKNKTqSyP5EgqG6EHLTZJKeWsjvN8GFuoYtkLCdkNcH+fcdJNT+Zh0+uhFG2yiqi7BgraBrMrZULhnm8O0mh/jjGyKFIkgtwXKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=duF04s4Jtf3V8M5VscoOnbLmjKRIaQ/EuTB417jKk2o=; b=bMImPzgiZgwWxXz3nAJNBSUht+DPg4J6GP7ylhSaEZe4CPlRHmaJMD6wxuwdYVDUq/8ngo5jqdtf7a+0bitlZ+YDDpnxZd7j46XL4LaF1iix3jyG8dy2biNK0RVliqWxlAwfHUZa/8F4EzhGTCdIv/mfm8EuPO6/ZhhwxJGmMsFJDv/YJUjqNMamY7iHzirGdlW+2cfxHjJ62FWPJAOGXN2XJImxpLqSITnpPUhp4rbovaj/chAdHTOsmL34ll8a+3gbfneFi6xabzqq6X8hXYCNNvMX1zUe8FWFOt8e4E9gdM6RyoK7s4sflwmUuCih3Nzwp9RgqczaYe+zOUyl5A== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS9PR06CA0416.eurprd06.prod.outlook.com (2603:10a6:20b:461::10) by VE1PR08MB4848.eurprd08.prod.outlook.com (2603:10a6:802:a7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Thu, 9 Jun 2022 08:13:18 +0000 Received: from VE1EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:461:cafe::c) by AS9PR06CA0416.outlook.office365.com (2603:10a6:20b:461::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13 via Frontend Transport; Thu, 9 Jun 2022 08:13:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT026.mail.protection.outlook.com (10.152.18.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12 via Frontend Transport; Thu, 9 Jun 2022 08:13:17 +0000 Received: ("Tessian outbound 4ab5a053767b:v120"); Thu, 09 Jun 2022 08:13:17 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 78bfad8fdc0549d7 X-CR-MTA-TID: 64aa7808 Received: from 2d83f728faec.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 29A22C11-A64C-4270-8B6E-614EC1A6A007.1; Thu, 09 Jun 2022 08:13:09 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2d83f728faec.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 09 Jun 2022 08:13:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EMSpjC2zKaXWbrLT3bMliVeUVqj8zA2caPvrVdfvBlrUd4USWyE9CELRd3MH7Rn5GtkDeLPbAm9theTsNRXLYF8Yp8REmvvQLUKOxrEMpVZpAg3AuXNoF0c93IbLOua0U8R09QBm5H0M6CqNbrEu905FgOQDptyh0D5g/BXbrmLA7aRfgwi4JbnzMR4Ey/rkjQQ29vva8PbgJCdg0PD+crliuvy6g8dMP/1PirvVVgswMvG2+rtwJtDlCNfEIzjZ09k8hgbQvaQsOIf6Q3x87589IkhQ76NeoH1FwDGoZXOWAjrkPPZ3PAfMU8ckQphDQypqFUmNpG3YBJMxVyMECA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=duF04s4Jtf3V8M5VscoOnbLmjKRIaQ/EuTB417jKk2o=; b=Dar7HXVfO9xQvew+zkgPy6ucSg9W2ToxlciYillE1/i0KCFg3BEtoIDTVmKZqJNeluppU6IQy/qLCCGA7ZERyQeoBZ2x5b+5ns/frh6ZiWs4kjjnldEgajVsVkAJCoU8UiuNXf1dXLFnBdIlc4fOyo4SLzdFZGgP4TXgOm1s5p5JNeud0SILJJ1NYZUlw0Av/vS8yCdEjigbEBg7k32U88C+PvC59JQo1ygjA8Zmvitkng0p0+d9RaSB4hXNPtdLC6ghIyWwWhB2u2DZIgpVWTIO494RyZzgBSX6UpvqoxQ7wrgpuahLE9voDe2OEBxc34EUuCM6zsOBgo2aPzWseg== 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: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by AS4PR08MB7686.eurprd08.prod.outlook.com (2603:10a6:20b:505::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Thu, 9 Jun 2022 08:13:08 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::9ccc:fe7c:19e5:bfa6]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::9ccc:fe7c:19e5:bfa6%4]) with mapi id 15.20.5332.013; Thu, 9 Jun 2022 08:13:08 +0000 Date: Thu, 9 Jun 2022 09:12:54 +0100 From: Szabolcs Nagy To: Fangrui Song Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v3] elf: Remove ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA Message-ID: References: <20220601175633.2407189-1-maskray@google.com> <20220607174917.56nvyqg7f5ish5ii@google.com> <20220608171643.k55emgjpvt5hxcwp@google.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220608171643.k55emgjpvt5hxcwp@google.com> X-ClientProxiedBy: LO4P123CA0565.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:33b::19) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 45755dbe-9c81-4ec2-9b1d-08da49efe8b8 X-MS-TrafficTypeDiagnostic: AS4PR08MB7686:EE_|VE1EUR03FT026:EE_|VE1PR08MB4848:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: wZ48JFOrEBwHnAS6HKZp1ysM1FMnr9VQpzI6NFhIN+XQBzc8guar1ZJ0N72pb4Hm9F7ZN+nH3T9gRoL0sbmdehwNQjWUUQcJf2uUHZ5FUvF/42gHbdN14psClGfbKXQcMJPU2GBQMYVJf2Q5hR/ULk1p740gjrLxBkxJYgo7zI04yVmJePl1oGLdy29I2UgiYa8wKRap2/HxnLbb/DS4nNIqDrCLfUnVivQAM11jGFgshqL4KQhuA728CiTWVLVlMgv25YwAPuWpZMoOdZ8tjuva5XZIwqI3YQQFBpqrgM5sOgGyYX57+U9aDh1dCnYd+ukfqBHEVUkqmHw2K5Xmge79/YkUOrZcXJzkrysF9Jjg/4T/smdzJsUBugctD64jWJxJI9TrPM8O/12HvG+oG2jW1bkQ+Zs89nctmNoBcwqY1eOS/Yc8+eRZ3SmJ6oezRUhhDCXxaCI57g/9/GvRMn5CUhw9Kp2KjqC/NMGzJk3r6/Us65ondF3gRrCx7GWZRmbNxJQCpOrbXjH8ig+8XETf0uwYln6uJT/bQv+y6KXLfGkW9zo89hslwcXLnFmNHtmFoh9tSuDTgMTdJ8i+M0uPiBJSq0hkEGGrb0uyj3c3AS9RsS4uNyIeL97WwSke2GBX+Dt/W6fEMgZ4wEUuisRZ8jjNuOA8VHMh5jihczFRbcKMxW300q0u61npxY2HqMyypzP9wDpP20a43v625s95iEw2s7JJZvU8Q/NkrLQ1Q4gHKRSxaVWgPwHwEjIoMkHC7Pq6koAQoVhraC/f0g== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB7179.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(44832011)(5660300002)(8936002)(966005)(6486002)(26005)(6512007)(508600001)(86362001)(6506007)(2906002)(6666004)(66476007)(38100700002)(186003)(2616005)(83380400001)(6916009)(66946007)(316002)(8676002)(66556008)(36756003)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7686 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 05f1c70b-b5bc-48a2-6dbe-08da49efe2f8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +f42mkC7SIabN+V3ybwxpJJdsdRpUpEMSZXvw7p8nZ8d7qGiM8YUMsd7ClUWj3WLprnFdHsZcx00c1jigyb5PlCz1fMD851dCer7T3SF3QUkZmWZhhdekczx1DBNrImDNDvahvJMvDXRn3zyuaaLD7kkyfmxnKoPZ2sILVHWPG8MPfyGg8d27vPr3U+bs7Yo9z98ZJJjIbjKUAgjPtyKTMVpu1bHge2KalG8UKrKZ+7HreMORWMsKCetG14QVoknK24/JS95AKFIkYJcototURnQP5TrdITzaUHLpRIDcGwQCqvi3ayFczVzkKaaENlWEcl8BqI7Gxawq0ChXCm9mw9ImoSVYQzm4q2sxevatxRYnQdhWWrgbP/H1d/43QwRbTVIMxje16nMHJM9/1D7gH5rNql4XtSFkd9OJ7tSK8EoTpgB1ETijjsQ0A2f7E1JXhqxJyqvBUyQkidpwuqpV9bNS4A+d0DxOcFw/K8hOsOiSAB64c0kr0Ctn2mLTQGE8HUQup+GceQ1NmiDxD1TlD+KVOJf3YrFYntaQ0P2taqbh87Wjl2jYrDEFEIJ7QfkEwNlSi9dmiEC/nQ2q9yLdPiY4PCY2t/4p+Qn4aX5Ewg34UHpIOIMRo/gjP4ueXFqSPlQSPDQUvPs0fD2AB4I+YnyIBECWlMSE/VbRfms/va1+myyfJv4Q8ULZmhrqyb/5guzSXRyF4+w+5P8EaZPMCs3vrynrFfZXwbvO/ljFPcZkLj4heio0a46K8RAx7HpPF31MySn8jOBbivUxNO8cs8MY1MGv5x2fLKa6AbzjOnCoDx7R++vskBbUrHQCQM3 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:(13230001)(4636009)(36840700001)(46966006)(40470700004)(47076005)(6862004)(2616005)(966005)(70206006)(70586007)(6486002)(186003)(8936002)(508600001)(5660300002)(4326008)(8676002)(2906002)(81166007)(356005)(336012)(26005)(6666004)(40460700003)(316002)(36756003)(83380400001)(36860700001)(86362001)(6512007)(44832011)(6506007)(82310400005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2022 08:13:17.5676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45755dbe-9c81-4ec2-9b1d-08da49efe8b8 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: VE1EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4848 X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-List-Received-Date: Thu, 09 Jun 2022 08:13:26 -0000 The 06/08/2022 10:16, Fangrui Song wrote: > On 2022-06-08, Szabolcs Nagy wrote: > > The 06/07/2022 10:49, Fangrui Song wrote: > > > On 2022-06-07, Szabolcs Nagy wrote: > > > > > - int protected = (*ref > > > > > - && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED); > > > > > - if (__glibc_unlikely (protected != 0)) > > > > > - { > > > > > - /* It is very tricky. We need to figure out what value to > > > > > - return for the protected symbol. */ > > > > > - if (type_class == ELF_RTYPE_CLASS_PLT) > > > > > - { > > > > > - if (current_value.s != NULL && current_value.m != undef_map) > > > > > - { > > > > > - current_value.s = *ref; > > > > > - current_value.m = undef_map; > > > > > - } > > > > > - } > > > > > - else > > > > > - { > > > > > - struct sym_val protected_value = { NULL, NULL }; > > > > > - > > > > > - for (scope = symbol_scope; *scope != NULL; i = 0, ++scope) > > > > > - if (do_lookup_x (undef_name, new_hash, &old_hash, *ref, > > > > > - &protected_value, *scope, i, version, flags, > > > > > - skip_map, > > > > > - (ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA > > > > > - && ELFW(ST_TYPE) ((*ref)->st_info) == STT_OBJECT > > > > > - && type_class == ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA) > > > > > - ? ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA > > > > > - : ELF_RTYPE_CLASS_PLT, NULL) != 0) > > > > > - break; > > > > > - > > > > > - if (protected_value.s != NULL && protected_value.m != undef_map) > > > > > - { > > > > > - current_value.s = *ref; > > > > > - current_value.m = undef_map; > > > > > - } > > > > > - } > > > > > - } > > > > > - > > > > > > > > i think we should keep this part without the > > > > ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA bit. > > > > > > I have played a bit but do not find any difference (with some examples using > > > "canonical PLT entries") if I simply remove the whole if statement. Do you > > > find anything I may have missed? > > > > yes, i posted an example earlier that behaves differently. > > OK. You meant the > https://sourceware.org/pipermail/libc-alpha/2022-May/139183.html > example with GNU ld as the linker. > > With lld the behavior is the same with or without the code block. well you need GOT reloc, obviously if lld locally binds the symbol then there will be no interpositon. but we must support GOT relocs for protected symbols, that's perfectly valid (even if no linker generates it). > > > object symbol defined in exe and dso, the dso one is protected > > and has a GOT reloc for it. > > > > with the extra logic the GOT is resolved to the definition in > > the dso, without it the exe interposes the protected symbol. > > Created > https://sourceware.org/pipermail/libc-alpha/2022-June/139574.html > I'd still wish that the code block is removed, but we can do that later. > I assume that once one port of GNU ld stops producing GLOB_DAT for > protected symbol, we can drop the code block for that port. thanks.