fix(dwarf): remap DW_AT_high_pc lengths to the fused layout (#319 inc 1)#320
fix(dwarf): remap DW_AT_high_pc lengths to the fused layout (#319 inc 1)#320avrabe wants to merge 2 commits into
Conversation
meld fuse produced DWARF that fails `llvm-dwarfdump --verify` with hundreds of out-of-parent + overlapping DIE address ranges, though the inputs verify clean. Root cause: gimli routes only *address*-form values through convert_address; `DW_AT_high_pc` encoded as a length (`DW_FORM_udata`, the common Rust/LLVM form) is a constant it copies verbatim. Fused bodies change length (LEB re-encode of the merged index space), so every subprogram/block/inlined DIE became `[remapped_low, remapped_low + STALE_input_len)` — overrunning its parent (grew) or the next function (shrank). Fix: after the gimli conversion, walk the write DIEs and rewrite each `low_pc`+`high_pc`-length pair to the fused output length via a new `AddressRemap::corrected_high_pc` — invert the remap for `low_pc` within its output body, then take the span's `output_body_end` for a range ending at the function end (avoids the aliased-boundary translate() None) or `translate` for interior ends (lexical blocks / inlined subroutines). Tombstoned (dropped) low_pc is left untouched — llvm-dwarfdump ignores those DIEs. Effect on the #319 repro (records+variants): overlapping 480 -> 0, out-of-parent 534 -> 11 (~96% of errors cleared; 1049 -> 46). Residual 11 (nested DW_AT_ranges on inlined/lexical DIEs) and Cause #2 (.debug_loc tombstone vs base-address-selection escape, 18+17) are distinct mechanisms tracked as follow-up increments on #319. Test: corrected_high_pc_rewrites_length_to_fused_layout (grew/shrank/interior/ tombstone). 24 dwarf tests pass. Refs: #319. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
LS-N verification gate✅ 58/58 approved LS entries verified
Approved Failed LS entries(none) Missing regression tests(none) Updated automatically by |
… body Mythos delta-pass hardening for #320. A DIE whose high_pc length exceeds its own function body would translate into the NEXT function and emit a plausible-but-wrong length (the LS-D-1 class). Unreachable from valid toolchain output (subprograms end at input_end; nested ranges stay interior; CUs use DW_AT_ranges not high_pc), but guard it explicitly: bail and leave the attribute unchanged rather than correct across a function boundary. Test: corrected_high_pc(len past body) -> None. Refs: #319. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mythos delta-pass — NO FINDINGS (meld-core/src/dwarf.rs)Ran the discover protocol on this PR's
No failing oracle for any wrong-attribution defect. Adding |
Mythos delta-pass (auto)✅ NO FINDINGS across 1 Tier-5 file(s)
Auto-run via |
What
Fixes the dominant cause of #319 —
meld fuseproducing DWARF that failsllvm-dwarfdump --verifywith hundreds of out-of-parent + overlapping DIE ranges.Root cause
gimli routes only address-form values through
convert_address;DW_AT_high_pcencoded as a length (DW_FORM_udata, the common Rust/LLVM form) is a constant it copies verbatim. Fused bodies change length (LEB re-encode of the merged index space), so every subprogram/lexical-block/inlined DIE became[remapped_low, remapped_low + STALE_input_len)— overrunning its parent (grew) or the next function (shrank).Fix
After the gimli conversion, walk the write DIEs and rewrite each
low_pc+high_pc-length pair via a newAddressRemap::corrected_high_pc: invert the remap forlow_pcwithin its output body, then use the span'soutput_body_endwhen the range ends at the function end (avoids the aliased-boundarytranslate()None) ortranslatefor interior ends. Tombstoned (dropped)low_pcis left untouched — llvm-dwarfdump ignores those DIEs.Measured (records+variants repro)
Scope
Inc 1 clears ~96% (all overlapping + 98% of out-of-parent). Residual is distinct mechanisms tracked as follow-ups on #319: nested
DW_AT_rangeson inlined/lexical DIEs (11/4 not-contained), and the.debug_loctombstone-vs-base-selection collision (Cause #2, invalid-expr/loc).Test:
corrected_high_pc_rewrites_length_to_fused_layout(grew/shrank/interior/tombstone) — deterministic, no llvm-dwarfdump dependency. 24 dwarf tests pass.Refs: #319.
🤖 Generated with Claude Code