binutils Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
binutils/bfd

Validate sym_hashes when reading relocations for ELF files

Binutils BFD now performs stricter validation of symbol hashes when processing ELF relocations.

This update enhances the robustness of BFD’s ELF linker by introducing stricter validation when reading relocations. It ensures that the STN_UNDEF symbol is present when required and verifies that the elf_sym_hashes array entries referenced by relocations are not NULL. This change addresses issues related to malformed object files and improves the reliability of the linking process.

In Details

This commit modifies elf_link_read_relocs_from_section in elflink.c to enforce stricter checks on ELF relocation processing. A new flag, sym_hashes_valid, is introduced in struct elf_obj_tdata and set in elf_link_input_bfd. The validation now includes ensuring STN_UNDEF is present and that elf_sym_hashes entries are not NULL, addressing PR 9934. This makes the linker less tolerant of malformed object files where relocations might reference invalid symbol hash entries.

For Context
sym_hashes
An array of hash table entries for symbols, used by BFD's ELF linker to efficiently look up symbol information during relocation processing.
relocation
Information in an object file that describes how to modify certain addresses or symbols when linking. For example, a relocation entry might indicate that a specific address needs to be updated with the actual address of a function.
STN_UNDEF
A special symbol table index in ELF that represents an undefined symbol, typically a function or variable that is defined in another object file or shared library.
ELF
Executable and Linkable Format. A common standard file format for executables, object code, shared libraries, and core dumps on Unix-like systems.
BFD
Binary File Descriptor library. A library used by GNU Binutils to provide a generic interface for reading and writing various binary file formats, including ELF.
Filed Under: elflinkingbfdvalidationrelocations