Repository navigation
cli: default AIF on for non-x86-64 decompile-all — recover stripped ARM Cortex-M functions (crazyflie 1430→2700) - #172
Merged
Conversation
…RM Cortex-M functions The #1 cause of kuna losing to angr on the decbench O0 benchmark is stripped ARM Cortex-M firmware: kuna failed to DISCOVER ~3,600 Thumb functions angr finds (75% of the angr-beats-kuna gap; kuna produces no output on 35% of O0 functions, almost all ARM). kuna already leads on x86 structuring — the ARM discovery failures are what drag it down. ## Root cause `funcstart_patterns` (DIV-20) only seeds a candidate when a matching EPILOGUE prepattern (Ghidra <patternpairs>) sits immediately before it, so ~70% of a firmware's functions — those preceded by literal pools / data / padding and living in call-graph components reachable only through indirect calls / function-pointer tables (87% of the missed have NO direct-call edge) — are never seeded, and the recursive-descent walk (direct CALL/BL only) structurally cannot reach them. ## Fix (the mechanism was already ported, just disabled) kuna already ports Ghidra's Aggressive Instruction Finder (`aif`, ArmAggressiveInstructionFinderAnalyzer): it gap-walks the UNDEFINED regions the walk left uncovered, gating each candidate on a prologue-fingerprint histogram learned from the already-discovered functions + check_valid_subroutine, so it bridges the disconnected components. Its results were computed but DROPPED behind the default-off `analysis_aif` flag. This injects `--option aif on` for non-x86-64 on the `decompile-all` surface (beside the funcstart_patterns/listing injections, DIV-20), unless the caller names it. ## Impact (measured) - crazyflie cf2.elf: 1430 -> 2700 functions (45% -> 82% of angr's discovered set) - betaflight STM32F405: ~1830 -> 4783 functions - libopencm3 cdcacm: -> 82 of 87 ground-truth Extra non-ground-truth functions are harmless to the GED benchmark (scored per ground-truth function, matched by name); strictly more coverage = strictly better. ## Scope / safety Driver policy only — the engine default (`analysis_aif = false`), the console/subprocess path, and x86-64 are untouched (AIF stays OFF for x86-64, so every datatest is byte-identical). make test 675/675 PARITY OK, make test-stages 261/261, make rust-test 0 failures (+ a new arm_decompile_all_defaults_aif_on wiring/non-destructive test). A follow-up (Stage 2) adds angr-style raw unpaired Thumb-prologue seeding to close the dense-binary residual (betaflight still misses ~483 GT functions with a PUSH prologue). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J
This was referenced Jul 14, 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.
The #1 cause of kuna losing to angr on the decbench O0 benchmark is stripped ARM Cortex-M firmware discovery — kuna failed to discover ~3,600 Thumb functions angr finds (75% of the angr-beats-kuna gap; kuna produces no output on 35% of O0 functions, almost all ARM). kuna already leads on x86 structuring, so this is what drags the overall score down.
Root cause
funcstart_patterns(DIV-20) only seeds a candidate when a matching epilogue prepattern (Ghidra<patternpairs>) sits immediately before it. So ~70% of a firmware's functions — preceded by literal pools/data/padding, living in call-graph components reachable only via indirect calls / function-pointer tables (87% of the missed have no direct-call edge) — are never seeded, and recursive descent (direct CALL/BL only) structurally can't reach them.Fix — the mechanism was already ported, just disabled
kuna already ports Ghidra's Aggressive Instruction Finder (
aif): it gap-walks the undefined regions, gating each candidate on a prologue-fingerprint histogram +check_valid_subroutine, bridging the disconnected components. Its results were computed but dropped behind the default-offanalysis_aifflag. This injects--option aif onfor non-x86-64 on thedecompile-allsurface (beside the funcstart_patterns/listing DIV-20 injections), unless the caller names it.Impact (measured)
Extra non-ground-truth functions are harmless to the GED benchmark (scored per ground-truth function, matched by name).
Scope / safety
Driver policy only — engine default (
analysis_aif = false), console/subprocess path, and x86-64 are untouched (AIF stays off for x86-64, so every datatest is byte-identical).make test675/675,make test-stages261/261,make rust-test0 failures (+ a newarm_decompile_all_defaults_aif_ontest).Stage 2 (follow-up) adds angr-style raw unpaired Thumb-prologue seeding for the dense-binary residual (betaflight still misses ~483 GT PUSH-prologue functions).
🤖 Generated with Claude Code
https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J