From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10olkn2071.outbound.protection.outlook.com [40.92.41.71]) by sourceware.org (Postfix) with ESMTPS id D64213858D20 for ; Thu, 28 Mar 2024 07:11:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D64213858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=maskray.me ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D64213858D20 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.92.41.71 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1711609872; cv=pass; b=cSJOSO5yfU15mnxtOsvqErJJBQGnG+4FaCFkVxq0FuQP6JNe0uqkaZ4XHnp/xkRxeQDQhYHG73i8aI7PnQ7vohXUqRCh7zrBOlh11QeFiPIY7Yc2RQcnJHNsSG1DqhVxZoBxB5iZeJrzqQYkbR03fWXW8enRuwxKE6M9+n19pvY= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1711609872; c=relaxed/simple; bh=nQ98GzAm/lF5Fg3W7ABCxUGkddKdQR7LJtd8dLViuWM=; h=From:Date:Message-ID:Subject:To:MIME-Version; b=QZvyNMzn1vN4Ca9d8h1JojvVDJQ3XSj1eyoeIPwgvZvDV/QWBWqq/f3Mj0Bz5Sl6eSNMMtGCXBa1YspgRc9hYukEGMwekhN7BlLwKOz/KTxnkpiCCBzA/+thycEGGcHLdzOvfY6XFza3f3Iqd0aSEAJmPNVwfT/a+HOtHyU68tA= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wi9aqqsuiwQI4bp0mHBm+jSEH1s5N9/nYJ97zjquyjhQdkqBxgDHkFAOAV/yLJTTwJ9EwXzXb1mzPeP5M7I/Ocq+npklZB0IhVs1pQx35FxCM/vHk7i2q1/3W02bftycG7/Ok+UQox/KxsiPuAuHu51IWpGzfQK5tohnqjW2hp8gbFmfCi0i2+odJACWhIHvfmbgyIMYS55glMCbQJtasFE49sZaVdN8GD2bp/vRIB7ValwVULO0xlxgTWvzWN89xfwtPi2JqEvmGcNVQr6TeytLkakAhTZhkYv/6Q9tjd5FLW2ToqFlOHp06nCHoirsdyaLWlGi6YxbzpS0CrUecg== 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=2u5vL+DqRwj9KVmSkrRt0AuZ3zQHFUxDCzu0HXjPlXM=; b=gCrVJK09JYGp19qDWFudSB7DVsM9OkAj2TtxKb9DPWIMVapfGoxIy38ic095lg2o2eohY2W3YxF/CtHLjdZ+To3/nkLo/pMAbSFmfEfffcDjzCFmrRmjNE6YWaZXo5VyZwr+81im75V8ZkGZoq7M2zOfV5aPlOUphwMIg39fiZEK+uXfFG8tY3vQT1t4Ds2DchoK32QsIf157XUr4ZfdWXf1jgMo6vGFziT0Re3rAOm1tsNt0KleFUW8OfJt32xGdDpdmV/3vJlaQPcv0z/YYMji7gx/pFAoZbNxiAb6nmN9lwkBYJSKBT/73Rv1n9ZGwG61KdLeQR36X7aMmqmkng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DS7PR12MB5765.namprd12.prod.outlook.com (2603:10b6:8:74::19) by PH7PR12MB6666.namprd12.prod.outlook.com (2603:10b6:510:1a8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.30; Thu, 28 Mar 2024 07:11:07 +0000 Received: from DS7PR12MB5765.namprd12.prod.outlook.com ([fe80::a812:d545:ea04:4982]) by DS7PR12MB5765.namprd12.prod.outlook.com ([fe80::a812:d545:ea04:4982%5]) with mapi id 15.20.7409.031; Thu, 28 Mar 2024 07:11:07 +0000 X-Gm-Message-State: AOJu0Yytkz9ohwd2EZ/4SPjjxVR2Feg0pBaMOAdncpCbTw6a9ctNkyOH dpmO7VMOmZ7g3T8fZvyHFcLNjDzbtoofC1+alQcVlVkGQq0KqXLiDrf822NRnV4YCPbeqiT2ZFr D7G01aET0fa9eF9oV4Nd6hPrG9to= X-Google-Smtp-Source: AGHT+IHBrIUoi5xcP6ItQ2NFP60nXUoXZNP9SQ+9BrJ81xayIx3HDGgN7iK5i11ekkQzWuNGVCoBNM9/PMCs3w+nuRw= X-Received: by 2002:a05:6122:400d:b0:4d3:3334:f2fe with SMTP id ca13-20020a056122400d00b004d33334f2femr954907vkb.1.1711609863419; Thu, 28 Mar 2024 00:11:03 -0700 (PDT) References: <2747d24e-1331-4970-8660-421f4479dc62@redhat.com> <54acf602-44ed-4bc8-8652-5feb450195ee@microej.com> <5c111888-0f10-46fd-9f5a-43354f2eda8a@redhat.com> <1aa735f4-ff2d-4334-830e-d23ef154dbba@microej.com> <578e6c40-5e6c-448f-bb76-791ad19db444@redhat.com> <56093691-58df-4917-99e7-41a47e5e1e5d@microej.com> In-Reply-To: <56093691-58df-4917-99e7-41a47e5e1e5d@microej.com> From: Fangrui Song Date: Thu, 28 Mar 2024 00:10:52 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: load of in-place relocation addend in AArch64 To: Nick Clifton Cc: binutils@sourceware.org, =?UTF-8?B?RnLDqWTDqXJpYyBSaXZpw6hyZQ==?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-TMN: [ZXDuLRPKufJ2IPh2kEZXXkR9dS/97mVe] X-ClientProxiedBy: BN0PR10CA0012.namprd10.prod.outlook.com (2603:10b6:408:143::10) To DS7PR12MB5765.namprd12.prod.outlook.com (2603:10b6:8:74::19) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB5765:EE_|PH7PR12MB6666:EE_ X-MS-Office365-Filtering-Correlation-Id: ad82ad48-416e-44aa-f53d-08dc4ef63bbc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: juc0nAAuaxIzgy/qYxpRjkUZfdf8cJdqodC3joX16IVGbSt4t18Ba0aV+lZaQzPy1WIU6oPSiMvf1HYtrZwCOLG2i7a6Cz3tBrpOQpy5Q7WGwra+anniV26hij/JHINUSQBoNyfBMDUiPjLWlmuFF6ynhfqZh4cymlouxDd8nQfyCCf00/XcXf3egM7wvDU1BbdG14FVJezsljIl6Gxk9XS9mTKgiUVQsKo7MzL0MGxG7sHL2c+BfSk5GvP6SRPnuCfbAZ0K/0OKSAA7ZSIWptLoBCtJPhyIb87/3QqZi1ngP9X+DleN0mxjFUTlFtAzwZNcUs7maZ+nkkvA2eblqT1cY9e9tokfrbTgOEVBkKzeMv+AC7f93oWgPjBbyEPdPgVZVfsHeAfd+QSezmo/VxrNEexrx0QOaX32N4zda3E+fgemaUMq1vpqqQF2AjaYaeAZvw+EhHxTlO9WZb8hrzHftQgaXfATPW7EVFbh7ov5WwWs+ElbgW4xXfmicUG7WlAYycuNjusACHOhnsw3mag4lkZJv9kta7oXOstPWpxvf/FpOhBNJppxAQIvcF7ihEEQtdUneYTo0U+zfTXVs+dRgeC0KsYcvJ2amCeVxp5JUN5j+ywYfgw1t2YvES1CMDr9LU35w5QZTWWrZdnP0BiHJyLtUcvkRmJ8uRNmDZ4= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dnRQWmZqT2ozY2hHTFdyL0hFQTJMZktjRHZzMFhLb3F0ZTR4eE9uYjJYOFB5?= =?utf-8?B?c1BPMUprVTQzbEUxbitEOTJsVVpNUG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-8?B?NEZ3cHErVWowUlNtNzVlZk03YllWT2VnYkVaM0hMQ1ovRk5seWtaQzF4RnR3?= =?utf-8?B?WndZK0QxTVBaTHhjNGRydkg1TEV6NUJpb0U4cmZrZHV2RVRzSDl5VUtpcEhL?= =?utf-8?B?MGwvcVI4VlkrV0tYUkZ6TFYzUEUrd3JaRXBucHhHTExSTTZqVkVFNGpncHZF?= =?utf-8?B?eisyVUpYcGJIQUVZb3YyQVRZY3Z4b1dkS2ZFdURwb3ZIMmw1aDRPTXJiNStj?= =?utf-8?B?R3AwcEREdHhuc1hMeWhDaWxxeERJVHZZUmRJekxWeUdiV3RrMW8vQlpmMjN3?= =?utf-8?B?NXlFcVFRNVhYOC85ajVCV1Z6UzRmU0ZwbERoVnNMYzk5bkNWbHNldEpiTkxJ?= =?utf-8?B?OE1hMkh4VmpHWEhPc2RHK00xSUhFVTJCbFhwN0ZxSFJ5WnpnU2p5SUlVdDdH?= =?utf-8?B?d1BBUVM2bzBtQlo5MUVGd1kyMDQvcFRSQUhnaG5sWGdCNHpYZmJpRVd3cnAr?= =?utf-8?B?aTV0dFFBV24xYld4LzB3YnNwQjJoQ1djU1QrTVVjYWVJZmplVk5kRXdRdHJI?= =?utf-8?B?dytPREtBNFB6NFFZaFRwSjBPbXBMbEt5SWlSQmRpL20zK3VvRW9TRzV2RGR5?= =?utf-8?B?Zlh1UWh1N0VSUGM5NjBXMEpsajRINUcyK2ljN294M04rSE1oeU1qaUdYOE1k?= =?utf-8?B?SXJZckdmVjFGRm5MLzZKSW9KV2U1WlE9PQ==?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-5183d.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: ad82ad48-416e-44aa-f53d-08dc4ef63bbc X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB5765.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 07:11:05.2822 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6666 X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_20,KAM_DMARC_STATUS,KAM_INFOUSMEBIZ,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, Dec 10, 2023 at 11:51=E2=80=AFPM Fr=C3=A9d=C3=A9ric Rivi=C3=A8re wrote: > > Hi Nick, > > I understand the reason and I agree with a warning, because in the > meantime I realized that REL relocations are correctly supported when > there is no in-place addend. > > So we could improve the message as following: > > "Warning: REL type relocations are not expected for architecture > 'aarch64' - in-place addends with non-zero values are not supported." > > Also I believe it would be perfect if this message could be printed only > during the relocation process, to avoid impacting the other tools. > > I'm not familiar with LD code base but is there any chance to be able to > retrieve the original relocation kind when we are in the > "elfNN_aarch64_relocate_section" function ? > > (for example by being able to retrieve the original relocation section > type or the relocation entry size for example) > > Best Regards, > > --Fr=C3=A9d=C3=A9ric I'd love to see better REL support :), at least for static data relocations (generated from .long/.quad). While REL is often inadequate for static code relocations because the instruction to be modified (commonly 4 bytes on RISC architectures) limits the available space for the addend, using RELA can be unnecessarily bulky for data and debug sections where the constraints on addend size don't apply. I have made a quick analysis using a modified clang. In a -O0 -g -gpubnames build, using REL for non-code sections (sections without the SHF_EXECINSTR flag) decreased relocation size by 27.1% and the .o file size by 6.4%. ``` |reloc size | .o size ---------+-----------+------------ RELA | 550519056 | 2339938120 REL data | 401209104 | 2190607000 -Wa,--implicit-addends-for-data CREL | 44865612 | 1834284744 -Wa,--crel,--implicit-addends-for-data ``` I have filed https://sourceware.org/bugzilla/show_bug.cgi?id=3D31567 ("gas/ld: Implicit addends for non-code sections"). LLVM RFC: https://discourse.llvm.org/t/rfc-implicit-addends-for-non-code-se= ctions/78000 > On 12/7/2023 6:16 PM, Nick Clifton wrote: > > Hi Fr=C3=A9d=C3=A9ric, > > > > OK, I have produced a small patch (attached) which adds this warning > > message to the linker's output: > > > > $ ld test_AArch64_with_REL.o > > ld: test_AArch64_with_REL.o: Warning: REL type relocations are not > > expected for architecture 'aarch64' - support may be incomplete > > > > This warning does not actually stop the link from completing however. > > The reason for this is that the code where the relocations are loaded > > is shared by other tools, which do still work with REL relocations. > > For example the objdump tool is able to display the relocations witho= ut > > any problems: > > > > $ objdump -r test_AArch64_with_REL.o > > BFD: test_AArch64_with_REL.o: Warning: REL type relocations are > > not expected for architecture 'aarch64' - support may be incomplete > > > > test_AArch64_with_REL.o: file format elf64-littleaarch64 > > > > RELOCATION RECORDS FOR > > [.text.__icetea__virtual__com_is2t_icetea_support_test_BImpl___bar__I]: > > OFFSET TYPE VALUE > > 0000000000000008 R_AARCH64_ABS32 > > com_is2t_icetea_support_test_AImpl___bar > > [...] > > > > This strikes me as a compromise solution at best, but it is better > > than the current situation nonetheless. > > > > What do you think ? > > > > Cheers > > Nick > > > > > > > -- > MicroEJ > > Fr=C3=A9d=C3=A9ric RIVIERE > /CTO Office Member & VP Product/ > > 11 rue du Chemin Rouge - Bat. D 44373 Nantes Cedex 3, France > https://www.linkedin.com/in/fredericriviere/ > > Twitter LinkedIn > Youtube > > > event > > This email (and all attachments) may contain information that is > proprietary privileged, and/or confidential. If you received this e-mail > in error or if it was improperly forwarded to you, the information > contained in the e-mail should, at all times, remain confidential. > Please notify the sender immediately by e-mail, and delete or destroy > the original and any copies. Any unauthorized use, disclosure, > reproduction, retention or distribution by any person other than the > intended recipient is strictly prohibited. >