Skip to content

[AUTOMATED] fix(p9): cppcallnames - render a C++ callee's qualified name at the call site (DIV-59) - #262

Merged
mahaloz merged 1 commit into
mainfrom
feat/cppcallnames
Aug 5, 2026
Merged

mahaloz merged 1 commit into
mainfrom
feat/cppcallnames

Conversation

@mahaloz

@mahaloz mahaloz commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What

kuna printed sub_<addr> at every call to a demangled C++ function on an
unstripped binary — for a name it already had. kuna functions listed
Account::deposit; kuna decompile <bin> 'Account::deposit' resolved and
decompiled by that name; only the call site lost it. IDA Pro 9.2 and Ghidra 12.1
both render the qualified name on the same bytes.

Captured on the vendored fixture cpp_noreturn_x86_64 (no probe needed — this
reproduces in-tree):

$ kuna decompile decompiler/crates/kuna-analysis/tests/fixtures/cpp_noreturn_x86_64 fail
  void fail(void)
  {
-   sub_401070(); // no-return
+   std::terminate(); // no-return
  }

A second, independent defect closed here — --addr never applied the known symbol
name, so the same function printed two different headers depending on how you
selected it:

$ kuna decompile ...cpp_noreturn_x86_64 --addr 0x401070
- void sub_401070(void)
+ void std::terminate(void)
  {
    (*dat_404018)(); // jump-as-call

And on a purpose-built probe (g++ -O0), the shape the report was filed on:

  int4 probe_member_fields(void *a,int4 amount)
  {
    ...
-   d = sub_271c(a,amount);
-   v = sub_2776(a);
+   d = Account::deposit(a,amount);
+   v = Account::available(a);
    o = 5;
-   sub_279c(a,&o);
+   Account::bump(a,&o);
    return o + d + v;
  }

IDA 9.2 on the same binary: d = Account::deposit(a, amount); — identical modulo
variable naming.

Why (the real mechanism, not the obvious one)

Three plausible causes are all wrong, and were checked: the name is not stored
only as an alias, there is no identifier filter rejecting ::, and the call-site
path reads the same symbol table kuna functions does. It is also not a demangler
defect — a demangled name with no namespace (_Z8topleveli → toplevel) rendered
fine all along.

It is scope shadowing in the gated-commit seam, and it is mode-dependent:

surface Account::deposit call site
--mode reliable Account::deposit(a,amount) ✅
default (auto → aggressive under 500 KiB) sub_271c(a,amount) ❌
--option fast_funcdisc off --option funcstart_patterns off Account::deposit(a,amount) ✅
  1. read_loader_symbols installs a demangled funcsym in its namespace scope —
    std::terminate is base terminate in scope std.
  2. A discovery pass (fast_funcdisc / funcstart_patterns, both in
    AGGRESSIVE_OVERRIDES) re-reports the same VMA.
  3. commit_analysis_output's discovered-entry arm named it sub_<addr>, resolved
    that synthetic name to a scope — no ::, so GLOBAL — and probed
    find_function(scope, addr) in that scope only. It missed the real symbol
    and installed a duplicate generic FunctionSymbol in GLOBAL at the same address.
  4. FlowInfo::queryCall resolves through find_function_across_scopes, which
    searches global first. It found the duplicate.

Turning off either discovery pass alone did not restore the names — both report
the VMA, so either one suffices to install the duplicate. The in-source comment
claiming the probe "still lets a real .symtab/.dynsym name win on a non-stripped
binary" was false for every ::-qualified symbol, and find_function_across_scopes
already documented the hazard verbatim; the two facts had simply never been
connected.

The fix: resolve the idempotence probe across scopes — the port of C++
Scope::queryFunction, which spans the scope tree. Discovery is unchanged: the
passes still run, still find the same VMAs, a genuinely unnamed find is still
sub_<addr>, and register_symbol is untouched so sub_<addr> remains a working
selection alias.

Why nothing caught it

  • Every tests/datatests/ and tests/stages/ file is an XML <binaryimage>, and
    that bootstrap never produces an AnalysisOutput — commit_analysis_output is a
    structural no-op there, so neither corpus can reach the defect.
  • verify_noreturn_demangle drives the console with shipped defaults (no
    discovery pass), where the duplicate is never created. It printed
    std::terminate() and passed — while the CLI on that same fixture printed
    sub_401070(). No test asserted the CLI render. Now one does.

No option

Deliberate, for three reasons:

  1. There is no driver-tier option axis. All 76 phases.toml settables carry an
    engine phase P1–P9; kuna-console/kuna-cli only ever write options. Gating
    this would mean inventing an axis, not filling in a row (precedent:
    --max-fn-seconds, "Driver policy, not a stage-model settable").
  2. The "after" behavior already ships under --mode reliable. This removes an
    inconsistency in which two of four modes silently lost names the other two kept.
  3. There is no judgment in it. A synthetic placeholder shadowing a real symbol
    at the same address is wrong under every naming policy, namestyle ghidra
    included.

docs/history.md DIV-59 records it.

Sweep — decompile-all before vs after, 13 binaries, every line classified

  8 C binaries   : byte-identical  (incl. /bin/grep 35,070 lines, /usr/bin/ls 14,788)
  5 C++ binaries : 184 changed lines
                     181 CALL-RENAME        <- the fix
                       3 ADDR-TAKEN-RENAME  <- pre-existing path, see below
                       0 unexplained

Every C++ diff is exactly -N/+N: no line added or removed, no structural or
signature change anywhere. Plain C is untouched structurally — a C symbol has no
::, so the global-only probe always found it and no duplicate was ever created.

Discovery itself is provably unchanged: kuna functions --json before vs after over
15 discovery fixtures (ARM/Thumb, Cortex-M, AArch64, RISC-V, Mach-O, i386-PIE,
funcstart_patterns, aif_gap, stripped ELF) — zero entries lost, gained, or
renamed
on any of them. The fix only changes naming when a function already exists
at the exact same address in a non-global scope.

The 3 address-taken lines (sub_2ca0 → perimeter, sub_2d20 → emit,
sub_401120 → ~runtime_error) render the symbol's base name, because
Funcdata::link_spacebase_symbol binds the unscoped name_for_global_varnode
where the sibling ActionNameVars path uses name_for_global_varnode_scoped +
kuna_qualify_global_name. That gap is pre-existing and unrelated: on main the
same fixture already emits {virtual override thunk} in exactly that position and
void Account::~Account(void) as a function header. Recorded as a follow-up.

Recompilability (the ::-in-a-C-header question)

Measured, not assumed. The header is bit-identical before and after, and C
output is untouched on every axis:

artifact :: ~ident {…} gcc -fsyntax-only errors
fmt_x86_64 (C) .c + .h — before 0 0 0 8
fmt_x86_64 (C) .c + .h — after 0 0 0 8
probe_O0 (C++) .h — before 122 22 3 —
probe_O0 (C++) .h — after 122 22 3 —
probe_O0 (C++) .c — before 246 44 6 316
probe_O0 (C++) .c — after 410 93 6 407

A C++ project export already failed to compile as C in 316 places; nothing
recompilable regresses, and the header this PR was warned about is produced from the
canonical function names, which this change does not alter. The .c bodies gain
:: at call sites — the point of the fix, and what IDA and Ghidra print. Since C
output is byte-identical, no C-binary recompile metric can move.

A sanitized identifier spelling for the export path is a genuinely separate feature
(it must rewrite .h and .c consistently, including the pre-existing
Account::~Account headers); filed as follow-up 1 in
docs/features/cppcallnames/analysis.md.

Gates

gate result
make test PARITY OK — 675/675, no re-pin
make test-stages PARITY OK — 394/394, no re-pin
make rust-test green
make check-spec OK
kuna catalog --check catalog OK

Speed

No option to flip, so scripts.pipeline.timeit (which times one binary off vs on)
does not apply — same as DIV-58. Arms are the pre-change kuna and this build,
interleaved, minimum of 11 pairs (the box is shared with concurrent agents, so
medians are contaminated: a first 5-pair pass reported +40.96% on probe_O0 that the
11-pair minimum resolves to −0.46%).

surface binary before after Δ
decompile-all probe_O0 (C++, ~150 namespace scopes) 358.1 ms 356.5 ms −0.46%
decompile-all cpp_noreturn (C++) 111.7 ms 110.4 ms −1.14%
decompile-all eh_lsda (C++) 118.9 ms 117.6 ms −1.12%
functions probe_O0 (load + commit only) 149.2 ms 142.8 ms −4.29%
decompile-all /usr/bin/ls (C, stripped) 31,445 ms 31,030 ms −1.32%
functions /bin/grep (C, stripped) 617.2 ms 616.8 ms −0.06%

Worst delta −0.46%, budget 5%. The added work is one probe per discovered entry;
find_function_across_scopes still hits the global scope first and walks the rest
only on a miss.

Tests

decompiler/crates/kuna-console/tests/verify_cppcallnames.rs — real engine over the
already-vendored cpp_noreturn_x86_64, discovery passes enabled in the live-CLI
order (option before read symbols):

  1. the namespaced callee renders qualified, and no sub_401070 shadows it;
  2. load addr 0x401070 names the function from the symbol table;
  3. control — discovery still names genuinely-unknown finds sub_<addr>, and an
    explicit load addr <vma> <name> still wins.

Ablated against the pre-fix sources (files copied aside — never git stash, it is
shared across worktrees): 1 passed / 2 failed, both defect gates failing and the
control passing. A gate that passes either way proves nothing.

No tests/stages/*.xml: structurally impossible for the primary defect (see "Why
nothing caught it"), so no corpus-count bump and no stages-baseline re-record.

One existing test moved, and it is worth naming

verify_multiformat_dwarf used load addr — with the DWARF pass still on — as
its "no-DWARF-name baseline", asserting sub_140001550 / sub_0. That only held
because load addr ignored the symbol table: the test was pinning the bug. Its
baseline arm now turns the pass off (option dwarf off), which is what it always
meant, and the claim gets stronger:

  • PE — nothing else names 0x140001550 (the COFF FUNC entry is
    --strip-symbol-removed), so sub_140001550 is unchanged and now actually tests
    the absence of DWARF rather than the absence of a lookup.
  • Mach-O — with DWARF off the --redefine-symed symtab entry _l0 remains, so
    the baseline asserts _l0. "The symtab says _l0 here, not first_byte" is a
    sharper statement of DWARF-only than a placeholder was.

Both DWARF-recovery assertions are untouched. This was the only test in the
workspace that moved.

Files

file change
kuna-console/src/engine.rs discovered-entry commit arm: cross-scope idempotence probe
kuna-console/src/ifacedecomp.rs IfcAddrrangeLoad: prefer the installed qualified name
kuna-console/tests/verify_cppcallnames.rs new — 3 tests
docs/spec/00-overview.md §0.1 commit idempotence is cross-scope; §0.2 both selection forms name identically
docs/history.md DIV-59
docs/features/cppcallnames/ analysis.md, plan.md, record.json

…ame at the call site (DIV-59)

kuna printed `sub_<addr>` at every call to a demangled C++ function on an
unstripped binary, for a name it already had: `kuna functions` listed
`Account::deposit`, decompiling by that name worked, and `--mode reliable`
rendered `d = Account::deposit(a,amount);` -- while the default (`auto` ->
`aggressive` under 500 KiB) rendered `d = sub_271c(a,amount);`.

Root cause is scope shadowing in the gated-commit seam, not the demangler.
`read_loader_symbols` installs a demangled funcsym in its NAMESPACE scope
(`std::terminate` = base `terminate` in scope `std`); a discovery pass
(`fast_funcdisc` / `funcstart_patterns`, both in AGGRESSIVE_OVERRIDES) then
re-reports the same VMA, and `commit_analysis_output`'s discovered-entry arm
named it `sub_<addr>`, resolved that synthetic name to a scope (no `::` ->
GLOBAL) and probed `find_function(scope, addr)` in that scope ONLY. It missed
the real symbol and installed a duplicate generic FunctionSymbol in GLOBAL;
`FlowInfo::queryCall` resolves through `find_function_across_scopes`, which
searches global first, so the duplicate shadowed the real name everywhere.

The probe now resolves across scopes -- the port of C++ `Scope::queryFunction`,
which spans the scope tree. Discovery is unchanged: the passes still run, still
find the same VMAs, a genuinely unnamed find is still `sub_<addr>`, and
`register_symbol` is untouched so `sub_<addr>` stays a working selection alias.

Second, independent defect closed here: `IfcAddrrangeLoad` jumped straight to
`Architecture::name_function`, so `kuna decompile <bin> --addr <vma>` printed a
`sub_<addr>` header on an unstripped binary while the by-name path printed the
real name. It now prefers the qualified FunctionSymbol installed at that address;
an explicit `load addr <vma> <name>` still wins.

No option: this is the driver tier, which has no settable axis (all 76
phases.toml rows carry an engine phase P1-P9); the post-fix rendering already
ships under `--mode reliable`; and a synthetic placeholder shadowing a real
symbol at the same address is wrong under every naming policy.

`verify_multiformat_dwarf` used `load addr` -- with the DWARF pass still on -- as
its "no-DWARF-name baseline", which only held because `load addr` ignored the
symbol table. Its baseline arm now turns the pass off, which is what it always
meant; both DWARF-recovery assertions are untouched. It was the only test in the
workspace that moved.

Gates: make test PARITY OK 675/675 (no re-pin), make test-stages PARITY OK
394/394 (no re-pin), make rust-test green (4,444 tests), make check-spec OK,
kuna catalog --check OK.

Sweep (`decompile-all` before vs after, 13 binaries, every changed line
classified): 8 C binaries byte-identical, including /bin/grep at 35,070 lines and
/usr/bin/ls at 14,788; 5 C++ binaries change 184 lines -- 181 call-target
renames, 3 address-taken renames through a pre-existing unqualified path, 0
unexplained. Every C++ diff is exactly -N/+N. Discovery inventories are identical
on 15 discovery fixtures (0 entries lost, gained, or renamed). Speed: worst
delta -0.46% over 11 interleaved pairs, budget 5%.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01McQC7imaNfzj5k5AVumSYN
@mahaloz
mahaloz merged commit 1cff8ec into main Aug 5, 2026
9 checks passed
@mahaloz
mahaloz deleted the feat/cppcallnames branch August 5, 2026 05:07
mahaloz added a commit that referenced this pull request Aug 5, 2026
…on, it is a point inside one (-1030 spurious entries, 0 real lost)

A kuna FunctionSymbol is an entry address with no extent: Database::add_function
takes an address and find_function answers "is a function registered AT this
address", never "is this address INSIDE one". Every discovery oracle's dedup is
therefore an equality test, and a candidate 12 bytes into a body passes it.

Three oracles do exactly that on ordinary compiler output, and --mode auto turns
all three on for anything under 500 KiB by resolving to `aggressive`:
eh_frame_full promotes each .gcc_except_table landing pad to a top-level function
(it is designed to), aif starts one at the first undecoded byte of an
unwinder-only region (routinely not an instruction boundary), and the prologue
patterns match an aligned `push rbp; mov rbp,rsp` inside a larger body. On a
g++ -O0 probe, probe_try_catch [0x2acf,0x2ba7) yields sub_2b0b / sub_2b1a /
sub_2b8a, all three surviving stripping, and sub_2b0b decompiles with an
uninitialised rbp so every local is a garbage dereference. IDA Pro 9.2 gives
get_func(0x2b0b).start_ea == 0x2acf; that is the model.

.eh_frame carries the missing extent: each FDE records ONE function's
[pcBegin, pcBegin+pcRange). kuna_fdeinterior.rs reuses scan_eh_frame_starts's
record walk and adds the one field it skips - pcRange, decoded with the CIE R
encoding's format bits only, since it is a length - and the commit filters the
FULLY MERGED entry set, after the deferred Listing consumers, because one
producer is aif.

Not every FDE describes one function: the linker gives the whole PLT a single
FDE and every stub inside it is real (the first prototype deleted every import).
A range is used only when no other named function start, no other FDE pcBegin,
and no .plt/.plt.sec/.plt.got/.iplt/.MIPS.stubs section falls inside it. An entry
AT an FDE start is never suppressed, so oracle 3's own product is preserved.

Gated and default-ON (DIV-60) because the measurement leaves no judgment call.
kuna functions off vs on over 72 stripped decbench x86-64 binaries, every dropped
entry classified against the matching unstripped binary's FUNC symbols (address
and size): 36,568 -> 35,538 entries, 1,030 dropped, 0 added, ZERO that are a real
function's entry, ZERO that carry a name, all 1,030 strictly inside a real body,
52 not even an instruction boundary. C++: big_O0.stripped 599 -> 449 (25% of the
list was junk), probe_O0.stripped 189 -> 162. Static glibc --mode aggressive
1,358 -> 1,087 with 0 real and 0 named lost. PE and ET_REL are inert.
Whole-binary decompile-all on five binaries: 0 functions added, 0 surviving
bodies changed and 0 surviving names changed.

#259 (tailcallentry) non-regression, measured on its own corpus and surface with
--option tailcallentry on: all 98 ARM images, entries 57,578 -> 57,578, zero
images changed - bare-metal ARM unwinds through .ARM.exidx and only 3 of 98
carry any .eh_frame FDE. The same argument covers draft PR #239.

Disclosed interaction: eh_frame_full's landing-pad product is now constrained by
this gate, so verify_eh_frame_full's option-on arm flips fdeinterior off to keep
testing what the LSDA decode produces.

Rebased onto 1cff8ec (#262, cppcallnames, DIV-59) and fully re-measured on that
tree: the C corpus, the C++ probes, the ARM corpus and every catalog counter
reproduce exactly. Both arms of every off/on comparison are the same build, so
#262's C++ callee renaming cancels; the added surviving_names_changed /
NAMED_LOST counters are 0 everywhere, so no entry this option removes was
shadowing a real symbol. phase_catalog.json re-captured and docs/options.md
regenerated from the post-rebase build; no stages XML added, so no corpus count
or stages baseline moves.

Bundle: docs/features/fdeinterior/. Gates: make test 675/675 PARITY OK (no
re-pin, no per-test opt-out), make test-stages 394/394 PARITY OK, make rust-test
green, make check-spec OK (strict), kuna catalog --check OK. Speed: timeit
-29.28% (15 samples); interleaved medians -21.68% to +0.06% (functions) and
-4.22% / -4.89% (decompile-all).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01McQC7imaNfzj5k5AVumSYN
mahaloz added a commit that referenced this pull request Aug 5, 2026
…on, it is a point inside one (-1030 spurious entries, 0 real lost)

A kuna FunctionSymbol is an entry address with no extent: Database::add_function
takes an address and find_function answers "is a function registered AT this
address", never "is this address INSIDE one". Every discovery oracle's dedup is
therefore an equality test, and a candidate 12 bytes into a body passes it.

Three oracles do exactly that on ordinary compiler output, and --mode auto turns
all three on for anything under 500 KiB by resolving to `aggressive`:
eh_frame_full promotes each .gcc_except_table landing pad to a top-level function
(it is designed to), aif starts one at the first undecoded byte of an
unwinder-only region (routinely not an instruction boundary), and the prologue
patterns match an aligned `push rbp; mov rbp,rsp` inside a larger body. On a
g++ -O0 probe, probe_try_catch [0x2acf,0x2ba7) yields sub_2b0b / sub_2b1a /
sub_2b8a, all three surviving stripping, and sub_2b0b decompiles with an
uninitialised rbp so every local is a garbage dereference. IDA Pro 9.2 gives
get_func(0x2b0b).start_ea == 0x2acf; that is the model.

.eh_frame carries the missing extent: each FDE records ONE function's
[pcBegin, pcBegin+pcRange). kuna_fdeinterior.rs reuses scan_eh_frame_starts's
record walk and adds the one field it skips - pcRange, decoded with the CIE R
encoding's format bits only, since it is a length - and the commit filters the
FULLY MERGED entry set, after the deferred Listing consumers, because one
producer is aif.

Not every FDE describes one function: the linker gives the whole PLT a single
FDE and every stub inside it is real (the first prototype deleted every import).
A range is used only when no other named function start, no other FDE pcBegin,
and no .plt/.plt.sec/.plt.got/.iplt/.MIPS.stubs section falls inside it. An entry
AT an FDE start is never suppressed, so oracle 3's own product is preserved.

Gated and default-ON (DIV-60) because the measurement leaves no judgment call.
kuna functions off vs on over 72 stripped decbench x86-64 binaries, every dropped
entry classified against the matching unstripped binary's FUNC symbols (address
and size): 36,568 -> 35,538 entries, 1,030 dropped, 0 added, ZERO that are a real
function's entry, ZERO that carry a name, all 1,030 strictly inside a real body,
52 not even an instruction boundary. C++: big_O0.stripped 599 -> 449 (25% of the
list was junk), probe_O0.stripped 189 -> 162. Static glibc --mode aggressive
1,358 -> 1,087 with 0 real and 0 named lost. PE and ET_REL are inert.
Whole-binary decompile-all on five binaries: 0 functions added, 0 surviving
bodies changed and 0 surviving names changed.

#259 (tailcallentry) non-regression, measured on its own corpus and surface with
--option tailcallentry on: all 98 ARM images, entries 57,578 -> 57,578, zero
images changed - bare-metal ARM unwinds through .ARM.exidx and only 3 of 98
carry any .eh_frame FDE. The same argument covers draft PR #239.

Disclosed interaction: eh_frame_full's landing-pad product is now constrained by
this gate, so verify_eh_frame_full's option-on arm flips fdeinterior off to keep
testing what the LSDA decode produces.

Rebased onto 1cff8ec (#262, cppcallnames, DIV-59) and fully re-measured on that
tree: the C corpus, the C++ probes, the ARM corpus and every catalog counter
reproduce exactly. Both arms of every off/on comparison are the same build, so
#262's C++ callee renaming cancels; the added surviving_names_changed /
NAMED_LOST counters are 0 everywhere, so no entry this option removes was
shadowing a real symbol. phase_catalog.json re-captured and docs/options.md
regenerated from the post-rebase build; no stages XML added, so no corpus count
or stages baseline moves.

Bundle: docs/features/fdeinterior/. Gates: make test 675/675 PARITY OK (no
re-pin, no per-test opt-out), make test-stages 394/394 PARITY OK, make rust-test
green, make check-spec OK (strict), kuna catalog --check OK. Speed: timeit
-29.28% (15 samples); interleaved medians -21.68% to +0.06% (functions) and
-4.22% / -4.89% (decompile-all).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01McQC7imaNfzj5k5AVumSYN
mahaloz added a commit that referenced this pull request Aug 5, 2026
…on, it is a point inside one (-1030 spurious entries, 0 real lost)

A kuna FunctionSymbol is an entry address with no extent: Database::add_function
takes an address and find_function answers "is a function registered AT this
address", never "is this address INSIDE one". Every discovery oracle's dedup is
therefore an equality test, and a candidate 12 bytes into a body passes it.

Three oracles do exactly that on ordinary compiler output, and --mode auto turns
all three on for anything under 500 KiB by resolving to `aggressive`:
eh_frame_full promotes each .gcc_except_table landing pad to a top-level function
(it is designed to), aif starts one at the first undecoded byte of an
unwinder-only region (routinely not an instruction boundary), and the prologue
patterns match an aligned `push rbp; mov rbp,rsp` inside a larger body. On a
g++ -O0 probe, probe_try_catch [0x2acf,0x2ba7) yields sub_2b0b / sub_2b1a /
sub_2b8a, all three surviving stripping, and sub_2b0b decompiles with an
uninitialised rbp so every local is a garbage dereference. IDA Pro 9.2 gives
get_func(0x2b0b).start_ea == 0x2acf; that is the model.

.eh_frame carries the missing extent: each FDE records ONE function's
[pcBegin, pcBegin+pcRange). kuna_fdeinterior.rs reuses scan_eh_frame_starts's
record walk and adds the one field it skips - pcRange, decoded with the CIE R
encoding's format bits only, since it is a length - and the commit filters the
FULLY MERGED entry set, after the deferred Listing consumers, because one
producer is aif.

Not every FDE describes one function: the linker gives the whole PLT a single
FDE and every stub inside it is real (the first prototype deleted every import).
A range is used only when no other named function start, no other FDE pcBegin,
and no .plt/.plt.sec/.plt.got/.iplt/.MIPS.stubs section falls inside it. An entry
AT an FDE start is never suppressed, so oracle 3's own product is preserved.

Gated and default-ON (DIV-61) because the measurement leaves no judgment call.
kuna functions off vs on over 72 stripped decbench x86-64 binaries, every dropped
entry classified against the matching unstripped binary's FUNC symbols (address
and size): 36,568 -> 35,538 entries, 1,030 dropped, 0 added, ZERO that are a real
function's entry, ZERO that carry a name, all 1,030 strictly inside a real body,
52 not even an instruction boundary. C++: big_O0.stripped 599 -> 449 (25% of the
list was junk), probe_O0.stripped 189 -> 162. Static glibc --mode aggressive
1,358 -> 1,087 with 0 real and 0 named lost. PE and ET_REL are inert.
Whole-binary decompile-all on eight binaries: 0 functions added, 0 surviving
bodies changed and 0 surviving names changed.

#259 (tailcallentry) non-regression, measured on its own corpus and surface with
--option tailcallentry on: all 98 ARM images, entries 57,578 -> 57,578, zero
images changed - bare-metal ARM unwinds through .ARM.exidx and only 3 of 98
carry any .eh_frame FDE. The same argument covers draft PR #239.

Disclosed interaction: eh_frame_full's landing-pad product is now constrained by
this gate, so verify_eh_frame_full's option-on arm flips fdeinterior off to keep
testing what the LSDA decode produces.

Rebased onto 890096b (#264 cppproto, DIV-60) on 1cff8ec (#262 cppcallnames,
DIV-59), and fully re-measured on that tree rather than carried forward, because
neither is inert here. #264 recovers out-of-line C++ member and namespace
definitions from DWARF, so an unstripped C++ binary now carries far more named
function symbols - the input to this option's "range holds no other named
function start" condition. The invariant holds against the new symbol set:
big_O0 now has 447 of its 450 surviving entries named (probe_O0 161 of 163) and
the filter still drops 150 with 0 real and 0 named lost, while the stripped
counterparts are unchanged at 449 / 162 (verified, not assumed - no DWARF there).
Both arms of every comparison are the same build, so #262's renaming and #264's
MAX_TYPE_DEPTH change cancel; coreutils fmt, the binary #264 altered, was
decompiled whole in both arms to keep the two unconflated (198 -> 191 entries, 0
surviving bodies changed; fmt-O2 151 -> 151).

Catalog counters were DERIVED from a fresh post-rebase catalog capture, not
incremented: 91 settables, 20 core / 41 transform / 30 analysis, 90 catalog rows.
#264 and this PR had made an identical off-by-one edit to the same three
assertions, so the merge resolution would have shipped the wrong number had it
been trusted. phase_catalog.json re-captured and docs/options.md regenerated from
the post-rebase build; no stages XML added, so no corpus count or stages baseline
moves.

Bundle: docs/features/fdeinterior/. Gates: make test 675/675 PARITY OK (no
re-pin, no per-test opt-out), make test-stages 394/394 PARITY OK, make rust-test
green, make check-spec OK (strict), kuna catalog --check OK. Speed: timeit
-29.28% (15 samples); interleaved medians -21.68% to +0.06% (functions) and
-4.22% / -4.89% (decompile-all).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01McQC7imaNfzj5k5AVumSYN
mahaloz added a commit that referenced this pull request Aug 5, 2026
…on, it is a point inside one (-1030 spurious entries, 0 real lost)

A kuna FunctionSymbol is an entry address with no extent: Database::add_function
takes an address and find_function answers "is a function registered AT this
address", never "is this address INSIDE one". Every discovery oracle's dedup is
therefore an equality test, and a candidate 12 bytes into a body passes it.

Three oracles do exactly that on ordinary compiler output, and --mode auto turns
all three on for anything under 500 KiB by resolving to `aggressive`:
eh_frame_full promotes each .gcc_except_table landing pad to a top-level function
(it is designed to), aif starts one at the first undecoded byte of an
unwinder-only region (routinely not an instruction boundary), and the prologue
patterns match an aligned `push rbp; mov rbp,rsp` inside a larger body. On a
g++ -O0 probe, probe_try_catch [0x2acf,0x2ba7) yields sub_2b0b / sub_2b1a /
sub_2b8a, all three surviving stripping, and sub_2b0b decompiles with an
uninitialised rbp so every local is a garbage dereference. IDA Pro 9.2 gives
get_func(0x2b0b).start_ea == 0x2acf; that is the model.

.eh_frame carries the missing extent: each FDE records ONE function's
[pcBegin, pcBegin+pcRange). kuna_fdeinterior.rs reuses scan_eh_frame_starts's
record walk and adds the one field it skips - pcRange, decoded with the CIE R
encoding's format bits only, since it is a length - and the commit filters the
FULLY MERGED entry set, after the deferred Listing consumers, because one
producer is aif.

Not every FDE describes one function: the linker gives the whole PLT a single
FDE and every stub inside it is real (the first prototype deleted every import).
A range is used only when no other named function start, no other FDE pcBegin,
and no .plt/.plt.sec/.plt.got/.iplt/.MIPS.stubs section falls inside it. An entry
AT an FDE start is never suppressed, so oracle 3's own product is preserved.

Gated and default-ON (DIV-61) because the measurement leaves no judgment call.
kuna functions off vs on over 72 stripped decbench x86-64 binaries, every dropped
entry classified against the matching unstripped binary's FUNC symbols (address
and size): 36,568 -> 35,538 entries, 1,030 dropped, 0 added, ZERO that are a real
function's entry, ZERO that carry a name, all 1,030 strictly inside a real body,
52 not even an instruction boundary. C++: big_O0.stripped 599 -> 449 (25% of the
list was junk), probe_O0.stripped 189 -> 162. Static glibc --mode aggressive
1,358 -> 1,087 with 0 real and 0 named lost. PE and ET_REL are inert.
Whole-binary decompile-all on eight binaries: 0 functions added, 0 surviving
bodies changed and 0 surviving names changed.

#259 (tailcallentry) non-regression, measured on its own corpus and surface with
--option tailcallentry on: all 98 ARM images, entries 57,578 -> 57,578, zero
images changed - bare-metal ARM unwinds through .ARM.exidx and only 3 of 98
carry any .eh_frame FDE. The same argument covers draft PR #239.

Disclosed interaction: eh_frame_full's landing-pad product is now constrained by
this gate, so verify_eh_frame_full's option-on arm flips fdeinterior off to keep
testing what the LSDA decode produces.

Rebased onto 890096b (#264 cppproto, DIV-60) on 1cff8ec (#262 cppcallnames,
DIV-59), and fully re-measured on that tree rather than carried forward, because
neither is inert here. #264 recovers out-of-line C++ member and namespace
definitions from DWARF, so an unstripped C++ binary now carries far more named
function symbols - the input to this option's "range holds no other named
function start" condition. The invariant holds against the new symbol set:
big_O0 now has 447 of its 450 surviving entries named (probe_O0 161 of 163) and
the filter still drops 150 with 0 real and 0 named lost, while the stripped
counterparts are unchanged at 449 / 162 (verified, not assumed - no DWARF there).
Both arms of every comparison are the same build, so #262's renaming and #264's
MAX_TYPE_DEPTH change cancel; coreutils fmt, the binary #264 altered, was
decompiled whole in both arms to keep the two unconflated (198 -> 191 entries, 0
surviving bodies changed; fmt-O2 151 -> 151).

Catalog counters were DERIVED from a fresh post-rebase catalog capture, not
incremented: 91 settables, 20 core / 41 transform / 30 analysis, 90 catalog rows.
#264 and this PR had made an identical off-by-one edit to the same three
assertions, so the merge resolution would have shipped the wrong number had it
been trusted. phase_catalog.json re-captured and docs/options.md regenerated from
the post-rebase build; no stages XML added, so no corpus count or stages baseline
moves.

Bundle: docs/features/fdeinterior/. Gates: make test 675/675 PARITY OK (no
re-pin, no per-test opt-out), make test-stages 394/394 PARITY OK, make rust-test
green, make check-spec OK (strict), kuna catalog --check OK. Speed: timeit
-29.28% (15 samples); interleaved medians -21.68% to +0.06% (functions) and
-4.22% / -4.89% (decompile-all).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01McQC7imaNfzj5k5AVumSYN
mahaloz added a commit that referenced this pull request Aug 5, 2026
…on, it is a point inside one (-1030 spurious entries, 0 real lost) (#263)

A kuna FunctionSymbol is an entry address with no extent: Database::add_function
takes an address and find_function answers "is a function registered AT this
address", never "is this address INSIDE one". Every discovery oracle's dedup is
therefore an equality test, and a candidate 12 bytes into a body passes it.

Three oracles do exactly that on ordinary compiler output, and --mode auto turns
all three on for anything under 500 KiB by resolving to `aggressive`:
eh_frame_full promotes each .gcc_except_table landing pad to a top-level function
(it is designed to), aif starts one at the first undecoded byte of an
unwinder-only region (routinely not an instruction boundary), and the prologue
patterns match an aligned `push rbp; mov rbp,rsp` inside a larger body. On a
g++ -O0 probe, probe_try_catch [0x2acf,0x2ba7) yields sub_2b0b / sub_2b1a /
sub_2b8a, all three surviving stripping, and sub_2b0b decompiles with an
uninitialised rbp so every local is a garbage dereference. IDA Pro 9.2 gives
get_func(0x2b0b).start_ea == 0x2acf; that is the model.

.eh_frame carries the missing extent: each FDE records ONE function's
[pcBegin, pcBegin+pcRange). kuna_fdeinterior.rs reuses scan_eh_frame_starts's
record walk and adds the one field it skips - pcRange, decoded with the CIE R
encoding's format bits only, since it is a length - and the commit filters the
FULLY MERGED entry set, after the deferred Listing consumers, because one
producer is aif.

Not every FDE describes one function: the linker gives the whole PLT a single
FDE and every stub inside it is real (the first prototype deleted every import).
A range is used only when no other named function start, no other FDE pcBegin,
and no .plt/.plt.sec/.plt.got/.iplt/.MIPS.stubs section falls inside it. An entry
AT an FDE start is never suppressed, so oracle 3's own product is preserved.

Gated and default-ON (DIV-61) because the measurement leaves no judgment call.
kuna functions off vs on over 72 stripped decbench x86-64 binaries, every dropped
entry classified against the matching unstripped binary's FUNC symbols (address
and size): 36,568 -> 35,538 entries, 1,030 dropped, 0 added, ZERO that are a real
function's entry, ZERO that carry a name, all 1,030 strictly inside a real body,
52 not even an instruction boundary. C++: big_O0.stripped 599 -> 449 (25% of the
list was junk), probe_O0.stripped 189 -> 162. Static glibc --mode aggressive
1,358 -> 1,087 with 0 real and 0 named lost. PE and ET_REL are inert.
Whole-binary decompile-all on eight binaries: 0 functions added, 0 surviving
bodies changed and 0 surviving names changed.

#259 (tailcallentry) non-regression, measured on its own corpus and surface with
--option tailcallentry on: all 98 ARM images, entries 57,578 -> 57,578, zero
images changed - bare-metal ARM unwinds through .ARM.exidx and only 3 of 98
carry any .eh_frame FDE. The same argument covers draft PR #239.

Disclosed interaction: eh_frame_full's landing-pad product is now constrained by
this gate, so verify_eh_frame_full's option-on arm flips fdeinterior off to keep
testing what the LSDA decode produces.

Rebased onto 890096b (#264 cppproto, DIV-60) on 1cff8ec (#262 cppcallnames,
DIV-59), and fully re-measured on that tree rather than carried forward, because
neither is inert here. #264 recovers out-of-line C++ member and namespace
definitions from DWARF, so an unstripped C++ binary now carries far more named
function symbols - the input to this option's "range holds no other named
function start" condition. The invariant holds against the new symbol set:
big_O0 now has 447 of its 450 surviving entries named (probe_O0 161 of 163) and
the filter still drops 150 with 0 real and 0 named lost, while the stripped
counterparts are unchanged at 449 / 162 (verified, not assumed - no DWARF there).
Both arms of every comparison are the same build, so #262's renaming and #264's
MAX_TYPE_DEPTH change cancel; coreutils fmt, the binary #264 altered, was
decompiled whole in both arms to keep the two unconflated (198 -> 191 entries, 0
surviving bodies changed; fmt-O2 151 -> 151).

Catalog counters were DERIVED from a fresh post-rebase catalog capture, not
incremented: 91 settables, 20 core / 41 transform / 30 analysis, 90 catalog rows.
#264 and this PR had made an identical off-by-one edit to the same three
assertions, so the merge resolution would have shipped the wrong number had it
been trusted. phase_catalog.json re-captured and docs/options.md regenerated from
the post-rebase build; no stages XML added, so no corpus count or stages baseline
moves.

Bundle: docs/features/fdeinterior/. Gates: make test 675/675 PARITY OK (no
re-pin, no per-test opt-out), make test-stages 394/394 PARITY OK, make rust-test
green, make check-spec OK (strict), kuna catalog --check OK. Speed: timeit
-29.28% (15 samples); interleaved medians -21.68% to +0.06% (functions) and
-4.22% / -4.89% (decompile-all).


Claude-Session: https://claude.ai/code/session_01McQC7imaNfzj5k5AVumSYN

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant