feat(dwarf): AddressRemap engine (#143 DWARF Phase 2 inc 3a)#204
Merged
Conversation
The mathematical core of DWARF address remapping: composes the two
anchors from v0.16.0 (per-function base via component-provenance v2
code_range) and v0.17.0 (intra-function InstrOffsetMap) into one
input→output code-address translation.
- meld-core/src/dwarf.rs: FunctionSpan + AddressRemap with
translate(input_addr) -> Option<output_addr>
- reconciles the three byte-offset spaces (input DWARF address,
instruction-stream offset, output DWARF address), accounting for
the locals-prefix length that cancels between input and output
- BTreeMap range lookup picks the containing function span; misses
(outside any function, off an instruction boundary, inside the
locals prefix) return None so the gimli converter drops the
address rather than emitting a wrong one
6 unit tests: identity offsets, instruction-offset shift (LEB
growth), locals-prefix handling, multi-function selection, miss
cases, and locals-prefix underflow guard.
This is increment 3a (the engine). Increment 3b wires it into a
gimli write::Dwarf::from(convert_address) rewrite of the .debug_*
sections behind a new DwarfHandling::Remap mode. gimli was added then
removed here to avoid shipping an unused dependency — it returns in
3b where it is actually used.
301 lib tests green, clippy + fmt clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
LS-N verification gate
Approved Failed LS entries(none) Missing regression tests
Updated automatically by |
avrabe
added a commit
that referenced
this pull request
May 29, 2026
DWARF Phase 2 increment 3a (#143, #204): the AddressRemap engine — composes the per-function base (provenance v2 code_range, v0.16.0) and intra-function InstrOffsetMap (v0.17.0) into input→output code-address translation. The mathematical core of DWARF address remapping. Increment 3b (gimli write::Dwarf::from section rewrite + DwarfHandling::Remap mode) follows in a later release. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The mathematical core of DWARF address remapping. Composes the two anchors already released:
code_rangeInstrOffsetMap— LEB-drift trackinginto
AddressRemap::translate(input_addr) -> Option<output_addr>: an input code-section-relative DWARF address → its fused-output address.The three offset spaces (the whole game)
meld-core/src/dwarf.rsreconciles:InstrOffsetMapkeys onThe locals-prefix length is identical input↔output (locals are preserved verbatim in the DWARF-remap path), so it cancels — recorded once per
FunctionSpan.Tests (6)
identity offsets · instruction-offset shift (LEB growth) · locals-prefix handling · multi-function selection via BTreeMap range lookup · miss cases (outside functions / mid-instruction / past end) · locals-prefix underflow guard
Scope
This is increment 3a — the engine. Increment 3b wires it into a
gimli::write::Dwarf::from(convert_address)rewrite of the.debug_*sections behind a newDwarfHandling::Remapmode. gimli was added then removed in this PR to avoid shipping an unused dependency; it returns in 3b where it's actually used.Test plan
dwarf::testsgreen🤖 Generated with Claude Code