Skip to content

DWARF Phase 2: address remap (#130) #143

@avrabe

Description

@avrabe

Sub-issue of #130 — Phase 2 of the witness-mapping epic.

v0.7 shipped Phase 1.5 (`DwarfHandling::Strip` default — stop being wrong). Phase 2 is the real fix: rewrite DWARF addresses across the merged code section so downstream MC/DC tooling (`pulseengine/witness`) can produce correct source-line attribution on fused output.

Scope

Per #130's plan §"Phase 2 — DWARF remap":

  • `.debug_line` rewrite. Single-pass line-program rewrite using the function-body relocation map the merger already builds. Addresses advance sequentially and meld preserves per-body byte offsets modulo index reencoding — straightforward.
  • `.debug_info` rewrite. DIEs that reference code addresses (`DW_AT_low_pc`, `DW_AT_high_pc`, `DW_AT_ranges`) get the same remap. CU concatenation with offset adjustments for multi-input cases.
  • `.debug_ranges` / `.debug_rnglists`. Entry-by-entry rewriting.
  • `.debug_str` / `.debug_abbrev` passthrough. Address-free; `.debug_str` needs string-pool dedup across inputs; `.debug_abbrev` merges if byte-equal, else stays per-CU.
  • New `DwarfHandling::Remap` variant on `FuserConfig` — opt-in initially, flipped to default once verified against witness on real-world fused modules.
  • End-to-end fixture: a fused module from `tests/wit_bindgen/fixtures/` driven through witness's gimli-based `(code-offset → file, line)` build path; assert >X% of `br_if` byte offsets get source attribution.

Dependencies

  • Add `gimli` (read) + a writer path to `meld-core`. Forking the writer-side logic into a thin standalone helper is OK if pulling the full gimli writer pulls too many deps.

Why not in v0.8 / v0.9

Real DWARF surgery is multi-day work. Witness integration is the verifier — needs the cross-repo loop set up. v0.10 is the soonest realistic milestone.

Out of scope

Rivet artifact

  • New requirement SR-35 — "DWARF address remap into merged code section".

Milestone

v0.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions