Skip to content

P3: PE/COFF backend, MinGW (windows-gnu) ABI #7

Closed as not planned
Closed as not planned

Description

@zackees

Part of #2. Full spec: 05-PHASE-3-WINGNU.md

The largest phase. gnu before msvc because DWARF needs only section concatenation plus two relocation kinds, whereas MSVC needs PDB — ~20k lines in radlink, larger than its entire linking core.

Group A — plumbing

  • P3-T1 generalize the relocation vocabulary. Most invasive change; do it first, alone, on ELF, and prove ELF still passes. Must add ImageRelative, SectionRelative, SectionIndex — the last two are mandatory, MinGW DWARF is full of them
  • P3-T2 COFF file-kind sniffing (incl. /bigobj)
  • P3-T3 CoffArgs — note dialect and format are independent axes; MinGW drives a GNU-syntax ld, selected via -m i386pep
  • P3-T4 ObjectFile impl. COFF addends are in-place in section bytes, REL-style
  • P3-T5 Platform impl. coff feature on by default — unlike wild's macho, which is gated off and panics at runtime

Group B — semantics

  • P3-T6 COMDAT selection, all six kinds. Port radlink's lnk_can_replace_symbol case-for-case; it is effectively a spec. Watch the two traps: a common symbol is a COMDAT with select=LARGEST, and ANY-vs-LARGEST promotes both to LARGEST
  • P3-T7 weak externals (not ELF weak symbols — they carry a characteristics field)
  • P3-T8 grouped-section $ ordering

Group C — output

  • P3-T9 PE headers · P3-T10 x86_64 relocations (apply during the copy, per mold) · P3-T11 base relocations · P3-T12 .pdata/.xdata (pleasantly small — compiler emits it, we sort by RVA) · P3-T13 imports/IAT via synthetic objects · P3-T14 exports/DLL · P3-T15 DWARF passthrough — the payoff · P3-T16 TLS (~35 lines) · P3-T17 MinGW CRT/entry/.ctors · P3-T18 --gc-sections

Not supported in v0, must error clearly: auto-import/pseudo-relocs, delay-load, /GUARD:CF, linker scripts.

Done when: ci/gate-wingnu.sh exits 0 — including a scripted gdb breakpoint hit and a DLL round-trip.

Activity

  1. added
    enhancement
    on Aug 1, 2026
  2. zackees commented on Sep 18, 2026

    @zackees
    CollaboratorAuthor

    Closing as superseded (owner decision, recorded in #154). This issue's premise was to retrofit a COFF backend into wild for the MinGW ABI. #91 decided Windows goes through an LLD-COFF fork instead. That fork, zackees/llvm-ld, already contains LLD's MinGW PE/COFF driver, so windows-gnu support arrives through #96. Keeping this open would imply a second, competing Windows implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions