Add DWARF support with libdw #1

Merged
ivan merged 7 commits from ivan/dwarf into master 2026-06-11 03:57:56 +02:00
Owner

DWARF is now parsed and shown, and binary diff is informed by the metadata.

DWARF is now parsed and shown, and binary diff is informed by the metadata.
Add DWARF support via libdw
All checks were successful
CI / build-test (push) Successful in 21s
c5ae2a061f
Optional elfutils libdw integration: a normalized DwarfInfo model
(dwarfinfo.{h,cpp}) decoded from the parser's existing mmap, a DWARF
TUI view (CUs, producer, concrete functions with inline-expansion
counts), a --dump section, addr2line-style source positions on FUNC
symbols, and DWARF function <-> symbol/disassembly cross-navigation.
Builds unchanged without libdw (NODW=1 forces the stub); tests gated
on require_libdw and cross-checked against readelf.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Thread per-side DWARF through the code diff: changed instructions gain
source-line annotations and a per-function "touches file:lines" summary,
inlining deltas are reported (including functions that vanished because
they were inlined into callers), same-named static functions pair by
decl file, and symbol-table gaps are filled from DWARF PC ranges.

Stack frame sizes are extracted from the call-frame info and diffed; a
function whose code is equivalent modulo regalloc but whose frame size
moved is surfaced instead of swallowed (different spills). New "Types"
category diffs record layouts (size + member offsets) for ABI drift,
and "DWARF units" reduces producer changes to their word-level delta
(-O0 -> -O2). The Header diff gains .riscv.attributes arch strings and
.comment compiler stamps, both independent of libdw.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
New "Data" diff category: byte-compares each object symbol's
initializer across the two files, masking relocation-covered words
first — addresses baked into .data move with layout and are noise,
while a changed constant in a same-sized config table is signal the
section and symbol diffs cannot see. Masked-only differences are
tallied, not listed; listed objects carry their changed byte ranges
as -/+ hex runs. DWARF (new DwarfVar extraction: any variable with a
DW_OP_addr location) annotates each item with the variable's
declaration position; without debug info only that annotation drops.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Qualify type names by their namespace/class chain (red::point and
blue::point no longer cross-match in the Types diff), then compare
repeat definitions of the same qualified name within one binary: a
layout mismatch is an ODR violation in C++ and header/LTO skew worth
seeing in any language. Conflicts surface in the single-file DWARF
view and --dump, and as a note on the diff's Types category, since
they make that name's cross-binary match ambiguous. Function-local
and anonymous-namespace types are exempt. Zero conflicts (and zero
false positives) across the LTO firmware corpus.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A Tensix op word built in a GPR (lui/addi/ori) and stored to the MMIO
instruction buffer at 0xFFE40000 reads as plain integer code, but is
the real payload. A linear dataflow tracker recognizes the pattern and
names the op (top byte) from a vendored Blackhole+Wormhole union of
tt-metal's ckernel_ops table: the materializing lui carries the
decoded mnemonic and word, the issuing store an "issue" tag, and a
changed function summarizes its delta (tensix -REPLAY +ZEROACC). Both
diff hunks and the section drill-in annotate; verdicts are never
affected. Synthetic rv32 fixtures committed under elfs/synth/.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Final fixes + new tests
Some checks failed
CI / build-test (push) Failing after 38s
382c12e629
Fix CI
All checks were successful
CI / build-test (push) Successful in 23s
CI / build-test (pull_request) Successful in 22s
2e5602fa9d
ivan merged commit e99036caa4 into master 2026-06-11 03:57:56 +02:00
ivan deleted branch ivan/dwarf 2026-06-11 03:57:57 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ivan/elfsight!1
No description provided.