binutils Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
bfd

bfd: Handle PE weak externals with real fallbacks in archives

BFD now correctly handles PE weak externals with real fallback definitions in archives for linking.

This commit addresses an issue in BFD where PE weak externals with real fallback definitions within archives were not correctly handled. Previously, these symbols were canonicalized as undefined, preventing the linker from extracting the correct archive member when a strong undefined reference occurred. The fix ensures these weak externals are included in the archive map when a valid fallback exists, and avoids redundant extraction of archive members.

In Details

PE weak externals, when present in archives, were previously canonicalized as undefined BFD symbols even if they had a real fallback definition in the same object. This prevented _bfd_compute_and_push_armap from including them in the archive symbol map. Consequently, a strong undefined reference to such a symbol could not resolve by extracting the archive member. This patch introduces bfd_coff_pe_weak_external_has_real_fallback to identify these cases and correctly add them to the armap. It also optimizes archive searches by not re-extracting members for already resolved PE weak externals.

For Context
BFd
A Binary File Descriptor library. It provides a common interface for reading and writing various executable file formats (like ELF, COFF, a.out) and object files.
PE weak external
A symbol within the Windows PE (Portable Executable) format that has weak linkage and is defined as an external reference, allowing for an optional fallback definition.
archive file
A file (often with a .a or .lib extension) that contains multiple object files bundled together. The linker can extract individual object files from an archive to satisfy symbol references.
symbol map
A data structure used by the linker and other tools that maps symbol names to their addresses or other attributes. In BFD, the archive map (armap) lists symbols from archive members.
undefined symbol
A symbol that is referenced in an object file but not defined within it. The linker's job is to resolve these references by finding definitions in other object files or libraries.
Filed Under: bfdlinkerpe coffweak symbolsarchives