[binutils-gdb/binutils-2_41-branch] LoongArch: ld:Report an error when seeing an unrecognized relocation
liu & zhensong
liuzhensong@sourceware.org
Mon Nov 11 03:49:49 GMT 2024
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1a1d001f91a2f78d371b3e6bb2311304872d7b17
commit 1a1d001f91a2f78d371b3e6bb2311304872d7b17
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.
(cherry picked from commit 5966e2eb3fed61ebe5c091a074b368b9238a68c1)
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 db9f106a8b0..c051edb99ba 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -2383,9 +2383,14 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
bfd_vma relocation, off, ie_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. */
More information about the Binutils-cvs
mailing list