From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7867) id 060A13858D34; Mon, 15 Apr 2024 01:55:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 060A13858D34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713146142; bh=k8aHZMsdUunYZKIRQRw0AC6IQ141ndpdEkGw78AYuFI=; h=From:To:Subject:Date:From; b=VC5Ez8PdQT/m3f3cilUIvZ7LgBpJqIzZVefHY1cTvVLzdL+8WFL6bGHw7qJIp0Bpm hAclSLVoeg0BUvfqgXRBvSEi60/LowoA/yHpbLwqSNq2JPilcUWoRuoE3cOnQSh9t1 fKKILDQy6J6N0pNS4Qw9Ndsr5dcUlvbNHsnxtCD4= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: liu & zhensong To: binutils-cvs@sourceware.org Subject: [binutils-gdb] LoongArch: ld:Report an error when seeing an unrecognized relocation X-Act-Checkin: binutils-gdb X-Git-Author: Lulu Cai X-Git-Refname: refs/heads/master X-Git-Oldrev: 31a1b19e6ca8d83eadce9b5daef6f318aa0b42ca X-Git-Newrev: 5966e2eb3fed61ebe5c091a074b368b9238a68c1 Message-Id: <20240415015542.060A13858D34@sourceware.org> Date: Mon, 15 Apr 2024 01:55:41 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5966e2eb3fed= 61ebe5c091a074b368b9238a68c1 commit 5966e2eb3fed61ebe5c091a074b368b9238a68c1 Author: Lulu Cai Date: Thu Mar 21 15:16:05 2024 +0800 LoongArch: ld:Report an error when seeing an unrecognized relocation =20 If we generate an object file using an assembler with the new relocations added, and then linking those files with an older linker, the link will still complete and the linked file will be generated. In this case we should report an error instead of continuing the linking process. Diff: --- bfd/elfnn-loongarch.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index e8632905019..7b493f6f05b 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -2611,9 +2611,14 @@ loongarch_elf_relocate_section (bfd *output_bfd, str= uct bfd_link_info *info, bfd_vma relocation, off, ie_off, desc_off; int i, j; =20 + /* When an unrecognized relocation is encountered, which usually + occurs when using a newer assembler but an older linker, an error + should be reported instead of continuing to the next relocation. */ howto =3D loongarch_elf_rtype_to_howto (input_bfd, r_type); - if (howto =3D=3D NULL || r_type =3D=3D R_LARCH_GNU_VTINHERIT - || r_type =3D=3D R_LARCH_GNU_VTENTRY) + if (howto =3D=3D NULL) + return _bfd_unrecognized_reloc (input_bfd, input_section, r_type); + + if (r_type =3D=3D R_LARCH_GNU_VTINHERIT || r_type =3D=3D R_LARCH_GNU= _VTENTRY) continue; =20 /* This is a final link. */