public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: liu & zhensong <liuzhensong@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] LoongArch: ld:Report an error when seeing an unrecognized relocation
Date: Mon, 15 Apr 2024 01:55:41 +0000 (GMT)	[thread overview]
Message-ID: <20240415015542.060A13858D34@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5966e2eb3fed61ebe5c091a074b368b9238a68c1

commit 5966e2eb3fed61ebe5c091a074b368b9238a68c1
Author: Lulu Cai <cailulu@loongson.cn>
Date:   Thu Mar 21 15:16:05 2024 +0800

    LoongArch: ld:Report an error when seeing an unrecognized relocation
    
    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, struct bfd_link_info *info,
       bfd_vma relocation, off, ie_off, desc_off;
       int i, j;
 
+      /* 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 = loongarch_elf_rtype_to_howto (input_bfd, r_type);
-      if (howto == NULL || r_type == R_LARCH_GNU_VTINHERIT
-	  || r_type == R_LARCH_GNU_VTENTRY)
+      if (howto == NULL)
+	return _bfd_unrecognized_reloc (input_bfd, input_section, r_type);
+
+      if (r_type == R_LARCH_GNU_VTINHERIT || r_type == R_LARCH_GNU_VTENTRY)
 	continue;
 
       /* This is a final link.  */

                 reply	other threads:[~2024-04-15  1:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240415015542.060A13858D34@sourceware.org \
    --to=liuzhensong@sourceware.org \
    --cc=binutils-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).