From patchwork Mon Oct 21 15:23:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evgeny Karpov X-Patchwork-Id: 99278 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 93E8F3858C33 for ; Mon, 21 Oct 2024 15:24:23 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2119.outbound.protection.outlook.com [40.107.20.119]) by sourceware.org (Postfix) with ESMTPS id BF2403858C53 for ; Mon, 21 Oct 2024 15:23:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF2403858C53 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=microsoft.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BF2403858C53 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.20.119 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1729524235; cv=pass; b=t9fberQyfImzgLp0/jsajXgFA3uq/PX/XnQnane7STaLYUW6zlPVQDk3ic4jBekm5T4t+UayBpWy/c4N2OMvI4CN82dhDmgKnKNZTlPUntMtOzcIBuDw/ezKbEJbrfGNlJS3M9BaWiXQkVLD+kQHYoGauvjJGRDsK9fvr55pOFA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1729524235; c=relaxed/simple; bh=gHPRBDTdzkq/Qb24XMt4Wuef0LeidnfzsS3duFZMNw4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=w7cHz7imaJaOI+hQa6Uy/8ViSm9RfY6xROyLNDrH8ZYTrGgmWpc8i0yLcFijI7ZYc9aRwxpTc4sCVOIQ7TLeSzNgFTZav4/I1WmbRbzerUNNxw8gQqshVdVlr1H8r4w9OQFPq77d+AwVox9yIt5HI+d6WKtBGw98bdTIbpjkVzo= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uyQM3/vef6b159I1BGYZGFm8MvMhSqFQ6yTuLkEnNRoYsdt0tZRj7OkVqsF00otH3/2k6tA1byAGC11u+QyY/ohKwPcOaNDah0SioZi2xYErRQlWxGLkQW1B58qTEcG6JZsp5BfbVTQqshNvRg3mUFXCkcxUXtUSuy86NO6ZvjI+ufMO4CKe5Q4SQX/m91dtWKoM606YQlPAtCBv3vAC5HsFuhEVKBS//TGU1tC+GfOapK1J4QcYDyXiRpemn01w+BfwPmBKs57Ck148phZP/OT7SniDPf2d471g4syGyZXtZVhUL4zZtYHcHpgggmggafZURiRlKt2PSMh4bf6gog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=E3TDH7lPHZjXpvWq/wzEa9P9nuFcc0y20pkQUdjEWPE=; b=KFfo2xoU9Za4rKVp1e+vZz6tVmf7EeiBQBGj7KmRFrwe4xFDCFoBC+nO1Dm9hGOQl7gLvR/Y7BubjEWWATXSEXmqGqch9pdfGZGjc0gGPZ3EC3+ODpD4FrkF0cnvsasr4izrDveAxZRoA4h8stne9jxeR/1u8zj5gYJq8Y0513YGH/iHQLve/gMmldcbVIWYW//g9nov1J5EkO1hqLrmsgSyDNmVNHXvi8BJCCG0j+yKhn/eRtjKSHh6ZB540YUgUEoa71F20jCfsU9SGnzi/3SCdsfEyNBaKjIIIDoMnLUbvY6h3KKRZ12e7EopqUVBhoxEBaD0SZggDXsXxcRTmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E3TDH7lPHZjXpvWq/wzEa9P9nuFcc0y20pkQUdjEWPE=; b=APJV8/crQBONzWOsZye1Ir//7ZWxOq9rpYuBF1OiGAkfpsb1skh5g1u4IAtxpBsi3Pj+B14RHEeZQqcqElL1MK3LnOXMvKs6Chb3IvvBbnpl9cd9EV8utMEI0ONbF9riddWcriaqb1T0N0LUdHmB2Mjmltdl9KSunLAgq+MaCKA= Received: from DBBPR83MB0613.EURPRD83.prod.outlook.com (2603:10a6:10:533::21) by DU5PR83MB0638.EURPRD83.prod.outlook.com (2603:10a6:10:522::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.3; Mon, 21 Oct 2024 15:23:50 +0000 Received: from DBBPR83MB0613.EURPRD83.prod.outlook.com ([fe80::399d:9bfc:1209:af10]) by DBBPR83MB0613.EURPRD83.prod.outlook.com ([fe80::399d:9bfc:1209:af10%7]) with mapi id 15.20.8093.013; Mon, 21 Oct 2024 15:23:49 +0000 From: Evgeny Karpov To: "Richard Earnshaw (lists)" , "binutils@sourceware.org" CC: Radek Barton , =?iso-8859-1?q?Martin_Storsj?= =?iso-8859-1?q?=F6?= Subject: [PATCH v1 1/3] aarch64: Fix IMAGE_REL_ARM64_PAGEBASE_REL21 relocation and symbol reduction for relocations Thread-Topic: [PATCH v1 1/3] aarch64: Fix IMAGE_REL_ARM64_PAGEBASE_REL21 relocation and symbol reduction for relocations Thread-Index: AQHbI806JGuxxuft3kaA0AEFHyS0pA== Date: Mon, 21 Oct 2024 15:23:49 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2024-10-21T15:23:37.967Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DBBPR83MB0613:EE_|DU5PR83MB0638:EE_ x-ms-office365-filtering-correlation-id: 9acd06ca-57a1-4353-8738-08dcf1e45d37 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|10070799003|366016|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?UPpVzrbOMhq6qwjote9Zv6gqCA?= =?iso-8859-1?q?WDkywYGBAGWuUFMmMHysmz5cgoJwg71u2U1jLmPydWM7FJqXY0OETaZny7Pa?= =?iso-8859-1?q?/Sa5KVt0U/002ZM//InWImuc+Ek/S83m1k8iHJYK0bkBCXnkBqQw/D0i3OTr?= =?iso-8859-1?q?YNeOsR00/blEJE8vOgkbyKR6IYLCz/dixvCeV5hHbTs5oqvzGJJgRk7SHV7A?= =?iso-8859-1?q?fRuVeM327AijQqRe0UtC89YRTMw97bv9vltLQ8tahvSlzvnt05nuM+cNqtJ6?= =?iso-8859-1?q?ASoCFeQcex9T1jPqp8XwJXaFllmTNs40FARTJWBC3R062BnYoZB6PlHMGORo?= =?iso-8859-1?q?iHVsvqqH0BGc/Mz64hbT3POxb3WSuh2nmgVVPiXoHhr6yw59wM/kVrr0TX/o?= =?iso-8859-1?q?peW9jlq94SiF2KiewyJLR7yGTi271Hq1KEx8ErwkFwfpwisR4diQL33GLLSS?= =?iso-8859-1?q?eq0Vz6ROpNVD1kKPJAPqYhRJwBdZBTmnzzTRoUHPdB6EhZGmA1lk8weXa4HZ?= =?iso-8859-1?q?ZPikaWvK92pXJOdK9RSoBl/fJk9LKrTcomyDq5l89dG/Lj2TFLG/wrWFzRSH?= =?iso-8859-1?q?ff2zWKMk+EyYaWbyo7u19MS7Ju4BA3kw0vp/axMm0G3sDW9dj9AsV6tQhus8?= =?iso-8859-1?q?XD2PXvPqStLh23zQO20KrpwkPktEPr+XTrndUNu0NyU0yyY0tafMj++2sXTb?= =?iso-8859-1?q?XdHb2tESuDufQUxDklT0NDSnJMOhL1/6cWa2yZmXt73GfsfaKnwg5Zn/ACEZ?= =?iso-8859-1?q?BM514LRPRMi8XAp8Yozi/vMNxLgF6XJTdfVlW1xaJRHVuW67A938lPZjYJju?= =?iso-8859-1?q?i3P9S6OmDz04+kk82D98XjPU3cxGXeMnT5jEGEHZvwhSku6fYNBdO2/NcP8F?= =?iso-8859-1?q?qc9GN/GYnEoOCURuLBKnWLEd8bvRigxfNYDgfZZXTQYU7YUrIB2273ROnGMV?= =?iso-8859-1?q?OXcdMwfAAB8MXXhjXnRHIr9VXeU4+6oGREANg8gssky2ICHoouEBGPMkToF3?= =?iso-8859-1?q?Ut82wEEivp/3Q3tY1wCGW086l8XsRTCzZuNa/BlJ3wnxxctX/EhAGPfs9Qvb?= =?iso-8859-1?q?NOmHLriQhB2YYEGM22nvLLSx/+Ol9erLegFvLg63zrbytqr9GvZxyEi9ram7?= =?iso-8859-1?q?ZXBLEttjLh2+K/7wHg+eBUs53LrkK+TmffvDCzJ2xYP6JYBPnGB+fS/RgIeh?= =?iso-8859-1?q?xArs8EpkNnMBOUd8Tzp0mHbcUjDPcTe1pcvvbK8Blq7craSHUQBfUN2buXPe?= =?iso-8859-1?q?8s+nBG+JOrEYOrpYdrBljag3PJT37SpC/EAHz0HlusycP02Aq8O/QmiwVjAe?= =?iso-8859-1?q?84kIR+wZs2pv0aVLTMSIi8G14PtO8cQBioqnoUH7OpS4PCNbqt/WLMMZ7e11?= =?iso-8859-1?q?+LIRNwyUhbaoe2hxW6YaFJCjxJPXBFeyZapXKuEzc=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR83MB0613.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(10070799003)(366016)(376014)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?CpLhQNOdxI0XNd4zFhXgBwg?= =?iso-8859-1?q?fyk3gqzqeRy7jEFgyfo9cMJYRcqHNB9QoPlxrdG9Q5Pyu0V/OnerMG6Ddvlh?= =?iso-8859-1?q?VJF25kEOYIiTQrJAHsdDP1TIRWv02XRisWXRagunrEf23h6IssU9gUwORZmj?= =?iso-8859-1?q?HN+gdGb3uYPv1Ju5jh0xekVxdC6GUip/DNGKAGyzH2Y3Cj6/p4qJENIB2hle?= =?iso-8859-1?q?4FHeAebuobfJ55ZnkZdp3YQhIlP3nC4/s4QkPBFs67BkBxtXXsmCdq0yHXSA?= =?iso-8859-1?q?dU5x3dIaJiexU4JzxbaWdaLWjDVIzs/kfZaim0OZ87GS6gx2qQQ8i6eqVf9L?= =?iso-8859-1?q?pbjjYD58BOle0gNknGmRIIE3cofM7Ln9OWgxSkcyAmOQeCb2RiZoNY6wPv3K?= =?iso-8859-1?q?j6iXaCwyYlZLPKP+W0hupn1QYMmBeeC/x6ALd19HJCS1SqY5somd7ot4MiKS?= =?iso-8859-1?q?LTG7rxuMxR0qMPILJ14D0m9ua6gXVfllBAg1o69+2ihwcwiBI8GROh+PrJP/?= =?iso-8859-1?q?jR3z60rHsJJMYn4roja3TbzuRPoBMqa9mvgOYMY3E4O/vDr/uPm9exgTd99L?= =?iso-8859-1?q?muTrafueKGMFj169qSYs8UQkLcN3HvwEPbDw8wCBeVfpyZ+JF2ubmm9xEyRn?= =?iso-8859-1?q?ySZ5fd0XwJWR9sJAWpGy0ftrz/GLgY3BXPYAlUW+kIIgGwRrnlD1NS7DkHY7?= =?iso-8859-1?q?OHdd0EEnDg4K6yWw3VBNB7vVHyIMMGj4lZiU0aLEH55v+r1yYRlpU7MyH01U?= =?iso-8859-1?q?zZ0WApPD9F9ygzemZkjwB4uS4enSFpDMzlNCW6P3G2sTBUl+mQ8Rfof4yWR0?= =?iso-8859-1?q?lZOXMmMeY82qtQTcI71Cej7OUGJx7+5ndcMRJ3F5fH4KQSSSFt6yN75atK5V?= =?iso-8859-1?q?0L1TUY7S3KX6ckLAQQ6+v4ZCN0xYY2DVft1MtKyBNO7nwtxJoPNXdusje18B?= =?iso-8859-1?q?LJ1YczrxoM4Hdc1VV1vj5y+GCVp8c2YqIvK19IcKgGCeaY/27KFfbZpw7aI9?= =?iso-8859-1?q?rpnZJtUhIu5O6i9woLRJzca+CqucOoaFgtQgjUZaX3xUPzByuwJ7Y2UeX8ql?= =?iso-8859-1?q?Ph7MtARrSbkOtF6b6O00ND6IsLSHCkdZvOXYyT3RZoiichS5FJAvCtqUcF24?= =?iso-8859-1?q?iwF31+gi3c1q2wWjDEpelUKRrXKVWHWL128WhuWWTabbQ7+dAEwEozMXoJzo?= =?iso-8859-1?q?HTh0T4ThzJv6e3WWuIHhppt2PqCphBZLlmK7zPTnK/SEwkhTlcH6PdYQjnOG?= =?iso-8859-1?q?UltzTisOV+bI9VK5IA17GAwPLG/cNh/PLZwtWmy3RtGeSBQawk1OjrDhV5WP?= =?iso-8859-1?q?LL9nrRYK1ei+K5cDM5fNSR9bTrjX6T1ZKDW5qmVtHnNrMB8wyWxkMlWrtUDX?= =?iso-8859-1?q?Zf81Qj9Wm0Ov8ff7kArgH6dBFp5gaO1QmxZhUfpusEpuK2lhNq8I1ymCClCq?= =?iso-8859-1?q?UYrXgicqw1LW5WqNtxJD7b6GpTJYCQDmCTTBTVR9O44iMCelwhNQl7xQlhXK?= =?iso-8859-1?q?MWpu+nGwffIifTCY1HHthBhy30UgDlDGQuuG38I0CW9jA1bIAzIJ/X/Nrapo?= =?iso-8859-1?q?QONPI53QDNUWdyu1CbhMUx6w9Vwd49RohMfffeiGvnhaOxzoll4WOb8Kn70y?= =?iso-8859-1?q?oLiLO56C22nXv4yZMgpuwdSiS7zE79hFPi5KYk4DsbPMKMeYg5wBjMaTHptD?= =?iso-8859-1?q?Fq97+H+esblyQ6H6mrlcn?= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DBBPR83MB0613.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9acd06ca-57a1-4353-8738-08dcf1e45d37 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Oct 2024 15:23:49.8438 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: t2R8oZMD1EFxVCeTOTdstCnEcEVTRWvFvEm4w31kef24jbZS+Q3qmUzeJYsC8/3tQeuFZc3jzFu+r6+Nnc+d4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU5PR83MB0638 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Monday, September 30, 2024 Richard Earnshaw (lists) wrote: >> To resolve this issue, S_SHOULD_BE_REDUCED_TO_SECTION_NAME has been >> added. > > I'm not exactly sure where we got to with this patch, it might have been dropped.  But one thing I noticed is that > S_SHOULD_BE_REDUCED_TO_SECTION_NAME seems to be trying to achieve the same effect as the tc_fix_adjustable() > hook, which can tell the generic assembler code if it is safe to replace one symbol with another+offset.  I note that > aarch64 does not define this, which may be the source of some of the issues you are seeing. The patch remains, and two lines in IMAGE_REL_ARM64_PAGEBASE_REL21 are reverted. Thank you for mentioning tc_fix_adjustable. It looks like it fits well with the patch's needs. Here is the updated patch. Regards, Evgeny diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c index 3f6a608b728..84af335b3a0 100644 --- a/bfd/coff-aarch64.c +++ b/bfd/coff-aarch64.c @@ -579,8 +579,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, input_section, rel->r_vaddr - input_section->vma); bfd_putl32 (val, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; - + rel->r_vaddr = -1; break; } @@ -614,7 +613,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |= val & 0x3ffffff; bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; + rel->r_vaddr = -1; break; } @@ -649,8 +648,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |= (val & 0x7ffff) << 5; bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; - + rel->r_vaddr = -1; break; } @@ -684,8 +682,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |= (val & 0x3fff) << 5; bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; - + rel->r_vaddr = -1; break; } @@ -721,7 +718,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |= (val & 0x1ffffc) << 3; bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; + rel->r_vaddr = -1; break; } @@ -758,8 +755,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |= (val & 0x1ffffc) << 3; bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; - + rel->r_vaddr = -1; break; } @@ -787,8 +783,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, input_section, rel->r_vaddr - input_section->vma); bfd_putl32 (val, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; - + rel->r_vaddr = -1; break; } @@ -832,8 +827,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |= val << 10; bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; - + rel->r_vaddr = -1; break; } @@ -855,8 +849,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |= val << 10; bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; - + rel->r_vaddr = -1; break; } @@ -876,8 +869,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, input_section, rel->r_vaddr - input_section->vma); bfd_putl32 (val, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; - + rel->r_vaddr = -1; break; } @@ -901,8 +893,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, bfd_putl16 (idx, contents + rel->r_vaddr); - rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; - + rel->r_vaddr = -1; break; } diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 4a91d5a1833..6cded78c3bb 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -2934,6 +2934,9 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd, symndx = rel->r_symndx; + if (rel->r_vaddr == (bfd_vma) -1) + continue; + if (symndx == -1) { h = NULL; diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index e94a0cff406..b515e668822 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -2189,6 +2189,27 @@ s_ltorg (int ignored ATTRIBUTE_UNUSED) } #if defined(OBJ_ELF) || defined(OBJ_COFF) + +#if defined OBJ_COFF + +bool +aarch64_fix_adjustable (fixS * fixP) +{ + symbolS* sym = fixP->fx_addsy; + if (!sym) + return true; + + if (S_GET_STORAGE_CLASS (sym) == C_STAT) + return false; + + if (symbol_get_bfdsym (sym)->section->flags & (SEC_DATA | SEC_READONLY)) + return false; + + return true; +} + +#endif + /* Forward declarations for functions below, in the MD interface section. */ static struct reloc_table_entry * find_reloc_table_entry (char **); diff --git a/gas/config/tc-aarch64.h b/gas/config/tc-aarch64.h index 15e22436bf7..f3288a5ae5d 100644 --- a/gas/config/tc-aarch64.h +++ b/gas/config/tc-aarch64.h @@ -250,7 +250,12 @@ extern void aarch64_after_parse_args (void); #define md_after_parse_args() aarch64_after_parse_args () # define EXTERN_FORCE_RELOC 1 + +#if defined OBJ_COFF +# define tc_fix_adjustable(FIX) aarch64_fix_adjustable (FIX) +#else # define tc_fix_adjustable(FIX) 1 +#endif /* Values passed to md_apply_fix don't include the symbol value. */ # define MD_APPLY_SYM_VALUE(FIX) 0 @@ -332,6 +337,7 @@ extern void aarch64elf_frob_symbol (symbolS *, int *); extern void cons_fix_new_aarch64 (fragS *, int, int, expressionS *); extern void aarch64_init_frag (struct frag *, int); extern void aarch64_handle_align (struct frag *); +extern bool aarch64_fix_adjustable (struct fix *); extern int tc_aarch64_regname_to_dw2regnum (char *regname); extern void tc_aarch64_frame_initial_instructions (void);