binutils Newspaper
OCTOBER 6, 2026
ld-pe — Proposed

ld-pe: Add support for -undefined, -include directives

Extends PE linker support for undefined symbol directives and DEF module-definition files.

This patch enhances the PE (Portable Executable) linker’s capabilities by adding support for specifying undefined symbol names. This can now be done through linker directives within COFF object files’ .drectve section or as statements in DEF module-definition files. This functionality is crucial for retaining symbols with the used attribute, preventing them from being discarded by the compiler or linker, similar to ELF’s retain attribute.

In Details

This change modifies the PE (Windows Portable Executable) linker within GNU binutils to recognize and process directives related to undefined symbols. It extends support to both the .drectve section in COFF objects and standard DEF (module-definition) files. The primary motivation is to correctly handle symbols marked with the used attribute, ensuring they are not optimized away by the toolchain, aligning PE behavior with similar mechanisms in ELF.

For Context
ld-pe
The GNU linker's backend for handling Portable Executable (PE) files, commonly used on Windows.
COFF
Common Object File Format, a file format for object files used on Windows and other systems.
DEF module-definition files
Text files used with Windows linkers to define module properties, such as exported functions and data.
used attribute
A compiler attribute that marks a symbol as being used, preventing the compiler or linker from discarding it, even if it appears unused.
retain attribute
An ELF-specific attribute that serves a similar purpose to the 'used' attribute, preventing symbols from being discarded.
Filed Under: linkerpecoffsymbols