Repository navigation
Conversation
…substrate); remaining blocker is ActionDeindirect stub Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ties port (LOSS-156 gate localized)
Ports the LOCAL-scope half of the `localmap->queryProperties` walk that
`Heritage::guard` runs (`database.cc:1268` / `heritage.cc:1192`), the precise
gate for the stack-local struct-typing cluster (LOSS-156):
- `ScopeLocal::query_properties` (varmap.rs) — delegates to the existing
`Database::query_properties`, returning a `map addr`-mapped stack range's
`mapped | addrtied | typelock | ...` flags (0 off-symbol).
- `Funcdata::query_local_properties` (funcdata_spacebase.rs) — the
`Funcdata`-level accessor `Heritage::guard` would call.
- A focused unit test (varmap/tests.rs) pinning that a mapped stack symbol
comes back `mapped | addrtied` and an unmapped range returns 0.
Held as +0 SUBSTRATE (not wired into `Heritage::guard`): OR-ing
`query_local_properties` into `fl` at heritage.rs:1370 is the full faithful
fix — it gives a `map addr` stack range `addrtied`, so `guard_calls` builds the
INDIRECT that keeps the symbol's stores live across calls and
`propagateSpacebaseRef` types it (MEASURED: +7 — Partial splitting #15-19,
Wayoff array #1, No for-loop alias #3 → 471). But enabling it ALSO exposes two
downstream gaps that regress 4 assertions, so it is NOT wired:
(a) addrForced array stores do not store-cross-merge — varcross
"Store cross #1/#2" (the two conditional `local_array[10]` stores stay
split instead of phi-merging to `local_array[10] = v2`);
(b) a typed stack struct's `&v1.arr1[a]` intermediate pointer is not
forwarded/collapsed — dupptr "Intermediate pointers #3/#5".
The strict monotonic gate (regressed-set must be empty) is not met, so the
heritage OR is documented in-place (heritage.rs NOTE) and deferred.
Substrate is byte-neutral: datatests [675, 468] (base==branch, regressed/gained
empty), cargo test --workspace 0 failures, C++ baseline PARITY OK, no
decompiler/cpp or docs touched.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…_properties OR (b120faf substrate); +7 gated on store-cross-merge + ptr-forwarding Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ct IR rewrite + commitNewInputs/Outputs — recovers Deindirect Output #2 (net +5, regressed-set EMPTY) On the b72bfea killedbycall substrate (merged), the CALLIND (*0x100046)(nm) now deindirects to a direct 'call obtainPtr' with a single clean 8-byte RAX output BEFORE output recovery, so 'return 0;' survives (Deindirect Output #2 no longer regresses) and the two-piece killed-output shadow CONCAT is gone (Output #3 gained). - ActionDeindirect::apply (coreaction_render.rs:1101, C++ coreaction.cc:1235): iterate CALLIND ops, trace in0 through COPYs, resolve a constant/external-ref target via the global-scope queryFunction snapshot, call FuncCallSpecs::deindirect. - Architecture::query_function (seams.rs, C++ Scope::queryFunction database.cc:1292): exact TYPE_CODE function-entry hit -> (name, entry, recovered proto), off the frozen GlobalQuery (no database.rs edit — avoids the concurrent stacklocal wave). - FuncCallSpecs::deindirect (fspec.rs, C++ fspec.cc:5448): un-stub the IR rewrite (newVarnodeCallSpecs + opSetInput + opSetOpcode CALLIND->CALL + insertIndirectOverride), then lateRestriction + the now-real commitNewInputs/commitNewOutputs (fspec.cc:5155/5206) + buildParam (fspec.cc:5010) + transferLockedOutput (fspec.cc:5135) merge the killed output pieces into one return-value Varnode. - FlowInfo::setupCallindSpecs (flow.rs): consume applyIndirect (flow.cc:729) so a restart re-flow would rebuild the CALLIND straight as a direct CALL; next_fspec_handle is now pub(crate) for the deindirect annotation Varnode. Gates: cargo build (release) + cargo test --workspace (1765+ pass, 0 fail; the two fspec deindirect unit tests now exercise the real rewrite via an fspec-space fixture); datatests [675,473] vs base-468 — GAINED Conditional Add #1, Conditional Subpiece #1, Modified conditional constant #2/#3, Deindirect Output #3; REGRESSED set EMPTY; C++ baseline PARITY OK; no decompiler/cpp or docs changes. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…irect) +5 → 473 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…-placement/INDIRECT-collapse wave (+10 potential) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Restore the faithful C++ opSubpiece dispatch (printc.cc:892-897):
isSubpieceCast(out->getHighTypeDefFacing(),
in0->getHighTypeReadFacing(op), in1->getOffset())
? opTypeCast : opFunc
The cast arm was deliberately gated out (op_subpiece_ir) because it
rendered a spurious `(int4)ptr` on condconstsub — but that was a free
SUBPIECE the call-return-recovery seam had left in the IR. With the
killedbycall + ActionDeindirect wave landed (base 1e4a2df), condconstsub's
`process` now returns the recovered call output and no spurious SUBPIECE,
so the dispatch is safe to restore. The `subpiece_is_cast` predicate
already reads the high-facing types (get_type_def_facing /
get_type_read_facing), matching C++.
Net +3, regressed-set EMPTY (base 473 → 476):
+ Bitfields #4
+ Union #8
+ Union #28
condconstsub `Modified conditional constant #4` stays byte-identical.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…eCast?opTypeCast:opFunc (printc.cc:892); Bitfields #4, Union #8, Union #28 +3 → 476 (cascade from call-return IR fix) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… Union #8/#28); LOSS-230 Family-1 closed Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…node markNotMapped/markUnaliased tail (604408a substrate ready) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ed-symbol seed + varnode-SymbolEntry binding unported) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…lated gaps remain (store-merge + ptr-forwarding), OR-wire is one line Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…nalMove (RuleIgnoreNan substrate ready on branch) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…t block; block-construction divergence) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…blocks signed div/mod reconstruction
RuleDoubleArithShift is registered under the runtime group "analysis"
(coreaction.cc:5808 / universalaction.rs), but its clone_rule gated on
grouplist.contains("doublearithshift") — the per-op placeholder NAME, which is
not a member of the "decompile" grouplist. The rule was therefore dropped from
every cloned ActionPool and never ran, so `(x s>> a) s>> b` collapses never
happened. That left the RuleDivOpt-produced signed-division sign correction
(`div + (x s>>31) - (x s>>31)` with an uncollapsed double shift) un-cancelled,
which in turn blocked RuleModOpt from reconstructing `x % C`.
Fix mirrors the prior RuleDoubleShift fix two functions above: accept "analysis"
(the real runtime group) OR the placeholder name (keeps the specs() contract).
Datatests (rust engine, 675): 476 -> 479. Gained: ModuloAlt #2, ModuloAlt #4,
If/Switch #4. Regressed: none. PARITY OK. cargo test: no new failures.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… (analysis group, not placeholder name; coreaction.cc:5808); ModuloAlt #2/#4 + If/Switch #4 +3 → 479 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… → 479 (ModuloAlt #2/#4, If/Switch #4) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ysis" but gated on placeholder name; fix +2 → 481
A whole bug class in ruleaction_2.rs: each Rule is registered under the
runtime group "analysis" (coreaction.cc actprop->addRule(new RuleX("analysis"))),
but its Rust clone_rule gate tested grouplist.contains("<placeholder>") — the
per-op short name — instead of contains("analysis"). The placeholder is not a
member of the "decompile" grouplist (action.rs), so each rule was DROPPED from
every cloned ActionPool and apply_op never ran (same defect already fixed for
RuleDoubleShift / RuleDoubleArithShift).
Fixed all 17 (gate now contains("analysis") || contains("<placeholder>"), so the
group arm fires in the live pools matching C++, and the placeholder arm preserves
any direct single-rule invocation):
RuleFloatRange, RuleAndCommute, RuleAndPiece, RuleAndZext, RuleAndCompare,
RuleDoubleSub, RuleConcatShift, RuleLeftRight, RuleShiftCompare, RuleLessEqual,
RuleLessNotEqual, RuleTrivialBool, RuleZextEliminate, RuleSlessToLess,
RuleZextSless, RuleBitUndistribute, RuleBooleanUndistribute.
All 17 confirmed registered "analysis" in coreaction.cc (5787–5883).
Datatest passing set: 479 → 481. Gained: "Bitfields #2", "Signed byte #4".
Regressed set EMPTY (full base-479 vs fixed-481 diff). B0 universalaction_listing
byte-equal (registration untouched — only clone-gate predicates changed).
kuna-decomp lib 1767/1767, mixfloatint_multislot green, C++ baseline PARITY OK.
No decompiler/cpp/** or docs/** touched.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ysis-group rules whose clone-gate tested the placeholder name → never fired); Bitfields #2, Signed byte #4 +2 → 481 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…xed; Bitfields #2, Signed byte #4) + branch-recovery ops note Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…der RULE_GROUP
Extends the W10 clone-gate audit (which fixed 17 ruleaction_2 rules) into the
files the prior pass skipped/spot-checked. ruleaction_5.rs is CLEAN: all 9
clone-gates test the dynamic self.group field set to the exact registration
group (6 analysis, 3 typerecovery — verified against coreaction.cc 5824-5937).
ruleaction_1/3/4/6/7 re-verified clean (dynamic self.group, or literal gates
that match their C++ registration group exactly).
The bug surfaced in ruleaction_8.rs: a single RULE_GROUP="analysis" const
gated all 12 rules, but three are NOT registered "analysis":
RulePiecePathology -> "protorecovery" (coreaction.cc:5? / universalaction.rs:524)
RuleFloatSignCleanup -> "cleanup" (universalaction.rs:553)
RuleExpandLoad -> "cleanup" (universalaction.rs:554)
C++ clone() tests getGroup() (== the registration group), so these three were
gated on the wrong group and dropped from / mis-placed in their pools. Fixed
each to contains("<reggroup>") || contains("<placeholder>") (same idiom as the
ruleaction_2 fix); the registration in universalaction.rs was already correct
and is untouched. Also corrected the local specs() metadata + its test, which
had hard-coded all 12 as "analysis".
Net-ZERO fidelity: datatest passing set BYTE-IDENTICAL to base-481 (gained 0,
regressed 0, footer [675, 481]) — these rules live in protorecovery/cleanup
pools whose net output is unchanged by current datatests; this lands as a
fidelity substrate (correct pool membership) with the regressed set EMPTY.
kuna-decomp specs test green, B0 universalaction_listing byte-equal
(registration untouched), C++ baseline PARITY OK. No decompiler/cpp/** or
docs/** touched.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…put #1 (+1 -> 482) ActionInferTypes' output-side local-type resolution (`output_type_local`, the port of `op->outputTypeLocal()`) was missing the CALL/CALLIND prototype arm. C++ `TypeOpCall::getOutputLocal` (typeop.cc:722) / `TypeOpCallind::getOutputLocal` (typeop.cc:778): when the resolved `FuncCallSpecs` has a locked (committed) output prototype, the call output Varnode's suggested type is the callee's (non-VOID) return data-type (`fc->getOutputType()`). The Rust port had the input-side counterpart (`call_input_type_local`) but no output-side equivalent, so a deindirected CALL to a known-proto function (`int4 *obtainPtr(char *)`) left its return Varnode at `undefined8`; `ActionSetCasts` then inserted a spurious `(int4 *)` cast, rendering `v1 = (int4 *)obtainPtr(nm)` instead of the oracle's `v1 = obtainPtr(nm)`. Add `call_output_type_local` (faithful transcription: CALL requires in(0) to be an fspec reference; both resolve the spec, gate on `isOutputLocked()`, drop VOID) and wire it into `output_type_local` before the generic size-only fall-through. Gate: cargo test --workspace --no-fail-fast 0 failures; datatests [675, 482] (base 481), gained "Deindirect Output #1", regressed-set EMPTY; C++ oracle PARITY OK; decompiler/cpp/** + docs/** byte-untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…/CALLIND locked-output arm (TypeOpCall::getOutputLocal typeop.cc:722); Deindirect Output #1 +1 → 482 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
#1; deindirect family fully recovered) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ules in wrong pool (RulePiecePathology→protorecovery, RuleFloatSignCleanup/RuleExpandLoad→cleanup); +0 fidelity, regressed-set EMPTY. ruleaction_5 confirmed clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…on_8 rules → correct pool); bug class fully swept (20 rules) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…+ new mergeAddrTied overlapLoc seam #2/#3/#4) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…x00...) RuleAddUnsigned::apply_op was stubbed: it bailed on the W6 `getTypeReadFacing` seam, so INT_ADD of a high-bit unsigned constant never converted to INT_SUB. The read-facing type machinery (Funcdata::vn_type_read_facing) and the commit helpers (op_set_opcode_code routing INT_SUB through typeop::type_op_for, new_constant, copy_symbol, op_set_input) have since landed, so the rule is now ported faithfully from ruleaction.cc:7215: - read-facing TYPE_UINT / !isCharPrint guards - "first quarter of bits all 1's" quarter mask - named-equate name-lock guard (EquateSymbol) - enum hasNamedValue(negated)/hasNamedValue(~val) guard - opSetOpcode(INT_SUB) + newConstant((-val)&mask) + copySymbol Fixes the `fval + 0xfffffff0` -> `fval - 0x10` render in floatconv.xml "Floating-point convert #1", and the same +const cleanup in "Promotion on compare #1" and "Switch Multi #3". Datatests 482 -> 485 (+3), regressed set empty. cargo test --no-fail-fast clean. PARITY OK. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This was referenced Oct 5, 2026
mahaloz
pushed a commit
that referenced
this pull request
Oct 12, 2026
A fixed ARM `LSL #2` on a signed parameter emits a C11 shift that is undefined for negative values and positive overflow. Converting the result afterward does not help: ```sh printf '\000\001\240\341\036\377\057\341' > /tmp/lsl.bin printf 'function 0x10000-0x10008=ShiftLeftTwo\nprototype 0x10000 unsigned int ShiftLeftTwo(int value)\n' > /tmp/lsl.kuna kuna decompile-all /tmp/lsl.bin --raw-image --base 0x10000 --entry 0x10000 \ --target ARM:LE:32:v5t:default --isa arm --mode reliable --jobs 1 \ --assert @/tmp/lsl.kuna --assert-strict --option armconstshift on ``` Without the option the output is `return value << 2;`; with it, `return (int4)((uint4)value << 2);`. **Fix** - New P9 option `armconstshift` (default off, not in the aggressive preset): convert signed operands before fixed-width ARM left shifts and restore signed results where later operations need signed semantics. - Evaluate each operand once, and leave unsigned shifts and variable-count guards unchanged. - Off by default because firmware tests nearly every register flag with a sign-bit shift: `x << 0x18 < 0` becomes `(int)((unsigned int)x << 0x18) < 0`, a cast pair on each one (11 functions on three libopencm3 examples change only by that). **Tests** - `kuna-arm-constant-shift.xml` is two-pass: off keeps the shift as written, on pins the conversion and the signed consumers. - `arm_constant_shift::` (with the option on) compiles and runs the emitted C with GCC and Clang at `-O0` and `-O2`, including UBSan. [AUTOMATED] includes review fix-ups by Claude Code. Co-authored-by: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011d7uHgQPRpFwdybmGwWHtw
mahaloz
added a commit
that referenced
this pull request
Oct 12, 2026
…ment (#1044) `--max-fn-seconds` cannot stop a function that hands the addresses of many stack locals to many calls: it runs far past the budget and its memory keeps growing until it finishes or the system kills it. This 45 KB function asks for 1 second and gets 13: ```c // big.c -- clang -O0 -fno-pic -no-pie -nostdlib -Wl,-e,big -o big big.c struct S { int a; long b; char c[24]; }; __attribute__((noinline)) int cb(void *p) { return *(int *)p; } __attribute__((noinline)) int reg(const char *n, void *p, int i, int (*f)(void *)) { return f(p) + i + *n; } #define L(i) { struct S s; s.a = (i); s.b = r; r += reg("n", &s, (i), cb); } #define L10(i) L(i##0) L(i##1) L(i##2) L(i##3) L(i##4) L(i##5) L(i##6) L(i##7) L(i##8) L(i##9) #define L100(i) L10(i##0) L10(i##1) L10(i##2) L10(i##3) L10(i##4) L10(i##5) L10(i##6) L10(i##7) L10(i##8) L10(i##9) int big(void) { int r = 0; L100(1) L100(2) L100(3) L100(4) L100(5) L100(6) L100(7) return r; } ``` ``` $ /usr/bin/time -f '%e s, %M KB max RSS' kuna decompile-all big --functions big --json --max-fn-seconds 1 "error": "per-function decompile budget exceeded (1 s)" 13.13 s, 2672244 KB max RSS ``` The same shape at 290 KB (5,000 locals) ignores a 10 s budget and reaches 8 GB in 36 s, which matches the growth in #1034. - Heritage guards every stack range at every call, as upstream does, so this function gets one INDIRECT per (local, call) pair, about a million here. That placement loop had no deadline probe; it now checks the deadline before each range. - A pass whose deadline passed during placement returns before renaming, and a pass panic after the deadline reports the budget error, not the panic text. - A function that finishes inside its budget is unchanged: the probes only act once the deadline has passed. After: 1.37 s, 389 MB for the example; 10.8 s and 775 MB for the 290 KB function with a 10 s budget. Tests: `watchdog_stops_heritage_guard_placement` runs the example (checked in as `tests/hang-repro/escaped_locals`) with a 1 s budget and fails without the fix (15 s against a 10 s bound). Speed (decompile-all of gzip, kmod, grep and ls, 11 interleaved runs): +1.7% on the min-sum with flat medians. That is within noise: the new probe runs 26,518 times over all of `ls`, which is well under a millisecond. Part of #1034 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015sdZpNU5odw5dVyaxeSvvz
mahaloz
added a commit
to mgostIH/kuna
that referenced
this pull request
Oct 17, 2026
…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
mahaloz
pushed a commit
that referenced
this pull request
Oct 17, 2026
Stripped A32 firmware loses hundreds of functions that only a disconnected stack frame reaches: no call reference, no symbol, no vector entry. `armframes` already recovered them, but only as an opt-in that also turned on full Thumb recovery and the expensive reference-query expansion. This adds an `inventory` value, A32 frames for the function inventory only, and makes it the default. `on` keeps its previous meaning; `off` restores the previous inventory byte for byte. DecBench's public U-Boot (O2-noinline) shows it: ```sh curl -fL 'https://huggingface.co/datasets/noelo-lab/decbench-dataset/resolve/815eb96f130b6d2ef7fa600e04669bf20139bf27/binaries/O2-noinline/u-boot/u-boot' -o /tmp/u-boot.bin llvm-strip --strip-all -o /tmp/u-boot /tmp/u-boot.bin kuna functions /tmp/u-boot --json | jq .count ``` Main finds 2,352 functions; this change finds 2,647. Scored against the symbols of the unstripped copy, recall goes from 62.0% to 92.0% and precision from 74.8% to 98.6%. The O2 build goes from 67.3% to 91.25% recall and from 73.3% to 97.35% precision. Six of the 1,759 true starts main finds on O2-noinline, and one on O2, are no longer separate functions, and neither is `malloc_trim`, which frame recovery alone finds on both builds. Each is reached only by a tail branch from code the walk now decodes through a followed switch: four from the cases of `pointer`, the others from `memalign`, `efi_queue_event` and `free`. The walk already treats any tail-branch target as part of its caller. `--option tailcallentry on` recovers all of them and raises O2-noinline recall to 94.5% at the same precision. On a stripped wpa_supplicant the same absorption costs 5 of the true starts main finds, while recall still rises from 79.0% to 92.2% and precision from 59.9% to 79.3%. Stripped hostapd and libpcap lose none. Thumb-only firmware (Betaflight, Crazyflie CF2 and CMSIS-DAP, NuttX at O0, O2 and O2-noinline, stripped and not) is byte-identical in both `functions` and `decompile-all`. - `inventory` validates LR-saving A32 frames in undefined executable code, keeps every entry the frameless inventory reports unless the frame-expanded Listing contradicts it, and reconciles AIF-supported prefixes. The prefix check uses `aifpoolslide` literal evidence, so a literal-pool word in front of a frame never replaces the true entry. - With frame recovery on, the AIF fingerprint histogram is drawn from the whole program, so switch case blocks the Listing never decoded started passing as function entries (U-Boot's `parse_label` was cut at its case 9). The Listing walk now follows guarded A32 jump tables (`ldrls pc,[pc,rN,lsl #2]` word tables and `addls pc,pc,rN,lsl #2` branch tables), reading the case count from the `cmp` guard. A frame root that the expanded Listing enters by straight-line flow from a function entry or branch target (a shrink-wrapped `push` a few instructions into `malloc`) is withdrawn. With them, 2 U-Boot functions are newly split against main; with frame recovery alone, 23 were. On A32 binaries that keep a symbol table, precision also rises with no true function lost (hostapd 72.3% to 86.0%, libpcap 49.8% to 77.7%, libc 64.1% to 69.7%). - One recovery shares its decodes across frame validation, the AIF walks, prefix reconciliation and every Listing rebuild of its fixpoint. A decode is reused only while its address still reads the decode context SLEIGH certified it under, so output is unchanged. - `decompile-all --jobs N` workers no longer repeat the search: the parent hands them a record of its final frame roots, AIF entries and retained entries, and each worker builds only the final Listing. `--jobs 8 --option protoorder off` is byte-identical to `--jobs 1` and to `--jobs-full-load` on U-Boot, Samba, BusyBox, ProFTPD and glibc. Cost. On a stripped A32 image whose frames validate, discovery does real extra work: it validates every LR-saving frame in the image and walks the whole program it finds, where the frameless walk reaches only part of it. Each round of the recovery's fixpoint (prefix reconciliation, mode checks, the AIF pass) walks the expanded program again, five Listing builds on U-Boot. Measured against main on a shared host: medians of 10 runs for discovery and 8 for `decompile-all`, main and this change interleaved and pinned to idle cores, CPU is user plus system, memory is the largest process's peak RSS. | Stripped image | `functions` (main → this) | `decompile-all --jobs 1` | `decompile-all --jobs 8`, wall | |---|---|---|---| | U-Boot O2-noinline | 0.59 s → 1.79 s, 48 → 122 MB | 29.2 s → 27.6 s | 5.2 s → 5.8 s | | Samba multicall | 1.8 s → 6.4 s, 50 → 265 MB | 26 s → 106 s, 188 → 375 MB | 6.7 s → 17.5 s | | BusyBox | 1.2 s → 2.0 s, 57 → 98 MB | 44.3 s → 35.8 s | 8.5 s → 7.4 s | | ProFTPD | 1.3 s → 2.0 s, 65 → 152 MB | 26.2 s → 26.9 s | 6.1 s → 6.5 s | | glibc 2.30 | 2.0 s → 2.6 s, 106 → 141 MB | not measured (one main run exceeds 20 min) | 240 s → 68 s | `disassemble` of a function costs what `functions` does, because it loads the same inventory, and so does every other command that loads one. That is 1.3× (glibc) to 3.6× (Samba) main's discovery time, and 1.3× to 5.3× its memory. `decompile-all` pays it once, in the parent: on U-Boot, BusyBox and ProFTPD the totals stay within a few percent of main, or below it, because main decompiles false entries this change no longer reports. On glibc, main spends 1,055 of its 1,258 CPU seconds under `--jobs 8` on the 290 entries this change drops. Samba is the exception: it now decompiles 5,074 functions instead of 2,361, with about twice as much C, so its run takes about four times as long. Thumb-only firmware is unchanged in output, and its timings are flat within noise. Tests: `tests/stages/kuna-arm-frame-inventory.xml` (two-pass), AIF unit cases for retained prefix records and the shared decode memo, and CLI tests on authored fixtures: a literal-pool prefix (`arm_frame_pool`), a retained tail target (`arm_frame_retain`), and a disconnected frame that dispatches an `ldrls pc` switch and calls a shrink-wrapped routine (`arm_frame_switch`, which also checks `--jobs 2` against `--jobs 1`). `make test` passes 675/675 and `make test-stages` 3,041/3,041; the workspace suite, `make check-spec`, `make test-cli` and `kuna catalog --check` pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016pSwXZADyVQwR4kf1NErrA
mahaloz
added a commit
to thotypous/kuna
that referenced
this pull request
Oct 22, 2026
…tatest baseline Revisit SSA Noelo-Lab#2 pinned the stored value reaching the call's INDIRECT on the global. With the store now kept until its effects cover the full write, that value reaches the INDIRECT through the explicit 4-byte COPY at 0x1001a, which the default `indexaliasguard global` keeps out of a store guard; `indexaliasguard full` still forwards it as upstream does. Accept either shape, and restore the 675-assertion baseline unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BEr111CDLJsQMzY3YSyWXD
mahaloz
pushed a commit
that referenced
this pull request
Oct 22, 2026
…1253) RuleStoreVarnode no longer turns a STORE into a COPY of an already-heritaged persistent global unless contiguous INDIRECTs naming the STORE cover every byte. Without that coverage the new COPY was unread and dead-code removal deleted it (e.g. when the global alias-guard budget is exhausted), so the store vanished from the output. The STORE now stays explicit. Revisit SSA #2 accepts the stored value reaching the call's INDIRECT through the kept COPY (the default `indexaliasguard global` shape; `indexaliasguard full` still produces upstream's forwarded shape). Base matched the old shape only through the lost-store path, which also printed a junk `dat_100074 = (int2)dat_100074;`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BEr111CDLJsQMzY3YSyWXD
mahaloz
added a commit
that referenced
this pull request
Oct 31, 2026
…phi order behind clonephiorder The split now destroys a one-input phi from a global to itself in the original block too, not only when its input is a COPY's output. A copy left there was cloned as a plain COPY by the block's next split, and ActionVarnodeProps replaced its known-zero output with 0, so the guard that read it printed a second store: bash sh_getopt `nextchar = NULL;` (O2, O2-noinline, /usr/bin/bash) and scp getopt_internal `BSDoptarg = NULL; BSDoptreset = 0; place = "";`, all once in the binary on those paths. ELFMAIN #2 (an option-off pass) accepts the -O0 local form the split now prints. Address-ordering a clone's global phis picks an order the binary does not record, so it is the `clonephiorder` option (default on, P8, transform). Over 140 corpus binaries on and off differ in 119 store runs; of the 34 the disassembly decides, on matches 21 and off 9. kuna-retcopyclone #8/#9 pin both arms. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
mahaloz
added a commit
that referenced
this pull request
Nov 1, 2026
… clonephiorder off prints ELFMAIN #2 accepted `= a1[1];` on its own, so an off-pass output that stored the element and lost the call to sub_1357 would still pass. It now matches the call in both forms the off pass prints, line by line: `v1 = sub_1357(a1[1]); return v1;` (base) and `v1 = a1[1]; return sub_1357(v1);` (once the split leaves no identity copy, the call folds into the return). Both pass on base, the PR head, and the PR merged with main. clonephiorder's catalog text, module header and spec 08 now say what the off arm's "block order" is: heritage inserts each phi at the block start in ascending address order, so one pass's phis end up in descending address order. Regenerated docs/options.md and the catalog fixture. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
alvistar
added a commit
to alvistar/kuna
that referenced
this pull request
Nov 1, 2026
The reference walk stopped at a guarded `addls pc,pc,rN,lsl Noelo-Lab#2` or `ldrls pc,[pc,rN,lsl Noelo-Lab#2]` and walked only `b default`, so every case body went unreferenced, and it filed a jump from the dispatch to the next instruction. It now reads both forms with the reader the Listing walk already uses under `armframes` (`kuna_a32switch`), walks each case as the dispatcher's own code with the dispatch's state, so a GOT base made before the dispatch reaches every case, and files one jump row per case. The predicated skip is a fall-through, not a reference. The words of an `ldr` table stay data with no pointer row, as in Ghidra's ARM switch recovery. Fixture `branchtable_arm_le32` (GCC 14.2, the dispatch in `asm goto` because GCC 14 compresses ARM-state tables) with e2e tests in `verify_branchtable.rs`, a gap record and a promoted CLI probe. Co-Authored-By: Claude Opus 5.5 <[email protected]>
alvistar
added a commit
to alvistar/kuna
that referenced
this pull request
Nov 1, 2026
Pins the rows of an `ldr pc,[pc,r0,lsl Noelo-Lab#2]` table with no range check placed right after a literal-pool word: the dispatch files only the row of its PC-relative operand and no switch record, as before A32 tables were read. The guard read stops at the undecoded pool word, but no table reader can read this form without a case count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
alvistar
added a commit
to alvistar/kuna
that referenced
this pull request
Nov 2, 2026
The reference walk stopped at a guarded `addls pc,pc,rN,lsl Noelo-Lab#2` or `ldrls pc,[pc,rN,lsl Noelo-Lab#2]` and walked only `b default`, so every case body went unreferenced, and it filed a jump from the dispatch to the next instruction. It now reads both forms with the reader the Listing walk already uses under `armframes` (`kuna_a32switch`), walks each case as the dispatcher's own code with the dispatch's state, so a GOT base made before the dispatch reaches every case, and files one jump row per case. The predicated skip is a fall-through, not a reference. The words of an `ldr` table stay data with no pointer row, as in Ghidra's ARM switch recovery. Fixture `branchtable_arm_le32` (GCC 14.2, the dispatch in `asm goto` because GCC 14 compresses ARM-state tables) with e2e tests in `verify_branchtable.rs`, a gap record and a promoted CLI probe. Co-Authored-By: Claude Opus 5.5 <[email protected]>
alvistar
added a commit
to alvistar/kuna
that referenced
this pull request
Nov 2, 2026
Pins the rows of an `ldr pc,[pc,r0,lsl Noelo-Lab#2]` table with no range check placed right after a literal-pool word: the dispatch files only the row of its PC-relative operand and no switch record, as before A32 tables were read. The guard read stops at the undecoded pool word, but no table reader can read this form without a case count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mahaloz
pushed a commit
that referenced
this pull request
Nov 2, 2026
Under `armframes`, xrefs now follows A32 `addls pc,pc,rN,lsl #2` and `ldrls pc,[pc,rN,lsl #2]` tables into their cases (kuna_a32switch, case count from the cmp/ls guard), walking each case with the dispatch's state. Each case gets one jump row; ldr table words stay data; the predicated skip stays a flow but files no row. Only an index scaled by four is read, an ldr table ends before its first odd (Thumb) word, and a predicated computed jump that is not an A32 table gets no other table read, so literal-pool words after a call no longer become cases. `armframes off` and non-ARM images keep the old walk. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKMUBscgGJBW9XHH5hJ
mahaloz
pushed a commit
that referenced
this pull request
Nov 21, 2026
…e (option switchextent, default on) (#1850) A jump table that no range check bounds (Swift's multi-payload enum dispatch, clang's `switch` with an unreachable default) now ends where the next jump table of the same function begins in the same section (option `switchextent`, default on). When a recovery fails, the flow decodes the function's extent once, names the table of every computed jump, and re-bounds the unguarded table to the entries that fit before the next one; a function's last table is left as a computed call. The discovery Listing and the xrefs walk now read AArch64 compact tables (`adr` base, byte/halfword/word offsets scaled by `lsl #2`, signed `sxtb`/`sxth` entries) behind a range check, including a check that branches into the dispatch block, so case bodies belong to their dispatcher and callees reached only from cases are discovered. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKNhsvezm24JAGcKtoV
mahaloz
added a commit
that referenced
this pull request
Nov 22, 2026
gcc -O0 reads each va_arg through the reg_save_area pointer va_start stores in the va_list, at an offset loaded from it. A loop over va_arg lost the prologue's stores of rsi..r9 to the save area before the guard followed that spill, so the printed loop summed an array nothing wrote; kuna-spillptr-loadguard.xml now checks vsum keeps all five (#4). The assertion names #1/#2 say which functions they count; stage baseline re-recorded, 5037 -> 5038. retypehalves_x86_64 (gcc -O2): control's variadic argument is read through its save slot whole and by halves. With the save forced, the slot is one variable with the parameter it arrived in (`unsigned long a2`) instead of a second local `unsigned long v6` beside `unsigned int a2`; stable_local_names now retypes a2 and checks the signature takes it whole. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQR2hseBprKvbvZRUv
This was referenced Nov 24, 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.
Kuna Initial Rust Port
This is the PR that converts the original Ghidra (slightly re-designed for phases) into Rust. During this conversion, we had a methodology to promise some level of correctness, detailed below.
The majority of this code was written by Claude Opus 4.8, but had some Fable 5 input. However, there were many steps along the process that required human intervention to redirect the model. It took a total of 2 human weeks, and 8 LLM days of development.
Methodology
decomp_test_dbgto test a module before and after.docs/rust-port/losses.mdClaude Stats