From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150045.outbound.protection.outlook.com [40.107.15.45]) by sourceware.org (Postfix) with ESMTPS id C348E385840C for ; Wed, 1 Jun 2022 09:53:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C348E385840C ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=icSahPhtktCnqZwRtJDQIK4LQL4JuoHSdfaq4DkT0kOTydYfggbVoITCZMDRPisj+3Uzrc9SkVGo1p9dsrkvk0+xDz2EBO0Ax2rynkubYQF/qWnJtD+QFN6SD3G/XLZb0rrqQZSBYBwFZzOx2hw9+IOSk+WdA1JlD9EprImc/7mPtwbCQPIFUYKYTCORNzP1Kw9fcowlKjqytBRxCnomEAZ/XWjG3nOtqywggHr3QhcvoVv0J2UoIt3HDk4cPSSB5ykdIEWSI6Y6ZOKBHkdN/hed9wDm5QS3BSO6myK9kLrl6kR2mAztqcfofQPlX1iBmMipafJMKgzbcaczXdN+Gw== 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=hGcmJGDlCs8M4WlPSijH0ICbJvq1N+SWInf47C740UY=; b=b6apbsZhB+66VKJ45DcpG/qC6i2aHckjeqMYAdzgXD0PDiqyH9YD3436ueV5zizBighpjDFBKs5M3jGOq3XSyDL2tnqwGUUbsh+u4TUbM4CidG1qIDwkdw3yd6TWbrbc1ow3rExVfctaAzVRZ9+uPm8yd3+xlOiobMtr7jOb1N7GjMNEqi6aH9Ixrz78iXq82IQdvJ63IAUWbz+v0C8LHappBV1gr+Z9qb0X25X/I5hMmT3hax0j7+0u4G/R+3klHsamwa85aGjZcdOk+5Qd93GzFPhtChDDhK2bHmTQRghRQSbhPkXW5xujQnkN5ANSziBXQzMCmFtncYFNC+kcqQ== 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 AM5PR04CA0002.eurprd04.prod.outlook.com (2603:10a6:206:1::15) by AS8PR08MB6135.eurprd08.prod.outlook.com (2603:10a6:20b:29f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Wed, 1 Jun 2022 09:53:46 +0000 Received: from VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::4c) by AM5PR04CA0002.outlook.office365.com (2603:10a6:206:1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 09:53:46 +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 VE1EUR03FT009.mail.protection.outlook.com (10.152.18.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 09:53:45 +0000 Received: ("Tessian outbound e40990bc24d7:v120"); Wed, 01 Jun 2022 09:53:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fd7422a9e4fc5bee X-CR-MTA-TID: 64aa7808 Received: from 9c9ace871c49.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C881EC0D-128E-45EC-9E97-212BEC27C92C.1; Wed, 01 Jun 2022 09:53:37 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9c9ace871c49.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 01 Jun 2022 09:53:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lA/PEITBa/t+BDiwf3czXkdN+Tv9dqQDvwRT724Rm8ILDj/eaPpCqXqLo04L1sgQQkHuG1tdKJNMGc4lTEmkO4V1rrzMilMF9tVHkAsNIU6D96m4da+wRPPIx5xZabu7Y31Dze7gnYZY4A5JlqDL60UWoUOnSgPW9KFdiJzOmqwQBnVZo/xgYPsUnu7y1Cx99eeyNMO809C8FiDPfTHRlZ1IHIAwZ6xvLvmFcASE/frfoR9KF9cFOQ102OVBTtreFT6Xs7PmGIGUBPuwYuIErlrz6+LSom4naOkb4o9IqPhHEglkPwqgsUj/DmHIt8k8wCeYa0T0uOtZo9zBvQTpog== 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=hGcmJGDlCs8M4WlPSijH0ICbJvq1N+SWInf47C740UY=; b=erut+gowGnfYzsUxVnyDWydOne7DOZBGAmnGimS38k0Ckl4AjOObkaICuN5OHr3NUWrbgKtsU3HsBj9Wf2X6XK2IwDCIHH0DY8Y8J5XXN8JMQ8JwwiKY+5k05pePqlaeX0Jb+b4SJicTpAxCzbD2j8HYtcySZ/413d1749VixosJu4cL0UWBef2XR3MgKYUUYc4SDgIWbBmISda8gfB205GzRA/mFQo0wjSheXYPkt8F8o3A/sCE66sBOQG7KHAkSGVkLrMApSSk735nQ1sDNNV3QBWRZqdaOXoqOMxHHyVG/Q8t1jlGgAXtWoyad7NHvVrVmKYL0JdzvFngpeVO1A== 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 DBBPR08MB4727.eurprd08.prod.outlook.com (2603:10a6:10:f2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 1 Jun 2022 09:53:36 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::9ccc:fe7c:19e5:bfa6]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::9ccc:fe7c:19e5:bfa6%5]) with mapi id 15.20.5293.019; Wed, 1 Jun 2022 09:53:36 +0000 Date: Wed, 1 Jun 2022 10:53:21 +0100 From: Szabolcs Nagy To: Fangrui Song Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v2] elf: Remove ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA Message-ID: References: <20220601045033.809671-1-maskray@google.com> <20220601073423.ddyb5wuwlo6tpisk@google.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220601073423.ddyb5wuwlo6tpisk@google.com> X-ClientProxiedBy: LO4P265CA0016.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ad::10) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: bd89eca3-576b-4b13-46af-08da43b49e65 X-MS-TrafficTypeDiagnostic: DBBPR08MB4727:EE_|VE1EUR03FT009:EE_|AS8PR08MB6135: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: bsUrpiQnMxCo4NFEZZrVQ6h+2xz7Xh8Ysv3/ACqgJ0+j7QqAD0zRaZZBvzd1r8GFyrZkn3dtgrHNcfc3oKqaZUCzT7VvQX2iwsZQiiTPBEHO4sfOfLREOFNXIfpvJ/42QD2fN/DNdErLPqnafVwg0l+Vzx7AeTC97TgIm74EqKfPUKMq7DX61Z7jvujOkvwt86c1PreJ8A50qo4llG6pgJeo2lsrSk6sL1wL96QgoWZRmJduD6FTGkJ4JMmfqnE9izSurjEWhaFPBVNWhANnZyu/BMLrCgSOKw57KgH0aM0N4j/tQyGCgnTv2O99if5juuAWBlrb0vcKyVDj33uFa+uMwcGU9Ok6Bav0Tk2mb53gROTIp+qMtZOAIAKcooTt/4ljZOIl3HWovxpAXS+yK967haehvn/G8/w5BsT50v9cwTxapRPxzuCj7PnOCtGAY9zu8tlBus36SswMO+/2ny+JLq9EKB5hE1FM+2ddvzBrSlqQrqvV/B5jeqb8gQLyNWaGkaLqacb94tSAMC7cFyPdVJWWCSeNTE9OkvxdMAvtrSeKnspI1ae3G36iyQN4v4FI7a6pqkHlfvcDg5NkGhLTngk0dWhz5WzJbzuzLB0pvqKVNIvdj9zi08soL8mNoRv/xSl9VJ3aCWAz74zZ1A== 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)(508600001)(5660300002)(6506007)(66946007)(66556008)(6486002)(86362001)(26005)(6512007)(6666004)(2906002)(8936002)(38100700002)(186003)(83380400001)(4326008)(36756003)(8676002)(6916009)(316002)(2616005)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4727 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: VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d4729b55-3604-4431-57c3-08da43b49845 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9ZuvikH691zmotQTBRaw0mhjRHdtaNDQUKX94jy/6MOZAtCXunWFLgTK+Q9LJGi0YKVTrPDuD3fFIHp5/yKec7JTn/8lcbaV6V3ZLptRs12PbiCFESScMV7QBrOokFKB+8lNcaOLmUI2XNkRxPWX+dEA0EyXrbDwMhXYxREWPipc7USs5hHhDN/COKg0bib+WcJ7/d4hG0J7a+ASNfZnvxlhdTha7w9mz9Ri8o6VaB1WijhmG2CXHAmh/JiezI+5xd3kJembA7DAmpUP1nYPASqNJf2S5zbgULgaM5600IlhjSUuQwlj6Sa6Yg4RjifV0SYfLLEtbr6dFXzkrGdvBGDiIzMA+2YOMobW1GQwIQxMvXHOunHFtLHJO4HBaJj8o5yrZM4Rve3uSOgJEtnEDv4aai9d/FAnnccyVL0tVaDAS4WGexv6EghLgjToiHo7twjX6HhZv1jPavZemXx47eRltf/YcabNjm8UbW3mnCOfCorfmAcMyQyNDkbQRsjWnEuvm1y4kOti9CKCcUeQRuwSbMHAIi06czI1qBe7/TxMI8ih4J/Eskps8IZx33agNOLvNaYVIK2fPFS8kQ9d+1NeKdx2DjleFz2E3OH5IPItA0BUxnie63qzFOI1CzQcCdZPa46JSuMB888x29p3qmPWXVkbtYmepF7hPXXPMrcd5ViQXA5mK3tKmy8+Xyaf 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)(40470700004)(36840700001)(46966006)(6512007)(6506007)(44832011)(8936002)(5660300002)(86362001)(6486002)(83380400001)(2906002)(26005)(47076005)(336012)(2616005)(508600001)(6666004)(40460700003)(186003)(82310400005)(36756003)(70586007)(316002)(70206006)(8676002)(81166007)(4326008)(6862004)(36860700001)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 09:53:45.5864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd89eca3-576b-4b13-46af-08da43b49e65 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: VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6135 X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham 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: Wed, 01 Jun 2022 09:53:51 -0000 The 06/01/2022 00:34, Fangrui Song wrote: > On 2022-06-01, Szabolcs Nagy wrote: > > The 05/31/2022 21:50, Fangrui Song wrote: > > > If an executable has copy relocations for extern protected data, that > > > can only work if the library containing the definition is built with > > > assumptions (a) the compiler emits GOT-generating relocations (b) the > > > linker produces R_*_GLOB_DAT instead of R_*_RELATIVE. Otherwise the > > > library uses its own definition directly and the executable accesses a > > > stale copy. Note: the GOT relocations defeat the purpose of protected > > > visibility as an optimization, but allow rtld to make the executable and > > > library use the same copy when copy relocations are present, but it > > > turns out this never worked perfectly. > > > > > > ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA has strange semantics when both > > > a.so and b.so define protected var and the executable copy relocates > > > var: b.so accesses its own copy even with GLOB_DAT. The behavior change > > > is from commit 62da1e3b00b51383ffa7efc89d8addda0502e107 (x86) and then > > > copied to nios2 (ae5eae7cfc9c4a8297ff82ec6b794faca1976ecc) and arc > > > (0e7d930c4c11de896fe807f67fa1eb756c9c1e05). > > > > > > Without ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA, b.so accesses the copy > > > relocated data like a.so. > > > > > > It's extremely unlikely anyone relies on the > > > ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA behavior, so let's remove it. > > > > > > -- > > > Changes from v1: > > > * Reword commit message as suggested by Szabolcs Nagy > > > > Please document the interposition change or fix it. > > Does this paragraph count as an explanation? > "Without ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA, b.so accesses the copy relocated data like a.so." > > Or, what other documentation on the interposition behavior do you expect? the current commit message implies there is only behaviour change in presence of copy relocations. but that's not true: the exe (or a shared lib) can now interpose a protected variable by another one with the same name (and no copy relocs). i originally thought that warning/rejecting copy relocs in ld is enough to get sane behaviour for protected symbols, but when multiple definitions are present the behaviour will depend on ld's decision to use GOT or not. i think the removed logic tried to ensure that GOT relocs resolve to the definition within the same shared lib for protected data. (i.e. ld's decision does not matter.) if we want to allow ld to not use GOT then i think we need to keep the logic that makes GOT behave consistently with that future. if we instead want to simplify ld.so and handle GOT for protected symbols more efficiently, then that should be explained in the commit clearly: why do we choose the "symbol lookup returns a unique address" over "protected symbol binds locally" rule when there are multiple definitions? (maybe because this case should not be relied on but then we should diagnose it, etc)