Repository navigation
[AUTOMATED] feat(p1): ptrentry - admit pointer-referenced ARM function entries on containment evidence (+1,613 at 95.2%) - #255
Merged
Conversation
mahaloz
force-pushed
the
feat/decbench-ptrentry
branch
from
August 3, 2026 13:45
359482d to
915b68c
Compare
…n entries on containment evidence Step 2 of the approved ARM entry-recall sequence ([PROPOSAL] #239) and the one it called the prize: 1,671 missed function entries, 56.8% of the whole ARM entry-recall gap, every one of them reachable only through a code-pointer word that `aif::code_pointer_table_seeds` already finds and then throws away. The shipped Stage-3 scan requires a pointer's target to open with a Thumb stack-frame prologue and to disassemble into more than two instructions. On bare-metal firmware that is the wrong population: 93.3% of the missed entries establish no frame at all and 41% are <= 8-byte leaves (`movs r0,#0; bx lr`, or a bare `bx lr`, which is a valid Cortex-M exception handler every rival recovers). Those two predicates reject 1,632 of the 1,671. Deleting them is not shippable - the proposal measured the naive relaxation at 62% ground truth with 21% of the new entries splitting a real function body, a failure mode decbench structurally cannot see. So the whole of this change is the precision model, and the model is CONTAINMENT rather than shape: reject a target when any word that references it overlaps a decoded instruction (it is operand bytes, not a table slot) or lies in the same discovered function as the target itself (that pairing IS the `ldr pc,[pc,r]` switch table). Measured over 3,462 validated candidates the two guards take splits from 1,261 to 0 for 17 ground-truth entries. The `MIN_SUBROUTINE_INSNS` floor is replaced, not deleted, by a terminating-routine check: the same speculative walk with the strict escape policy and no minimum length. This is kuna's form of the line Ghidra draws between `OperandReferenceAnalyzer` (creates functions, from instruction operands) and `DataOperandReferenceAnalyzer`, which overrides `createFunctions` to a no-op - "don't ever create a function from a data pointer". kuna cannot use Ghidra's version directly because the Listing tier records only control-flow references, so the containment pair recovers the same discrimination from the code/data partition the walk leaves behind. Measured on the 48-image decbench Cortex-M corpus (41,378 DWARF ground-truth addresses), `kuna functions`: recall 38,238 (92.4%) -> 39,851 (96.3%), +1,613 1,694 new entries, 1,613 ground truth (95.2%) 0 splitting a real function body, 81 outside any DWARF body 0 entries lost, 0 ground-truth entries lost `--option listing off` is structurally inert (ptrentry is a Listing consumer): 0 new, 0 lost. Whole-binary `decompile-all --json` is sha256-identical off vs on for x86-64, ARM Linux and the Cortex-M images with no admissible candidate. Two things the proposal asked for that measurement rejected, both built and measured rather than argued (tables in docs/features/ptrentry/): - table-run corroboration: a switch table IS a run, so it removes no additional split, and it costs 311 ground-truth functions (1,302 vs 1,613); - re-seeding the recursive-descent walk (what Stages 2-3 do): +13 ground-truth entries but 974 split bodies and 734 dropped entries, through the same tail-call absorption that constrained step 1. The pass therefore emits entry facts only, which makes "never removes an entry" a property of the wiring rather than of a heuristic. That also settles the proposal's optional AIF gap-start re-walk fold-in: closing it IS a walk re-seed, so it stays with step 3. Default-OFF and not auto-injected by any driver: it discovers more functions, so it changes emitted C by construction, and the precision numbers want a human read before a flip. No DIV row (default output is byte-identical). Tests: `kuna-console/tests/verify_ptrentry.rs` is the two-pass e2e over a new hand-assembled fixture carrying both shapes - the pointer-only leaf that must be recovered and the switch-table case that must stay rejected with the option ON - plus three unit tests and a superset-property pin. No `tests/stages/*.xml`: the harness embeds raw `<bytechunk>`s and never builds a load image or a Listing, the same reason every sibling analysis-tier discovery flag ships a cross-crate `verify_*` gate. Gates on the rebased tree (origin/main 208bb15, after #252/#253/#254): make test PARITY OK 675/675; make test-stages PARITY OK 386/386; make rust-test green (295/295 result blocks); make check-spec green in strict mode; kuna catalog --check OK. Every shared counter is derived from a fresh `phase catalog` capture and a green run on the rebased tree, not by arithmetic: settables 87 -> 88, analysis tier 26 -> 27, catalog JSON rows 86 -> 87, bytecompat fixture 87 -> 88, and the live-value count stays at 29 because this row declares no codegen live_field. The `kuna-base/src/xml.rs` corpus count was verified by counting the files (83 datatests + 107 stages = 190, unchanged), and `docs/baseline-stages.json` is untouched because this PR adds no stages XML. The recall/precision table and the off-vs-on sha256 ablation were re-measured on the rebased build and are unchanged, with 0 of 48 per-binary entry sets differing from the pre-rebase run. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL
mahaloz
force-pushed
the
feat/decbench-ptrentry
branch
from
August 3, 2026 13:48
915b68c to
cd17e35
Compare
This was referenced Aug 3, 2026
Closed
mahaloz
added a commit
that referenced
this pull request
Aug 3, 2026
…cost this round Docs-only. No .rs, no phases.toml, no baselines, no tests. Rebased onto origin/main 4c2b59b (after #254, #255 and #257). Round 2 shipped, and the benchmark signal was refreshed on 2026-08-03 (all three opt levels re-decompiled from pinned kuna 9623dc2). Several documented claims were provably stale and several hard-won operational facts existed only in agent transcripts. Both fixed, every number re-verified against the live tree. docs/decbench-loop.md - Standings replaced and widened: GED ida 36.06 / kuna 35.93 / angr 34.20, overall ida 38.01 / kuna 37.91 / angr 36.98, byte_match kuna 3.41 (first). Stated plainly that kuna's column is current while the rivals' are from their own last runs, so the tree is a MINING INSTRUMENT, not a leaderboard. - Recall pool: 6,540 (7.3%) -> 1,420 vs angr / 1,552 vs ida, 0 whole-binary failures, now almost entirely embedded ARM Cortex-M. All three named causes corrected: "u-boot 100% / freertos 100%" was a decbench .text-filter artifact and never a kuna discovery failure (angr and ida score nothing there); "betaflight 22%" is 6.0%; the coreutils `main` empty-body/panic is fixed (comm/join/timeout/uniq all produce full bodies today). - The `--mode auto` degrades-to-fast warning is moot for this corpus: the largest stripped binary is O0 bash at 1,513,904 B (1.44 MiB), so all 803 binaries resolve 768 aggressive / 35 reliable / 0 fast. The aggressive-vs- reliable distinction is kept and sharpened; the stale 21-of-24 default-off count is now 20 of 25, with the five exclusions named. - Two operational traps recorded for the first time: (a) byte_match RECOMPILES with an arch-matched toolchain and this box has neither arm-none-eabi-gcc nor MinGW, so deleting kuna's (never auto-invalidated) checkpoints destroys kuna's ARM/PE scores while every rival keeps theirs. The coverage guard caught 34 slices; O2 and O2-noinline are still damaged from an earlier DECBENCH_ALLOW_DROPS=1 run with no surviving copy. Rule: never pass DECBENCH_ALLOW_DROPS=1 without reading every [guard] line. (b) The pools store a PE address as an RVA where kuna uses the VA, so scripts.decbench.rescore fails on every PE case (119 across the three pools). Recorded with a fix direction. - Pointed at the durable refresh recipe at ~/decbench-campaign-state/ and its two pinning rules, plus the non-obvious one: the GED baseline must drop kuna's published scores for EVERY re-decompiled opt level, not just the one being refreshed (an O0-only baseline died with "cannot reproduce published fallback 58.0" on an O2 slice). Method corrections (decbench-loop.md + improvement-pipeline.md standing rules) - "Not a no-op" is not "correct". On paramcopyhoist a refuter proved the proposed hook reached the printer and it was still the wrong site: it deleted an assignment, lost an early return, and made another function return the wrong parameter. The refute brief now carries an explicit "would this produce WRONG output?" axis. - Diff every changed function, not the witness. Those designs all passed on their witness. Round 2's PRs swept 3,031 / 12,241 / 14,720 / 15,386 functions; two caught real problems that way. - The tally, honestly: round 1's filed mechanisms were 2-for-5, round 2's refuters overturned the filed diagnosis on 3 of 8, and the symptom stood in every case. Shared counters in a busy queue (decbench-loop.md + improvement-pipeline.md) - Round 2 ran up to four output-changing PRs over the same hard-coded counters and produced three failure shapes, only one of which announced itself: a conflict (#257's DIV number raced 55 -> 56 -> 57 -> 58); a SILENT identical-edit auto-merge (catalog_bytecompat.rs kept 86 because both sides made the same 85 -> 86 edit); and a SILENT keep-both auto-merge (a stale baseline-stages.json data_footer, and five rounds of keep-both duplicating a row in tests/stages/README.md). - Rules written down: derive every shared counter from a fresh capture and a green run on the rebased tree, never by arithmetic; diff every keep-both resolution against main asserting you removed nothing and added nothing twice; DIV numbers are claimed on merge; re-run the gates AFTER the rebase. - New standing requirement 9: re-measure after every rebase, never carry a number forward. #257's placeholder count moved 2,143 -> 2,142 because #254 landed underneath it, caught only by re-measuring. docs/decbench/features.md - Round-1 menu replaced by round-2 outcomes, keeping the file's shape and its rank-by-correctness thesis. NINE merged PRs: #248 cortexmvectors, #249 funcptralign, #250 paramcopyhoist, #251 subright, #252 returncopysplit, #253 itecondlist, #254 peimportcall (DIV-57), #255 ptrentry and #257 undefname (DIV-58) -- seven of the eight round-2 candidates plus steps 1 and 2 of the ARM entry-recall sequence (#239). Only three of the nine move GED on a mined case; four are correctness fixes the metric cannot see and two are recall. - The dead-pass finding is now three DISTINCT shapes to grep for, not one anecdote: stub body (RuleSubRight), live body with a permanently-zero input (RuleFuncPtrEncoding's hard-coded funcptr_align() = 0), and live body with a gate bit that has no writer anywhere (ActionDeindirect / externref). The third had a second gap in the same chain -- GlobalEntry::func_no_return never copied the callee's no-return flag into the snapshot -- so one dead gate can hide another. - The ARM sequence is cross-referenced to the live table on PR #239 rather than duplicated here, so it cannot go stale in-repo. - Carried forward as the one still-open candidate: catalog-upstream-options (38 upstream-inherited ArchOptions invisible to `kuna catalog`). Re-mined pool tables regenerated against the refreshed tree (snapshot 2026-08-03): backlog.md, backlog-ida.md, novel.md, triage-queue*.json. Gates on the rebased base: make check-spec OK (lenient and strict); make test 675/675 PARITY OK; make test-stages 394/394 PARITY OK. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL
mahaloz
added a commit
that referenced
this pull request
Aug 3, 2026
…cost this round (#256) Docs-only. No .rs, no phases.toml, no baselines, no tests. Rebased onto origin/main 4c2b59b (after #254, #255 and #257). Round 2 shipped, and the benchmark signal was refreshed on 2026-08-03 (all three opt levels re-decompiled from pinned kuna 9623dc2). Several documented claims were provably stale and several hard-won operational facts existed only in agent transcripts. Both fixed, every number re-verified against the live tree. docs/decbench-loop.md - Standings replaced and widened: GED ida 36.06 / kuna 35.93 / angr 34.20, overall ida 38.01 / kuna 37.91 / angr 36.98, byte_match kuna 3.41 (first). Stated plainly that kuna's column is current while the rivals' are from their own last runs, so the tree is a MINING INSTRUMENT, not a leaderboard. - Recall pool: 6,540 (7.3%) -> 1,420 vs angr / 1,552 vs ida, 0 whole-binary failures, now almost entirely embedded ARM Cortex-M. All three named causes corrected: "u-boot 100% / freertos 100%" was a decbench .text-filter artifact and never a kuna discovery failure (angr and ida score nothing there); "betaflight 22%" is 6.0%; the coreutils `main` empty-body/panic is fixed (comm/join/timeout/uniq all produce full bodies today). - The `--mode auto` degrades-to-fast warning is moot for this corpus: the largest stripped binary is O0 bash at 1,513,904 B (1.44 MiB), so all 803 binaries resolve 768 aggressive / 35 reliable / 0 fast. The aggressive-vs- reliable distinction is kept and sharpened; the stale 21-of-24 default-off count is now 20 of 25, with the five exclusions named. - Two operational traps recorded for the first time: (a) byte_match RECOMPILES with an arch-matched toolchain and this box has neither arm-none-eabi-gcc nor MinGW, so deleting kuna's (never auto-invalidated) checkpoints destroys kuna's ARM/PE scores while every rival keeps theirs. The coverage guard caught 34 slices; O2 and O2-noinline are still damaged from an earlier DECBENCH_ALLOW_DROPS=1 run with no surviving copy. Rule: never pass DECBENCH_ALLOW_DROPS=1 without reading every [guard] line. (b) The pools store a PE address as an RVA where kuna uses the VA, so scripts.decbench.rescore fails on every PE case (119 across the three pools). Recorded with a fix direction. - Pointed at the durable refresh recipe at ~/decbench-campaign-state/ and its two pinning rules, plus the non-obvious one: the GED baseline must drop kuna's published scores for EVERY re-decompiled opt level, not just the one being refreshed (an O0-only baseline died with "cannot reproduce published fallback 58.0" on an O2 slice). Method corrections (decbench-loop.md + improvement-pipeline.md standing rules) - "Not a no-op" is not "correct". On paramcopyhoist a refuter proved the proposed hook reached the printer and it was still the wrong site: it deleted an assignment, lost an early return, and made another function return the wrong parameter. The refute brief now carries an explicit "would this produce WRONG output?" axis. - Diff every changed function, not the witness. Those designs all passed on their witness. Round 2's PRs swept 3,031 / 12,241 / 14,720 / 15,386 functions; two caught real problems that way. - The tally, honestly: round 1's filed mechanisms were 2-for-5, round 2's refuters overturned the filed diagnosis on 3 of 8, and the symptom stood in every case. Shared counters in a busy queue (decbench-loop.md + improvement-pipeline.md) - Round 2 ran up to four output-changing PRs over the same hard-coded counters and produced three failure shapes, only one of which announced itself: a conflict (#257's DIV number raced 55 -> 56 -> 57 -> 58); a SILENT identical-edit auto-merge (catalog_bytecompat.rs kept 86 because both sides made the same 85 -> 86 edit); and a SILENT keep-both auto-merge (a stale baseline-stages.json data_footer, and five rounds of keep-both duplicating a row in tests/stages/README.md). - Rules written down: derive every shared counter from a fresh capture and a green run on the rebased tree, never by arithmetic; diff every keep-both resolution against main asserting you removed nothing and added nothing twice; DIV numbers are claimed on merge; re-run the gates AFTER the rebase. - New standing requirement 9: re-measure after every rebase, never carry a number forward. #257's placeholder count moved 2,143 -> 2,142 because #254 landed underneath it, caught only by re-measuring. docs/decbench/features.md - Round-1 menu replaced by round-2 outcomes, keeping the file's shape and its rank-by-correctness thesis. NINE merged PRs: #248 cortexmvectors, #249 funcptralign, #250 paramcopyhoist, #251 subright, #252 returncopysplit, #253 itecondlist, #254 peimportcall (DIV-57), #255 ptrentry and #257 undefname (DIV-58) -- seven of the eight round-2 candidates plus steps 1 and 2 of the ARM entry-recall sequence (#239). Only three of the nine move GED on a mined case; four are correctness fixes the metric cannot see and two are recall. - The dead-pass finding is now three DISTINCT shapes to grep for, not one anecdote: stub body (RuleSubRight), live body with a permanently-zero input (RuleFuncPtrEncoding's hard-coded funcptr_align() = 0), and live body with a gate bit that has no writer anywhere (ActionDeindirect / externref). The third had a second gap in the same chain -- GlobalEntry::func_no_return never copied the callee's no-return flag into the snapshot -- so one dead gate can hide another. - The ARM sequence is cross-referenced to the live table on PR #239 rather than duplicated here, so it cannot go stale in-repo. - Carried forward as the one still-open candidate: catalog-upstream-options (38 upstream-inherited ArchOptions invisible to `kuna catalog`). Re-mined pool tables regenerated against the refreshed tree (snapshot 2026-08-03): backlog.md, backlog-ida.md, novel.md, triage-queue*.json. Gates on the rebased base: make check-spec OK (lenient and strict); make test 675/675 PARITY OK; make test-stages 394/394 PARITY OK. Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Aug 3, 2026
…e Listing walk absorbs at a tail call (+561 at 94.6%) Step 3 of the approved ARM entry-recall sequence (PROPOSAL PR #239), and the step both shipped predecessors independently found blocking them: `listing/walk.rs` makes a new function only at a CALL target and treats every other flow target as a same-function successor, so a routine reached only by a tail `B` is swallowed by whichever function branched to it and never becomes a function at all — 513 missed entries, 17.4% of the ARM entry-recall gap. Measured on 96 ARM Cortex-M images (43,809 DWARF entries), `kuna functions --mode aggressive`: entry recall 40,309 (92.0%) -> 40,870 (93.3%) 593 new entries, 561 ground truth (94.6%), 0 split a real body, 32 outside any DWARF body, 0 entries lost The proposal's naive arm for this step was the worst-precision arm of the whole sequence — 39% ground truth with 55% of the new entries splitting a real function body — and its "stricter" variant 54%/38%. Neither was shippable. Two results got past that. 1. The split cannot change what the walk decodes. Writing the walk as its closure, moving a tail-call target from the instruction worklist to the function worklist leaves the decoded-instruction set fixed, because a function entry is walked and therefore decoded either way. So the split is computed AFTER the walk, with complete predecessor and region information rather than whatever the LIFO worklist order exposed, and emitted as an additive entry fact that never rebuilds the Listing. "Never removes an entry" is a property of the wiring, not of a heuristic. 2. Containment is region crossing. A target is admitted only when every predecessor is an unconditional branch, the branch LEAVES the caller's entry-ordered function region, the target's flow region reaches a RETURN or computed jump (no length floor), and the target does not open with a stack restore. Leave-one-out says the region crossing is load-bearing: dropping it costs 43 points of precision and splits 514 real bodies. A stack-discipline model (reject a branch taken with an unmatched PUSH/SUB SP open) was built, measured at 89.9%/18 splits, and dominated; inter-function alignment padding was measured and declined at 186 ground-truth functions for 1.6pp. Split-half holdout over the eight projects: the shipped rule scores 99.2% with zero splits on the held-out half. Per project 90.3%-100.0%, per optimisation level 85.7%-96.8%, zero split bodies in every cell. Exactly orthogonal to `ptrentry` (#255): identical delta with it off and on, because neither enters `Listing::functions()`. Stacked, corpus entry recall is 97.2%. The AIF gap-start re-walk that step 2 assigned here is NOT folded in, and the measurement says why: it is a walk re-seed, which ADDS to the decoded-instruction closure and makes other stages' candidates fail their `is_undefined` guard — 109 entries lost, 87 of them ground truth, 1013 split bodies, and `tailcallentry` makes it slightly worse rather than safe. Default-OFF, ARM-gated. gzip (x86-64) and mydoom.exe (PE) are byte-identical off vs on. u-boot (ARM Linux, A32) is in scope and disclosed: +21 entries, 19 ground truth (90.5%), 2 splits, 0 lost — the one non-zero-split number, on a population the model was never fitted on. Bundle: docs/features/tailcallentry/. Gates: make test 675/675 PARITY OK, make test-stages 394/394 PARITY OK, make rust-test green, make check-spec green (strict), kuna catalog --check OK. No DIV row (default output byte-identical). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL
mahaloz
added a commit
that referenced
this pull request
Aug 3, 2026
…e Listing walk absorbs at a tail call (+561 at 94.6%) (#259) Step 3 of the approved ARM entry-recall sequence (PROPOSAL PR #239), and the step both shipped predecessors independently found blocking them: `listing/walk.rs` makes a new function only at a CALL target and treats every other flow target as a same-function successor, so a routine reached only by a tail `B` is swallowed by whichever function branched to it and never becomes a function at all — 513 missed entries, 17.4% of the ARM entry-recall gap. Measured on 96 ARM Cortex-M images (43,809 DWARF entries), `kuna functions --mode aggressive`: entry recall 40,309 (92.0%) -> 40,870 (93.3%) 593 new entries, 561 ground truth (94.6%), 0 split a real body, 32 outside any DWARF body, 0 entries lost The proposal's naive arm for this step was the worst-precision arm of the whole sequence — 39% ground truth with 55% of the new entries splitting a real function body — and its "stricter" variant 54%/38%. Neither was shippable. Two results got past that. 1. The split cannot change what the walk decodes. Writing the walk as its closure, moving a tail-call target from the instruction worklist to the function worklist leaves the decoded-instruction set fixed, because a function entry is walked and therefore decoded either way. So the split is computed AFTER the walk, with complete predecessor and region information rather than whatever the LIFO worklist order exposed, and emitted as an additive entry fact that never rebuilds the Listing. "Never removes an entry" is a property of the wiring, not of a heuristic. 2. Containment is region crossing. A target is admitted only when every predecessor is an unconditional branch, the branch LEAVES the caller's entry-ordered function region, the target's flow region reaches a RETURN or computed jump (no length floor), and the target does not open with a stack restore. Leave-one-out says the region crossing is load-bearing: dropping it costs 43 points of precision and splits 514 real bodies. A stack-discipline model (reject a branch taken with an unmatched PUSH/SUB SP open) was built, measured at 89.9%/18 splits, and dominated; inter-function alignment padding was measured and declined at 186 ground-truth functions for 1.6pp. Split-half holdout over the eight projects: the shipped rule scores 99.2% with zero splits on the held-out half. Per project 90.3%-100.0%, per optimisation level 85.7%-96.8%, zero split bodies in every cell. Exactly orthogonal to `ptrentry` (#255): identical delta with it off and on, because neither enters `Listing::functions()`. Stacked, corpus entry recall is 97.2%. The AIF gap-start re-walk that step 2 assigned here is NOT folded in, and the measurement says why: it is a walk re-seed, which ADDS to the decoded-instruction closure and makes other stages' candidates fail their `is_undefined` guard — 109 entries lost, 87 of them ground truth, 1013 split bodies, and `tailcallentry` makes it slightly worse rather than safe. Default-OFF, ARM-gated. gzip (x86-64) and mydoom.exe (PE) are byte-identical off vs on. u-boot (ARM Linux, A32) is in scope and disclosed: +21 entries, 19 ground truth (90.5%), 2 splits, 0 lost — the one non-zero-split number, on a population the model was never fitted on. Bundle: docs/features/tailcallentry/. Gates: make test 675/675 PARITY OK, make test-stages 394/394 PARITY OK, make rust-test green, make check-spec green (strict), kuna catalog --check OK. No DIV row (default output byte-identical). Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Aug 27, 2026
… preset (DIV-90) cortexmvectors (#248), ptrentry (#255), tailcallentry (#259) and poolentry (#278) all shipped default-OFF and sat on the UNEVALUATED list in modes.rs, so they were absent from AGGRESSIVE_OVERRIDES. `auto` resolves to `aggressive` under 500 KiB, and the preset is what the whole-binary surfaces actually run, so all four were INERT on every default path -- the DIV-64 itaniumrtti trap, four times over. The default path's stripped-ARM entry recall had not moved since they merged. They are flipped jointly because they compose, which is exactly what the UNEVALUATED comment demanded before any flip. Measured over the 110 stripped non-x86-64 decbench twins against their unstripped twins' symbol tables (50,724 ground-truth function starts), --mode aggressive: arm entries exact midbody recall added added_exact lost_exact base 55006 44957 8333 88.63% - - - cortexm 55142 45093 8333 88.90% 136 136 0 ptr 56594 46522 8333 91.72% 1588 1565 0 tail 55655 45602 8337 89.90% 649 645 0 pool 53956 45122 7116 88.96% 167 165 0 all4 56188 47330 7117 93.31% 2402 2373 0 Recall and precision improve together: +2,373 real entries (98.8% of everything added is a real function start) while mid-body false entries FALL 8,333 -> 7,117. No ground-truth entry is lost by any arm -- poolentry's 1,217 removals contain zero ground-truth addresses. 0 of 110 binaries lose recall. Restricted to the 105 binaries `auto` actually sends to `aggressive` (< 500 KiB), the default-path number is 90.92% -> 96.06%. The 5 images at/over the threshold resolve to `reliable` and are disclosed in the DIV row rather than papered over. Non-ARM inertness is measured: identical entry sets over 90 x86-64 twins and the 12 i386 PE images in the ARM corpus, byte-identical emitted C over 8 x86-64 binaries. Speed, interleaved min-of-4: decompile-all cf2.elf -5.8% (a speedup), nuttx +3.5%, x86-64 controls at noise; discovery-only `kuna functions` +6.2%, which is more work for more output on the one surface that only does discovery. The 0/675 ablation is proven, not asserted: a throwaway build with all four forced ON as engine defaults -- strictly stronger than preset membership, which the XML harness never applies -- still reports 675/675 and 538/538 PARITY OK. Also lands PR #239's two doc corrections, repointed at the shipped feature docs rather than at its unshipped-proposal directory: the recall-measurement.md mechanism/noise correction and the missing-ghidra-analyses.md OperandReferenceAnalyzer row (its "function creation is subsumed by entry-disc" claim is what ptrentry disproved). [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1
mahaloz
added a commit
that referenced
this pull request
Aug 27, 2026
…e aggressive preset (DIV-93) (#345) * feat(modes): the four ARM entry-discovery options join the aggressive preset (DIV-90) cortexmvectors (#248), ptrentry (#255), tailcallentry (#259) and poolentry (#278) all shipped default-OFF and sat on the UNEVALUATED list in modes.rs, so they were absent from AGGRESSIVE_OVERRIDES. `auto` resolves to `aggressive` under 500 KiB, and the preset is what the whole-binary surfaces actually run, so all four were INERT on every default path -- the DIV-64 itaniumrtti trap, four times over. The default path's stripped-ARM entry recall had not moved since they merged. They are flipped jointly because they compose, which is exactly what the UNEVALUATED comment demanded before any flip. Measured over the 110 stripped non-x86-64 decbench twins against their unstripped twins' symbol tables (50,724 ground-truth function starts), --mode aggressive: arm entries exact midbody recall added added_exact lost_exact base 55006 44957 8333 88.63% - - - cortexm 55142 45093 8333 88.90% 136 136 0 ptr 56594 46522 8333 91.72% 1588 1565 0 tail 55655 45602 8337 89.90% 649 645 0 pool 53956 45122 7116 88.96% 167 165 0 all4 56188 47330 7117 93.31% 2402 2373 0 Recall and precision improve together: +2,373 real entries (98.8% of everything added is a real function start) while mid-body false entries FALL 8,333 -> 7,117. No ground-truth entry is lost by any arm -- poolentry's 1,217 removals contain zero ground-truth addresses. 0 of 110 binaries lose recall. Restricted to the 105 binaries `auto` actually sends to `aggressive` (< 500 KiB), the default-path number is 90.92% -> 96.06%. The 5 images at/over the threshold resolve to `reliable` and are disclosed in the DIV row rather than papered over. Non-ARM inertness is measured: identical entry sets over 90 x86-64 twins and the 12 i386 PE images in the ARM corpus, byte-identical emitted C over 8 x86-64 binaries. Speed, interleaved min-of-4: decompile-all cf2.elf -5.8% (a speedup), nuttx +3.5%, x86-64 controls at noise; discovery-only `kuna functions` +6.2%, which is more work for more output on the one surface that only does discovery. The 0/675 ablation is proven, not asserted: a throwaway build with all four forced ON as engine defaults -- strictly stronger than preset membership, which the XML harness never applies -- still reports 675/675 and 538/538 PARITY OK. Also lands PR #239's two doc corrections, repointed at the shipped feature docs rather than at its unshipped-proposal directory: the recall-measurement.md mechanism/noise correction and the missing-ghidra-analyses.md OperandReferenceAnalyzer row (its "function creation is subsumed by entry-disc" claim is what ptrentry disproved). [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs(decbench): retire the two round-ledger claims DIV-90 falsifies features-round4.md Rank 6 was a filed, still-open recommendation to flip `tailcallentry` into the preset ("aggressive does not carry it"); DIV-90 does exactly that, so it is marked SHIPPED with the sweep it asked for. features.md still called step 3 "in flight" and did not know about step 5 (`poolentry`, #278). [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs: state the ARM restriction precisely -- poolentry has no arch gate cortexmvectors/ptrentry/tailcallentry each early-return on `object::Architecture::Arm`; poolentry does not, and is ARM-only in EFFECT because it keys on PC-relative literal pools. The measured inertness is the same either way (identical entry sets on 90 x86-64 twins and 12 i386 PE images), but "all four are ARM-gated" overstated the mechanism for one of them. [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs(history): add the leave-one-out direction to the DIV-90 evidence Dropping each option from the combination loses 27 / 1427 / 645 / 136 ground-truth entries respectively, and dropping poolentry is the only one that also raises mid-body false entries (7117 -> 8337). No option is redundant given the others. [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs: renumber the ARM-preset divergence to DIV-93 [AUTOMATED] DIV-90/91/92 were claimed by #341/#342/#344 while this branch was in flight; the row and every reference move to DIV-93. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…llee result returns all eight bytes
`u64 full_or(unsigned a) { return full(a) | 0xff00000000ULL; }` is, on 32-bit
ARM, `bl full; orr r1,r1,#255; bx lr`: r0 comes back from full untouched and
only r1 is written. Return recovery refused r0 as the call's INDIRECT
creation, and the output model never returns r1 without r0, so the function
printed as `void full_or(int a0) { full(a0); }`.
The new p4_calls/kuna_retcallhalf.rs makes the first register of the pair
active when, at every live RETURN, it is a call's untouched result, the second
register is computed on purpose and read only by the RETURN, and the model
returns exactly those two registers. "On purpose" excludes the other output of
a two-register instruction, frame restores and reloads, an argument set up for
a later call or svc, and the -fzero-call-used-regs zero. Pairs of unequal
width and big-endian pairs are refused.
Tests: tests/stages/kuna-retcallhalf.xml (ARM callers plus four controls) and
kuna-cli/tests/call_result_pair_returns.rs (ARM, MIPS and i386 decompile-all
output compiled back with gcc and clang and checked against the source).
Fixes #808
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…llee result returns all eight bytes
`u64 full_or(unsigned a) { return full(a) | 0xff00000000ULL; }` is, on 32-bit
ARM, `bl full; orr r1,r1,#255; bx lr`: r0 comes back from full untouched and
only r1 is written. Return recovery refused r0 as the call's INDIRECT
creation, and the output model never returns r1 without r0, so the function
printed as `void full_or(int a0) { full(a0); }`.
The new p4_calls/kuna_retcallhalf.rs makes the first register of the pair
active when, at every live RETURN, it is a call's untouched result, the second
register is computed on purpose and read only by the RETURN, and the model
returns exactly those two registers. "On purpose" excludes the other output of
a two-register instruction, frame restores and reloads, an argument set up for
a later call or svc, and the -fzero-call-used-regs zero. Pairs of unequal
width and big-endian pairs are refused.
Tests: tests/stages/kuna-retcallhalf.xml (ARM callers plus four controls) and
kuna-cli/tests/call_result_pair_returns.rs (ARM, MIPS and i386 decompile-all
output compiled back with gcc and clang and checked against the source).
Fixes #808
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…llee result prints void (#855) A function that returns a callee's 64-bit result with only the high word changed printed as `void`, and the call's result was thrown away. The same happened to a sign-extended call result and to a call result next to a constant high word. ```sh printf 'typedef unsigned long long u64;\nu64 full(unsigned a) { return ((u64)a << 32) | (a * 3u); }\nu64 full_or(unsigned a) { return full(a) | 0xff00000000ULL; }\n' > fo.c clang --target=arm-linux-gnueabi -O2 -fno-inline -c fo.c -o fo.o kuna decompile-all fo.o ``` ```c // Function: full_or @ 0x40000c void full_or(int a0) { full(a0); } ``` `full_or` is `bl full; orr r1,r1,#255; pop {r11,lr}; bx lr`, so `r0` comes back from `full` as it is. With this change it prints `unsigned long long full_or(int a0) { return full(a0) | 0xff00000000; }`, and `kuna decompile fo.o full_or` (also `void` before) prints the same. ## The fix - Return recovery refused `r0` because at the return it is the call's untouched result, and the output model never returns `r1` without `r0`. The new `p4_calls/kuna_retcallhalf.rs` accepts the first register when, at every return, it is a call's untouched result, the second register is computed and read only by the return, and the model then returns exactly those two registers. - The second register must not be a value that also reaches the return of a function returning one register or none: the other output of a two-register instruction (an `smull` low word), a restore or reload from the frame (gcc's `pop {r1,r2,r4,pc}`, an `-O0` reload), an argument for a later call or `svc`, and the `-fzero-call-used-regs` zero. - No option: the rule only fires where the function prints `void` today while computing a register only a pair return can use. Not fixed here: a byte write such as gcc's i386 `or $0xff,%dl` (#852), i386 code that pushes its arguments and never names `%eax`, in single-function mode (#853), and big-endian pairs. On Cortex-M, a caller that builds the high word from a narrower piece of the callee's own (`uxtb r1,r1`) now returns eight bytes, but the call still loses that piece (#851, which already shows on main). ## Tests - `tests/stages/kuna-retcallhalf.xml` (ARM): 5 of 7 assertions fail on main; the other two are the controls (the `smull` word, the hardening zero, the dummy pop and the `svc` argument stay `void`; a low-word-only caller keeps `int`). - `kuna-cli/tests/call_result_pair_returns.rs` builds ARM, MIPS and i386 objects, compiles the printed C with gcc and clang at -O0 and -O2, and checks it against the source. It fails on main. - `decompile-all` over 31 stripped ARM, i386, MIPS and x86-64 binaries (26,265 functions) changes one function: in cf2 (-O2 -fno-inline), a function that tail-calls libgcc's `__fixunssfdi` now returns its result. `__fixunsdfdi` and `__fixunssfdi` themselves already return theirs on main since #757. `decompile-all` time over five of them is unchanged (min of 11, user+sys: 39.1 s on main, 38.5 s with the change). Fixes #808 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
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.
Acceptance table
Corpus: the decbench ARM Cortex-M set — 16 binaries x 3 optimisation levels, 48
stripped images, 41,378 DWARF ground-truth function addresses. Ground truth is
DW_AT_low_pcfrom the matching unstrippedcompiled/binary; kuna is run againstthe stripped copy decbench actually feeds. Same harness as step 1
(
cortexmvectors, PR #248).kuna functions(Listing on — the decbench surface)--option listing offProposal bar: >= 80% ground truth, zero entries lost. Measured: 95.2%, zero
lost, zero split bodies. For scale, the naive relaxation the proposal measured
and rejected was 62% ground truth with 21% splitting a real body.
--option listing offis structurally inert:ptrentryis a Listing consumer —its precision model reads the code/data partition the recursive-descent walk leaves
behind — so with no Listing there is nothing to consume.
What this is
Step 2 of the approved ARM entry-recall sequence (
[PROPOSAL]#239) and the one itcalled the prize: 1,671 missed entries, 56.8% of the whole ARM entry-recall
gap, every one of them reachable only through a code-pointer word that
aif::code_pointer_table_seedsalready finds and then throws away.Stage 3 requires a pointer's target to open with a Thumb stack-frame prologue and
to disassemble into more than two instructions. On bare-metal firmware that is the
wrong population: 93.3% of the missed entries establish no frame at all and
41% are <= 8-byte leaves —
movs r0,#0 ; bx lr, or a barebx lr, which is aperfectly valid Cortex-M exception handler that angr, Ghidra, IDA and Binary Ninja
all recover. Those two predicates reject 1,632 of the 1,671.
The precision model: containment, not shape
A scratch build dumped every candidate's features across all 48 images and joined
them against DWARF. 3,462 candidates survive
is_undefined+ aterminating-routine decode:
The 21% mid-body splits are
ldr pc,[pc,r]switch tables, whose slots pointinto the body that holds the table. Two containment facts kill them:
is the switch table. Removes 1,253 of 1,261 splits; costs 12 ground-truth
entries.
bytes read four-aligned, not a table slot. Removes the last 8 splits; costs 5.
This is kuna's form of the line Ghidra draws between
OperandReferenceAnalyzer(creates functions, from instruction operands) and
DataOperandReferenceAnalyzer, which overridescreateFunctionsto a no-op —"don't ever create a function from a data pointer". kuna cannot use Ghidra's
version directly (the Listing records only control-flow references), so the
containment pair recovers the same discrimination from the walk's code/data
partition.
docs/missing-ghidra-analyses.md§6's "subsumed by s1-entry-disc" claimfor that analyzer was corrected by the proposal; this PR is the fix it named.
MIN_SUBROUTINE_INSNSis replaced, not deleted:check_terminating_routineis thesame speculative walk with the length floor removed and the strict escape policy
kept — no undecodable byte, no flow out of the image, no escape into another dark
region, and it must reach a clean
RET/computed jump or a call into discoveredcode.
Two things the proposal asked for that measurement rejected
Both were built and measured on the full corpus, not argued.
Table-run corroboration (proposal item 1's first half) — require a run of >= 2
consecutive stride-4 code-pointer words:
A switch table is a run, so the test removes no additional split; what it removes
is 311 ground-truth functions reached by an ordinary
ldr rN,=funcliteral-poolconstant. The 2.1pp it buys sits entirely in the unverifiable "outside any DWARF
body" bucket. Not shipped — but both configurations are in
measurements.txt(blocks 1 and 4) if a reviewer wants the stricter one.
Re-seeding the walk (proposal item 4) — the wiring Stages 2 and 3 use:
13 more ground-truth entries for 974 split bodies and 734 dropped entries. This is
the same trap step 1 traced:
listing/walk.rstreats an unconditionalBassame-function flow, so seeding an ISR stub that tail-calls a shared handler makes
the walk absorb the handler and lose its entry — proposal step 3's tail-call split,
which has not shipped. Keeping the pass purely additive is what makes "never
removes an entry" a property of the wiring rather than of a heuristic.
That also settles the proposal's optional fold-in (re-walking AIF's accepted gap
starts, +39 entries): closing it is adding a walk re-seed, so it stays with step
3. Explicitly not in this PR: step 3 (
tailcallentry) or step 4 (TBB/TBH).Strict no-op elsewhere
kuna decompile-all --jsonis sha256-identical off vs on for x86-64 (gzip),ARM Linux (
u-boot), and the Cortex-M images with no admissible candidate(libopencm3
blink.elf,miniblink.elf,tick_blink.elf). The XML datatest pathnever builds an
ObjectLoadImageor a Listing, so the option cannot fire there atall.
Speed
Median of 5 whole-binary runs against a frozen release binary, off vs on:
kuna functionskuna functionskuna functionskuna functionskuna decompile-allkuna decompile-allThe scan is under 1% on the discovery surface. Both
decompile-alldeltas aresub-proportional to the extra functions (nuttx +46 of 786 = +5.9% work for
+3.96% wall clock; msc.elf +8 of 67 = +11.9% for +9.73%) — it is the cost of
decompiling more code, not overhead.
Tests
tests/stages/*.xmlis impossible here for the reason every sibling analysis-tierdiscovery flag hits: the harness embeds raw
<bytechunk>s and never constructs aload image, so neither the ELF facts nor the Listing exist on that path. Instead,
kuna-console/tests/verify_ptrentry.rsis the two-pass e2e over a newhand-assembled fixture (
cortexm_ptrentry_le32, 405 bytes, committed generator).The fixture carries both shapes:
LEAF@0x08000048(movs r0,#7 ; bx lr) — reachable only by a.rodatafunction-pointer word. Off: in no symbol table, produces no C. On: registered,
decompiles to
return 7;.SWCASE@0x0800005c— byte-for-byte the same shape, but its pointer word sitsin the same discovered function as its target. Must stay undiscovered with the
option on; pinned by its own test.
Plus three unit tests on the collector and the ARM gate, and
ptrentry_only_adds_entriespinning the superset property.Gates
Re-run on the rebased tree (
origin/main208bb155, after #252 / #253 / #254):make testPARITY OK 675/675 ·make test-stagesPARITY OK 386/386 ·make rust-testgreen (295/295 result blocks) ·make check-specgreen (strict) ·kuna catalog --checkcatalog OK.Every shared counter is derived from a fresh
phase catalogcapture and a greenrun on the rebased tree, not by arithmetic: settables 87 -> 88, analysis tier
26 -> 27, catalog JSON rows 86 -> 87, bytecompat fixture 87 -> 88,
phase_catalog.jsonre-captured (byte-identical to the auto-merge, verified ratherthan assumed),
docs/options.mdregenerated. The live-value count stays at 29 —this row declares no codegen
live_field, so it joinsPASS_GATESinstead;peimportcallis transform-tier despite being P1, so this row is the only one thatmoves the analysis-tier counter.
kuna-base/src/xml.rs' corpus count was verifiedby counting the files (83 datatests + 107 stages = 190, unchanged) and
docs/baseline-stages.jsonis untouched, because this PR adds no stages XML. Nodocs/baseline.jsonre-pin, and no DIV row (default-OFF, so default output isbyte-identical — nothing to renumber).
The acceptance table above was re-measured on the rebased build and is
unchanged: +1,613 / 1,613 GT (95.2%) / 0 splits / 0 lost, with 0 of 48
per-binary entry sets differing from the pre-rebase run, on either side. The
off-vs-on sha256 ablation was re-confirmed too (u-boot's absolute hash moved with
the newly merged PRs, but off and on remain identical to each other, which is the
property being asserted). #254 is PE-only and this is ARM Cortex-M, as expected.
Bundle:
docs/features/ptrentry/—analysis.md,plan.md,record.json,measurements.txt(per-binary tables for all four measured configurations).🤖 Generated with Claude Code
https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL