LoongArch: Fix relocation of ignored undefined symbols
LoongArch linker now correctly handles ignored undefined symbols during relocation for call instructions, preventing BFD assertions.
This patch addresses an issue in the LoongArch linker where ignored undefined symbols were treated as dynamically resolved. When such symbols were involved in call relocations and lacked a PLT entry, it could lead to a BFD assertion failure. The fix ensures that for call relocations, ignored undefined symbols are handled appropriately by treating them as undefined weak symbols when no PLT entry is available, thus preventing the assertion.
- proposer
Submits a patch to fix how LoongArch relocations handle ignored undefined symbols, preventing BFD assertion failures.
“For LoongArch, an ignored undefined symbol that fails to resolve locally is treated as dynamically resolved. Enable --unresolved-symbols=ignore-all Branch and call relocations of ignored undefined symbol could request a non-exist PLT entry thus trigger a BFD assertion.”
In Details
This patch series for the LoongArch backend of binutils addresses a bug in relocation handling for ignored undefined symbols. When the linker is configured with --unresolved-symbols=ignore-all, previously undefined symbols that couldn't be resolved locally were incorrectly treated as dynamically resolved. This led to a BFD assertion when a call relocation was attempted for such a symbol without a corresponding PLT entry. The fix modifies bfd/elfnn-loongarch.c to specifically handle call relocations for ignored undefined symbols, treating them as weak symbols when no PLT entry exists.
- LoongArch
- A 64-bit instruction set architecture developed by the Loongson Technology Corporation, primarily used in China.
- relocation
- The process of updating symbolic references in object code to absolute addresses or other information needed to create an executable or shared library. This is typically done by the linker.
- ignored undefined symbols
- Symbols that are referenced but not defined within the current compilation unit, and are explicitly marked to be ignored by the linker (e.g., using
--unresolved-symbols=ignore-all). - PLT
- Procedure Linkage Table, a table used in dynamically linked executables to hold addresses of functions that are not part of the executable itself but are called by it.
- BFD assertion
- An assertion failure within the BFD (Binary Description Format) library, which is part of GNU Binutils and handles various object file formats. Such failures indicate a programming error or an unexpected state.