Repository navigation
[AUTOMATED] Recover validated A32 frame inventories by default - #1108
Conversation
Add the inventory value to armframes: recover disconnected A32 inventory roots while keeping full Thumb and independent reference expansion explicit. Apply literal-pool evidence to frame prefixes and retain reconciled prefix instruction records. Verified focused AIF and CLI regressions, 24 stage assertions, catalog byte compatibility, and spec anchors. Full corpus and workspace checks remain deferred under the task workspace policy. Paired U-Boot coverage gains 770 bodies with zero losses; Betaflight coverage is unchanged.
Resolve conflicts with main: keep the bejoin evidence note in modes.rs, take main's catalog row count (306/312) with this branch's armframes assertions, bump the stage corpus count to 549, keep both fixture README entries, and re-record docs/baseline-stages.json (2975 keys). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RVkhSR3PZKoRmKDbGHjfqH
Resolve conflicts with main: take main's catalog row count (307/313) with this branch's armframes assertions, bump the stage corpus count to 551, and re-record docs/baseline-stages.json (2987 keys). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RVkhSR3PZKoRmKDbGHjfqH
|
[AUTOMATED] Merged current main into this branch to clear the conflicts (catalog row count, stage corpus count, fixture README) and re-recorded docs/baseline-stages.json; no change to the feature itself. |
|
[AUTOMATED] Holding this one for now — the accuracy gain is real, but the default-ON speed cost is beyond what kuna accepts for a default flip. What was measured on this branch (merged with current main as
Paths forward: cut the recovery cost (e.g. share the frame inventory with |
|
[Human] |
Re-derived the stage corpus count (558) and the catalog row count (310 rows, 316 matches), and re-recorded docs/baseline-stages.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016pSwXZADyVQwR4kf1NErrA
…eir functions With frame recovery on by default, the AIF fingerprint histogram is drawn from the whole program, so A32 switch case blocks the Listing never decoded started passing as function entries and cut their dispatchers apart (U-Boot parse_label at 0x608045ac). A frame root a few instructions into a shrink-wrapped routine also stayed an entry next to the real one (malloc). - The Listing walk now follows guarded A32 jump tables (ldrls pc,[pc,rN,lsl Noelo-Lab#2] word tables and addls pc,pc,rN,lsl Noelo-Lab#2 branch tables) when armframes is enabled, reading the case count from the cmp guard as the Thumb tbb reader does. Thumb-only images are unaffected. - A frame root that the frame-expanded Listing enters by straight-line flow from a function entry or branch target is withdrawn, like a root whose mode is contradicted; a run that starts after a call stays speculative. - A retained prior entry reached by a jump-table dispatch is contradicted. Stripped U-Boot O2-noinline against its own symbols: recall 91.9% -> 92.0%, precision 92.6% -> 98.6%; O2: recall 91.05% -> 91.25%, precision 91.4% -> 97.3%. On A32 binaries that keep a symbol table no true function is lost and precision rises (hostapd 72.3% -> 86.0%, libpcap 49.8% -> 77.7%). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016pSwXZADyVQwR4kf1NErrA
Inventory frame recovery decoded the same image many times over: frame validation, the prior inventory's AIF walk, every prefix reconciliation, the post-frame AIF walk and each Listing rebuild of its fixpoint loop. On stripped U-Boot that was five full Listing builds and six gap scans. One recovery now shares a decode memo. A decode is kept only when SLEIGH certifies it context-free (the existing one_instruction_reusable certificate), together with the effective context words it read, and is reused only while its address still reads those words, so a reused record is exactly the record a fresh decode makes and reports no context commits. The inventory never replays a frame body into a reference walk, so its records keep no p-code; reference walks (armframes on) keep theirs. Output is byte-identical to the previous commit (U-Boot O2 and O2-noinline, all 24 Thumb firmware images, and the CLI fixtures). `kuna functions` on stripped U-Boot O2-noinline drops to about half the time. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016pSwXZADyVQwR4kf1NErrA
Every `decompile-all --jobs N` worker loads the image again, and with frame recovery on by default each one re-ran the whole search: on stripped U-Boot `--jobs 8` went from 5.3 s to 14.1 s wall. Turning the recovery off in workers is not an option, because its final Listing also decides decode modes, no-return facts and call returns (548 U-Boot functions changed). The search now leaves a record of what it decided: the final frame roots, code-pointer and AIF entries, and the retained prior entries (`AnalysisOutput::arm_frames`, kept on the program). The pool writes it next to the worker inventory, and a worker that skips discovery hands it to its analysis commit, which builds only the final Listing from it. That is the parent's Listing, because every discarded round of the search ran in a rolled-back decode context. `--jobs-full-load` still runs the full search. `decompile-all --jobs 8 --option protoorder off` on stripped U-Boot is byte-identical to `--jobs 1` and to `--jobs-full-load`; a new CLI test checks the same on the authored switch fixture. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016pSwXZADyVQwR4kf1NErrA
The decode memo held one hash-map entry per decode with its own mnemonic, operand and flow-target allocations. On a large stripped A32 image that is most of the image at once: Samba's 475,000 records cost about 130 MB, lifting `kuna functions` from 251 MB without the memo to 382 MB. Records are now 16-byte slots, one per halfword of each executable range, allocated per range on first use, with their text and flow targets in two shared arenas and the flow type packed into 16 bits. A decode a slot cannot hold (an odd address, a field that does not fit) is simply not kept. Output is unchanged. `kuna functions` on stripped Samba: 7.35 s and 382 MB before, 6.04 s and 272 MB after (main: 1.7 s, 50 MB); on stripped U-Boot: 2.05 s and 152 MB before, 1.78 s and 124 MB after (main: 0.6 s, 48 MB). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016pSwXZADyVQwR4kf1NErrA
Following A32 jump tables decodes switch cases, and a routine reached only by a tail branch from a case is then walked as part of the switch, as the Listing walk already treats any tail-branch target. On stripped U-Boot O2-noinline that merges 6 of the 2,836 true functions into their callers (one on O2); `--option tailcallentry on` splits all of them off again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016pSwXZADyVQwR4kf1NErrA
Re-derived the stage corpus count (560) and the catalog row count (311 rows, 317 matches), and re-recorded docs/baseline-stages.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016pSwXZADyVQwR4kf1NErrA
|
[AUTOMATED] Pushed fixes on top of a merge of current main (counts re-derived, stage baseline re-recorded):
Cost against main, as medians of interleaved, pinned runs:
|
…absorbs The spec said every U-Boot routine the switch walk absorbs is a tail-branch target of a case. Four are (`pointer`'s cases); `memalign_simple`, `efi_process_event_queue` and `malloc_trim` are tail-branch targets of `memalign`, `efi_queue_event` and `free`, which the walk now reaches through a followed case. `malloc_trim` was found by frame recovery alone, so the count is 7, not 6. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016pSwXZADyVQwR4kf1NErrA
|
[AUTOMATED] Pushed |
Stripped A32 firmware loses hundreds of functions that only a disconnected stack frame reaches: no call reference, no symbol, no vector entry.
armframesalready recovers them, but only as an opt-in that also turns on full Thumb recovery and the expensive reference-query expansion. This adds aninventoryvalue, A32 frames for the function inventory only, and makes it the default.DecBench's public U-Boot (O2-noinline) shows it:
Main
4aac7a27emits 2,352 functions; this branch emits 2,816.--option armframes offreproduces main's JSON byte for byte.On the DecBench 96-binary samples, scored with the nightly scorer against main
2a298195(nothing that touches ARM discovery has merged since):All gains are U-Boot functions whose ground-truth start was missing; no function covered on main is lost in any preset, and no previously perfect GED or type score changes.
Cost. The extra time is the cost of decompiling the extra functions, not a slowdown of the existing ones:
The per-function cost stays inside the 5% speed budget; the total grows because U-Boot now has 20% more functions to decompile. Binaries where no frame validates pay only the scan.
armframestakesinventory | on | off, defaultinventory.inventoryvalidates LR-saving A32 frames in undefined executable code and adds them to the function inventory.onkeeps its previous meaning (also Thumb frames and independent ARM reference queries, the part that once doubled a BusyBox query);offrestores the previous inventory.aifpoolslideliteral evidence from the original Listing and the validated frames, so a prefix that begins inside a literal pool word no longer replaces the true entry. The reconciled prefix keeps its validated instruction records.docs/options.mdanddocs/spec/01-program-prep.mddescribe the new value and default.Tests:
tests/stages/kuna-arm-frame-inventory.xml(two-pass: the disconnected frame appears only by default, the literal-guarded caller starts at its own address and keeps its incoming value, and disabling the guard reproduces the literal entry), new AIF unit cases for retained prefix records, and CLI fixturesarm_frame_pool_le32/arm_frame_retain_le32with their generator.make testpasses 675/675 andmake test-stages2906/2906 (PARITY OK);kuna catalog --checkpasses anddocs/options.mdis regenerated.