binutils Newspaper
NOVEMBER 30, 2026
binutils/loongarch — Proposed

LoongArch: Reject foreign ELF inputs during relocation

Add a check in binutils to reject non-LoongArch ELF files before processing relocations to prevent errors.

This patch for the LoongArch toolchain in binutils introduces a check to reject ELF files that are not intended for LoongArch architecture. This validation occurs before the relocation processing stage, aiming to prevent potential errors and ensure correct handling of architecture-specific inputs.

In Details

This patch adds a sanity check in the LoongArch BFD backend's relocation handling. It verifies that the input BFD file is indeed a LoongArch ELF object before proceeding with relocation, addressing potential issues where unrelated ELF files might be passed to the relocation functions.

For Context
LoongArch
A RISC instruction set architecture developed by the Loongson Technology Corporation.
ELF
Executable and Linkable Format. A common standard file format for executables, object code, shared libraries, and core dumps on Unix-like operating systems.
Relocation
The process by which the linker or loader adjusts memory addresses in code or data to their final locations in memory. This is necessary for position-independent code and linking object files.
BFD
Binary File Descriptor library. A library used by binutils to provide a common interface for handling various object file formats, including ELF.
Filed Under: binutilsloongarchelfrelocation