Repository navigation
Listing/xref tier (scope-B) PR0: recursive-descent disassembly core + design doc - #24
Merged
Merged
Conversation
… design doc
Land the keystone of the post-disassembly Listing/xref tier: a program-wide
recursive-descent disassembler + an instruction / cross-reference /
discovered-function model, reusing the ported SLEIGH decoder and a lifted copy
of the S2 flow classifier. PR0 only — the module is dormant (no engine
invocation, no --option flag, no AnalysisCtx change), so all three parity gates
are structurally untouched.
- docs/listing-tier-design.md: the canonical tier spec (transcribed from the
design fan-out).
- kuna-analysis/src/listing/{model,decode,classify,walk,mod}.rs: the §2 data
model (Insn/FlowType/FlowKind/RawOp/Reference/RefKind/DiscoveredFunction/
CodeUnit), decode_one (Translate::one_instruction + print_assembly capture),
classify (faithful xref_control_flow transliteration, flow.rs:1039-1185, with
the constant-space / last-op / delay-slot gotchas), the two-level
recursive-descent walk, and the Listing facade + Listing::build.
- s1_entry seed helpers (executable_sections/existing_function_addrs/
in_executable_section) promoted to pub(crate) for PR2's seed set.
Tests (both REAL, not skipped):
- 9 classifier unit tests pin classify against the flow.rs rules.
- kuna-console/tests/verify_listing_core.rs drives Listing::build end-to-end on
the bootstrapped x86-64 fauxware fixture (Translate via prog.arch().translate()):
recovered 108 instructions, 11 functions, 16 call edges from 2 seeds; the
je/call/ret/push sites classify correctly. Ran (x86-64.sla built), not skipped.
Gates: make test 675/675 PARITY OK; make test-stages 158/158 PARITY OK;
make rust-test green (incl. the new tests).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…'s earlier value is used after it Keeping the store COPY at the binary's position while the global's earlier value is still read after it made Merge copy that earlier value out where it is defined (the entry, a call, a loop head), above a pointer store the binary reads the global after. The decline now checks for such a read first, through the copies a later propagation can fold, and leaves the store to upstream. Witnesses w_ohoist (gcc -O2), w_oif (gcc -O0, clang -O2) and w_oloop (gcc -O0) added to the globalstore fixtures; stage assertions #22-#24. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
… (1658 -> 1661); footprint on main 363123e Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…'s earlier value is used after it Keeping the store COPY at the binary's position while the global's earlier value is still read after it made Merge copy that earlier value out where it is defined (the entry, a call, a loop head), above a pointer store the binary reads the global after. The decline now checks for such a read first, through the copies a later propagation can fold, and leaves the store to upstream. Witnesses w_ohoist (gcc -O2), w_oif (gcc -O0, clang -O2) and w_oloop (gcc -O0) added to the globalstore fixtures; stage assertions #22-#24. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
… (1658 -> 1661); footprint on main 363123e Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Nov 22, 2026
…t tail call off the entry depth Themida (plain) computes every stack and VM-context address from the entry stack pointer and other entry registers through mixed boolean-arithmetic identities, with flags words of junk arithmetic mixed in and cancelled again. The linear normal form and the one-variable three-point probe saw none of them, so loads and stores went to unknown locations and the VM exit's return target was lost (4 rows unresolved, 9 rows over budget). - ExprArena::identity_probe decides `e == base + k` or `e == k` by evaluating the DAG at 96 fixed points (splitmix64, fixed seed) assigning every variable and every innermost boolean atom (as a free bit) at once: 20 structured lane-edge points, 76 uniform; exhaustive at <= 8 open bits. affine_probe uses it for several variables and to confirm the one-variable answer when no atom is involved. A per-node cache of 4 quick points (ExprArena::quick_vals) rejects most values with no walk. - Explorer::same_on_stack: two values whose difference is the constant 0 by that test are no difference at a merge. - ExprArena::decide_atoms: a guard, address or computed target has each atom an identity decides replaced (x == y with x - y constant; ordered compares of constants or of one pointer plus constants). - Linear form: zext(b ^ 1) == 1 - zext(b) for a boolean b. - PushanTarget::user_stack_clear_bits: a second identity run with the stack pointer's top bits clear (Windows x86 without IMAGE_FILE_LARGE_ADDRESS_AWARE: bit 31; Windows x64: bits 47-63); used answers are counted and the header says the function "assumes the stack lies where the platform puts a user-mode stack". - Explorer::misplaced_tail_call: a tail call (to a function or through an import slot) is accepted only with the stack pointer at its entry value; otherwise the exit stays unresolved and the header counts it (newstar_backdoor_themida ended at WSAStartup without a warning). Fixture pushan_vm2_x86_64: f_mba (arguments read through an MBA identity over rbp, rdx and rbx; exit behind an opaque predicate on rsp mixed with the result) and f_spbit (an exit on bit 16 of rsp whose other arm jumps to fin with the VM frame pushed). bin-t1-final2 prints garbage loads plus a bogus `fin(...)` path for f_mba with no warning, and accepts f_spbit's arm as a tail call; now `return a0 + a1;` and an incomplete header. Stage kuna-pushan-sound #19-#21 recounted, #24, #25 new; baseline-stages re-recorded (4957). Spec 02 2.11: identity test, platform stack, tail calls. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQR2hseBprKvbvZRUv
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.
What
Lands PR0 of the Listing/xref tier ("scope-B") — the keystone of a post-disassembly subsystem in
kuna-analysis: a program-wide recursive-descent disassembler plus an instruction / cross-reference / discovered-function model, built by reusing the ported SLEIGH decoder and a lifted copy of the S2 flow classifier. This is the foundation the rest of the tier's PRs (the--option listingflag, the engine build wiring, the CodeUnit partition, theFindNoReturnFunctionsAnalyzerconsumer) build on.The design doc
docs/listing-tier-design.mdis the canonical spec for the whole tier (§1 module layout, §2 data model, §3 the recursive-descent algorithm, §4 decoder reuse + the flow classifier, §5 the flag + parity-safety argument, §6 consumer API, §7 the ordered PR breakdown, §8 deferrals). It is transcribed faithfully from the design fan-out.The subsystem (
kuna-analysis/src/listing/)model.rs—Insn(addr/len/fall_through/flow/flows/mnemonic/lazy-pcode),FlowType(the faithfulFlowTypepredicate set) +FlowKind,RawOp,Reference/RefKind(Call/Code populated; Data/Read/Write reserved),DiscoveredFunction(orderedBTreeMapmodel),CodeUnit.decode.rs::decode_one— drivesTranslate::one_instructionwith a capturingPcodeEmitfor(len, ops)andprint_assemblywith a capturingAssemblyEmitfor the mnemonic; builds theAddressin the default code space.classify.rs::classify— a faithful transliteration ofs2_lift/flow.rs::xref_control_flow(flow.rs:1039-1185), honoring the three gotchas: constant-spacein0is p-code-relative (not a VMA), fall-through is the last-op test, delay slots are already folded intolen. BRANCHIND/CALLIND ⇒ computed/indirect with no static target (deferred jump-table resolution).walk.rs— the two-level recursive-descent (function worklist + per-function instruction worklist),BTreeMap-membership dedup, exec-range bounds gate, decode-error = stop-this-path, CALL targets → new function entries +RefKind::Calledges, branch/fall-through → same-function successors +RefKind::Codeedges.mod.rs— theListingfacade +Listing::build(file, image, arch, translate, seeds)and the read-only query API.The
s1_entryseed helpers (executable_sections/existing_function_addrs/in_executable_section) are promoted topub(crate)so PR2 can build the seed set.Scope discipline (PR0 ONLY)
The module is dormant: no
--option listingflag (PR1), noAnalysisCtx::listing/ driver build (PR1-PR2), nocontext.rsARM/MIPS decode-paint (PR5). It touches no engine path the XML datatests use — so the 675/675 + 158/158 oracles are structurally untouched.Demonstration — what
Listing::buildrecovers on the fixtureThe real-decode integration test (
kuna-console/tests/verify_listing_core.rs) bootstraps the vendored x86-64fauxwareELF, obtains a realTranslate(prog.arch().translate()) + code space (prog.arch().manage()), seeds withcollect_entries ∪ {main}, and drivesListing::buildend-to-end:From 2 entry seeds the walk discovered the rest of the call graph (11 functions, 16 call edges) by following CALL targets. The
je@0x4007bb yields two successors +ConditionalBranch; theretis terminal; thecall@0x4007ae files aRefKind::Calledge toauthenticate@0x400664 and seeds it as a function.Tests (both layers REAL, not skipped)
classify.rs) pinclassifyagainst theflow.rsrules: CBRANCH (two successors), unconditional BRANCH (no fall-through), CALL (target + falls through), RETURN (terminal), BRANCHIND (computed, no target), CALLIND (computed, falls through), a constant-space BRANCH in0 (intra-insn, NOT a target), and the last-op fall-through rule.verify_listing_core.rs— the end-to-end drive above. Ran (not skipped) —x86-64.slais built.Gates
make test— 675/675 PARITY OKmake test-stages— 158/158 PARITY OKmake rust-test— green (incl. the 9 classifier tests +verify_listing_core)Deviations from the plan
kuna-console/tests/(akuna-consoleintegration test, exactly as the task suggested) — that is the realistic place to obtain a builtTranslate. It is reached viaprog.arch().translate()(a&Sleigh: Translate) +prog.arch().manage().get_default_code_space(), mirroring theverify_*.rsbootstrap pattern. The keystone'simageparameter is part of the contract but not read by the PR0 decode path (the decode drivestranslate, which reads through the engine loader the bootstrap already attached), so the test threads a throwawayObjectLoadImageover the same bytes.🤖 Generated with Claude Code
https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb