binutils Newspaper
NOVEMBER 30, 2026
windows — Proposed

Windows linker errors with LTO symbols and plugins

Patch addresses linker errors on Windows when using LTO objects with plugins, where late symbol references cause 'defined in discarded section' errors.

This patch addresses a linker error on Windows occurring when linking objects compiled with Link Time Optimization (LTO). The issue arises when linker plugins claim symbols as GIMPLE, leading to problems with late references. These late references, appearing after the plugin has run, cause the linker to incorrectly report symbols as defined in discarded sections, preventing the link. The proposed solution involves modifying how symbols are handled to prevent this conflict.

In Details

This issue concerns the interaction between binutils' linker (ld.exe), Link Time Optimization (LTO), and linker plugins on Windows. Specifically, it addresses a race condition or incorrect handling of symbol resolution when a linker plugin claims symbols as GIMPLE IR. Late references to these symbols, occurring after the plugin's initial pass, cause the linker to fail because the symbol's definition is found in a section marked for exclusion (SEC_EXCLUDE), which the plugin might have used for intermediate storage.

For Context
Link Time Optimization (LTO)
A compiler optimization technique where optimization across multiple object files is performed during the linking stage, rather than per compilation unit.
linker plugin
An extension mechanism for the GNU linker (ld) that allows third-party tools or custom logic to participate in the linking process.
GIMPLE
GCC's internal representation language used for optimization after parsing.
SEC_EXCLUDE
A section flag in object files indicating that the section should not be included in the final executable.
ld.exe
The GNU linker executable, commonly used on Windows via MinGW or Cygwin.
Filed Under: binutilslinkerwindowsLTOplugin