binutils Newspaper
JULY 29, 2026
ld/testsuite Committed

ld/testsuite: Add comprehensive PE COFF weak external tests

Tests for PE COFF weak externals have been applied upstream after fixing a build configuration issue.

This discussion covers the addition of comprehensive tests for PE COFF weak external symbols in the GNU linker’s test suite. Initial test failures were reported, but later diagnosed as stemming from an incorrect GCC configuration that bypassed the new linker. After resolving this configuration issue, the patch series was committed upstream. Potential pre-existing buffer overflow issues in handling fuzzed object files were also noted.

In the Thread 4 participants
  1. Peter Damianov proposer

    Submitted tests for PE COFF weak externals.

    “Add tests covering the full matrix of weak/strong symbol interactions for PE COFF weak externals, based on testcases by Martin Storsjo.”
  2. Alan Modra reviewer

    Reported test failures on a cross-build environment, specifically around duplicate weak definitions and undefined strong symbols with weak definitions.

    “On a cross build of x86_64-w64-mingw32 from x86_64-linux with gcc 13.2.0-6ubuntu1+26.1 installed, I see x86_64-w64-mingw32 +FAIL: weak external: strong undef + weak def (link) x86_64-w64-mingw32 +FAIL: weak external: duplicate weak defs (link)”
  3. Peter Damianov contributor

    Identified that the reported failures were likely due to the test environment using the system's default linker instead of the new one, due to GCC configuration.

    “ERROR: Your compiler apparently ignores -B when choosing ld. ERROR: Hint: don't configure gcc using --with-ld (or --with-as) ERROR: You will not be testing the new ld in many of the following tests. ERROR: It seems you will be testing /usr/bin/x86_64-w64-mingw32-ld instead.”
  4. Alan Modra maintainer

    Confirmed reproduction of failures after addressing the build configuration issue via symlinks and committed the patchset, noting potential pre-existing buffer overflow issues.

    “Right, I should have checked that before I tried your patch set, and worked around the compiler config problem by installing sym-links. I have committed your v3 patchset upstream. I think there are some potential buffer overflow problems reading aux entries from fuzzed object files, but at least some of those are pre-existing.”

Technical Tradeoffs

  • Increased test coverage for a specific linker feature.
  • Ensuring tests correctly target the intended linker version.
  • Addressing potential pre-existing issues in object file parsing.

In Details

This thread tracks the integration of new test cases for weak external symbols in PE COFF object files into the GNU linker's test suite. The tests, originally developed by Martin Storsjo, aim to cover the complex interactions of weak and strong symbols in this object file format. A key challenge encountered was ensuring the test suite actually invoked the newly built linker rather than a system default, which required workarounds related to GCC's linker configuration.

For Context
PE COFF
Portable Executable Common Object File Format, the executable file format used by Microsoft Windows.
Weak External
A symbol with a special linkage that allows it to be defined in multiple places, or not at all, with specific rules for resolving conflicts during linking.
ld
The GNU linker, responsible for combining object files and libraries into an executable or library.
testsuite
A collection of tests designed to verify the correctness of a software component.
Filed Under: linkerPE COFFweak symbolstest suitebinutils