[binutils-gdb] LoongArch: Reject foreign ELF inputs during relocation

liu zhensong liuzhensong@sourceware.org
Tue Nov 10 09:11:09 GMT 2026


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

commit 49465fb034a8e92b01589cf0ce8db2843de4218c
Author: zhaozhou <zhaozhou@loongson.cn>
Date:   Fri Oct 30 15:33:37 2026 +0800

    LoongArch: Reject foreign ELF inputs during relocation
    
    Reject non-LoongArch inputs before processing relocations.
    
    PR ld/34807

Diff:
---
 bfd/elfnn-loongarch.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 1c94748360f..f19049d59b3 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -3535,6 +3535,12 @@ loongarch_elf_relocate_section (struct bfd_link_info *info,
   asection *got = htab->elf.sgot;
   uint32_t insn;
 
+  if (!is_loongarch_elf (input_bfd))
+    {
+      bfd_set_error (bfd_error_wrong_format);
+      return false;
+    }
+
   loongarch_pcrel_relocs pcrel_relocs;
   if (!loongarch_init_pcrel_relocs (&pcrel_relocs))
     return false;


More information about the Binutils-cvs mailing list