aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfnn-loongarch.c
diff options
context:
space:
mode:
authorLulu Cai <cailulu@loongson.cn>2024-03-21 15:16:05 +0800
committerliuzhensong <liuzhensong@loongson.cn>2024-04-15 09:54:06 +0800
commit5966e2eb3fed61ebe5c091a074b368b9238a68c1 (patch)
tree50d6054a6a3ba4a9e4c9040d52579ada499838e0 /bfd/elfnn-loongarch.c
parent31a1b19e6ca8d83eadce9b5daef6f318aa0b42ca (diff)
downloadbinutils-5966e2eb3fed61ebe5c091a074b368b9238a68c1.zip
binutils-5966e2eb3fed61ebe5c091a074b368b9238a68c1.tar.gz
binutils-5966e2eb3fed61ebe5c091a074b368b9238a68c1.tar.bz2
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.
Diffstat (limited to 'bfd/elfnn-loongarch.c')
-rw-r--r--bfd/elfnn-loongarch.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index e863290..7b493f6 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. */