binutils Newspaper
JUNE 15, 2026
pe-coff Proposed

PE-COFF: Fix weak external symbol resolution bugs

This series fixes two bugs related to PE COFF weak external symbol resolution in the BFD linker and adds testsuite coverage.

This patch series addresses two bugs in the BFD linker related to PE COFF weak external symbol resolution. The first patch fixes an issue where the linker loses the weak symbol’s aux record and fails to resolve the fallback alias when a strong undefined reference is seen first. The second patch corrects the handling of two weak externals for the same symbol, ensuring the linker prefers a real definition over NULL. The series also includes a new test suite covering a wide range of weak/strong symbol interactions.

In the Thread 1 participant
  1. Peter Damianov <peter0x44@disroot.org> proposer

    This series fixes bugs in PE COFF weak external symbol resolution in the BFD linker and adds testsuite coverage.

    “This series fixes two bugs in the PE COFF weak external symbol resolution in the BFD linker, plus adds testsuite coverage.”

In Details

The series modifies bfd/cofflink.c to fix weak external symbol resolution and adds a new test suite in ld/testsuite/ld-pe/. The first patch addresses issues with strong undefined references, while the second prefers defined fallbacks over null fallbacks. The test suite provides comprehensive coverage of weak/strong interactions.

For Context

This patch series focuses on the PE COFF file format, commonly used for executables on Windows. It fixes two bugs related to how the linker handles 'weak symbols'. Weak symbols are optional; if a strong symbol isn't found, the linker may use the weak symbol as a fallback. The first bug fix ensures that the linker correctly resolves weak symbols even when a strong, but undefined, symbol is encountered first. The second fix ensures that the linker prefers a valid fallback definition over a null definition. A new test suite validates these fixes and improves the robustness of the linker.

Filed Under: PE-COFFlinkerweak symbolssymbol resolutionbfd