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

Remove assertion in COFF symbol name retrieval

Changes COFF symbol name retrieval to return NULL instead of asserting on invalid offsets.

This commit modifies the _bfd_coff_internal_syment_name function in BFD to return NULL when a symbol’s offset is invalid, rather than triggering an assertion. This change prevents crashes when encountering malformed COFF symbol tables, improving robustness.

In Details

The _bfd_coff_internal_syment_name function previously asserted if sym->_n._n_n._n_offset was less than STRING_SIZE_SIZE. This assertion is removed, and instead, the function now checks if the offset is less than STRING_SIZE_SIZE or greater than or equal to the available string table length. If either condition is true, it returns NULL. This makes the handling of malformed symbol table entries more graceful.

For Context
BFD
The Binary Descriptor library, a portable interface for manipulating binary object files.
COFF
Common Object File Format, a file format for executables, object code, and shared libraries used on Unix-like systems.
assertion
A statement in a program that checks a condition that the programmer believes to be true; if the condition is false, the program typically terminates.
symbol name retrieval
The process of extracting the name of a symbol (e.g., a function or variable) from an object file's symbol table.
offset
A numerical value indicating a specific position or distance from a reference point, often the beginning of a file or data structure.
Filed Under: bfdcoffrobustness