Repository navigation
[AUTOMATED] fix(p9): cppcallnames - render a C++ callee's qualified name at the call site (DIV-59) - #262
Merged
Conversation
…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
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]>
This was referenced Aug 5, 2026
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.
What
kuna printed
sub_<addr>at every call to a demangled C++ function on anunstripped binary — for a name it already had.
kuna functionslistedAccount::deposit;kuna decompile <bin> 'Account::deposit'resolved anddecompiled 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 — thisreproduces in-tree):
$ kuna decompile decompiler/crates/kuna-analysis/tests/fixtures/cpp_noreturn_x86_64 failvoid fail(void) { - sub_401070(); // no-return + std::terminate(); // no-return }A second, independent defect closed here —
--addrnever applied the known symbolname, so the same function printed two different headers depending on how you
selected it:
$ kuna decompile ...cpp_noreturn_x86_64 --addr 0x401070And 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 modulovariable 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-sitepath reads the same symbol table
kuna functionsdoes. It is also not a demanglerdefect — a demangled name with no namespace (
_Z8topleveli→toplevel) renderedfine all along.
It is scope shadowing in the gated-commit seam, and it is mode-dependent:
Account::depositcall site--mode reliableAccount::deposit(a,amount)✅auto→aggressiveunder 500 KiB)sub_271c(a,amount)❌--option fast_funcdisc off --option funcstart_patterns offAccount::deposit(a,amount)✅read_loader_symbolsinstalls a demangled funcsym in its namespace scope —std::terminateis baseterminatein scopestd.fast_funcdisc/funcstart_patterns, both inAGGRESSIVE_OVERRIDES) re-reports the same VMA.commit_analysis_output's discovered-entry arm named itsub_<addr>, resolvedthat synthetic name to a scope — no
::, so GLOBAL — and probedfind_function(scope, addr)in that scope only. It missed the real symboland installed a duplicate generic FunctionSymbol in GLOBAL at the same address.
FlowInfo::queryCallresolves throughfind_function_across_scopes, whichsearches 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/.dynsymname win on a non-strippedbinary" was false for every
::-qualified symbol, andfind_function_across_scopesalready 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: thepasses still run, still find the same VMAs, a genuinely unnamed find is still
sub_<addr>, andregister_symbolis untouched sosub_<addr>remains a workingselection alias.
Why nothing caught it
tests/datatests/andtests/stages/file is an XML<binaryimage>, andthat bootstrap never produces an
AnalysisOutput—commit_analysis_outputis astructural no-op there, so neither corpus can reach the defect.
verify_noreturn_demangledrives the console with shipped defaults (nodiscovery pass), where the duplicate is never created. It printed
std::terminate()and passed — while the CLI on that same fixture printedsub_401070(). No test asserted the CLI render. Now one does.No option
Deliberate, for three reasons:
phases.tomlsettables carry anengine phase P1–P9;
kuna-console/kuna-clionly ever write options. Gatingthis would mean inventing an axis, not filling in a row (precedent:
--max-fn-seconds, "Driver policy, not a stage-model settable").--mode reliable. This removes aninconsistency in which two of four modes silently lost names the other two kept.
at the same address is wrong under every naming policy,
namestyle ghidraincluded.
docs/history.mdDIV-59 records it.Sweep —
decompile-allbefore vs after, 13 binaries, every line classifiedEvery C++ diff is exactly
-N/+N: no line added or removed, no structural orsignature 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 --jsonbefore vs after over15 discovery fixtures (ARM/Thumb, Cortex-M, AArch64, RISC-V, Mach-O, i386-PIE,
funcstart_patterns,aif_gap, stripped ELF) — zero entries lost, gained, orrenamed 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, becauseFuncdata::link_spacebase_symbolbinds the unscopedname_for_global_varnodewhere the sibling
ActionNameVarspath usesname_for_global_varnode_scoped+kuna_qualify_global_name. That gap is pre-existing and unrelated: onmainthesame fixture already emits
{virtual override thunk}in exactly that position andvoid 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:
::~ident{…}gcc -fsyntax-onlyerrorsfmt_x86_64(C).c+.h— beforefmt_x86_64(C).c+.h— afterprobe_O0(C++).h— beforeprobe_O0(C++).h— afterprobe_O0(C++).c— beforeprobe_O0(C++).c— afterA 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
.cbodies gain::at call sites — the point of the fix, and what IDA and Ghidra print. Since Coutput 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
.hand.cconsistently, including the pre-existingAccount::~Accountheaders); filed as follow-up 1 indocs/features/cppcallnames/analysis.md.Gates
make testmake test-stagesmake rust-testmake check-speckuna catalog --checkSpeed
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
kunaand 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_O0that the11-pair minimum resolves to −0.46%).
decompile-alldecompile-alldecompile-allfunctionsdecompile-allfunctionsWorst delta −0.46%, budget 5%. The added work is one probe per discovered entry;
find_function_across_scopesstill hits the global scope first and walks the restonly on a miss.
Tests
decompiler/crates/kuna-console/tests/verify_cppcallnames.rs— real engine over thealready-vendored
cpp_noreturn_x86_64, discovery passes enabled in the live-CLIorder (
optionbeforeread symbols):sub_401070shadows it;load addr 0x401070names the function from the symbol table;sub_<addr>, and anexplicit
load addr <vma> <name>still wins.Ablated against the pre-fix sources (files copied aside — never
git stash, it isshared 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 "Whynothing caught it"), so no corpus-count bump and no stages-baseline re-record.
One existing test moved, and it is worth naming
verify_multiformat_dwarfusedload addr— with the DWARF pass still on — asits "no-DWARF-name baseline", asserting
sub_140001550/sub_0. That only heldbecause
load addrignored the symbol table: the test was pinning the bug. Itsbaseline arm now turns the pass off (
option dwarf off), which is what it alwaysmeant, and the claim gets stronger:
0x140001550(the COFF FUNC entry is--strip-symbol-removed), sosub_140001550is unchanged and now actually teststhe absence of DWARF rather than the absence of a lookup.
--redefine-symed symtab entry_l0remains, sothe baseline asserts
_l0. "The symtab says_l0here, notfirst_byte" is asharper 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
kuna-console/src/engine.rskuna-console/src/ifacedecomp.rsIfcAddrrangeLoad: prefer the installed qualified namekuna-console/tests/verify_cppcallnames.rsdocs/spec/00-overview.mddocs/history.mddocs/features/cppcallnames/analysis.md,plan.md,record.json