[PATCH] LoongArch: Reject foreign ELF inputs during relocation
Alan Modra
amodra@gmail.com
Tue Nov 10 04:49:06 GMT 2026
On Fri, Oct 30, 2026 at 03:33:37PM +0800, zhaozhou wrote:
> Reject non-LoongArch inputs before processing relocations.
>
> PR ld/34807
> ---
> bfd/elfnn-loongarch.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> index 15f44420b4c..c96e0806bc6 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;
> --
> 2.20.1
OK.
--
Alan Modra
More information about the Binutils
mailing list