Repository navigation
Listing/xref tier: read API (code-unit / function-model / xref queries) - #26
Merged
Merged
Conversation
Increment 30 — the read/query surface over the PR0-built Listing (design listing-tier-design.md §6 + §7 PR3 + PR4, combined into one increment since both finalize read queries over the already-built model and would self-conflict on listing/mod.rs). Code-unit partition (PR3): code_unit_at (Instruction start-or-interior / Undefined in exec ranges / Data outside), is_data, is_undefined, first_undefined_after, num_instructions. Ordered function model (PR3): function_containing (range(..=vma).next_back()), function_at, next_function_after, function_count. Xref read API (PR4): refs_to / refs_from / ref_source_iter / has_refs_to / ref_count_to over the bidirectional multimap; ordering+dedup locked at build (finalize_refs sorts each bucket and de-dups on (from,to,kind)). Signatures match §6 verbatim so the future discovered-no-return consumer transliterates. Additive read API over a dormant module: no engine path, no flag, no AnalysisCtx change. New verify_listing_queries.rs reuses the PR0 fauxware bootstrap and asserts the partition / ordered-function / xref behaviors; it RUNS (not skipped) against the built x86-64.sla. Gates: make test 675/675 PARITY OK; make test-stages 158/158 PARITY OK; make rust-test green (incl. the new test). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb
# Conflicts: # docs/analysis-port-log.md
mahaloz
added a commit
that referenced
this pull request
Sep 23, 2026
…ending) Union #26 (union_datatype.xml) pins upstream's `res = (int4)ptr->b->bCharField;` and opts out with `option castimplied off`. Ten stage assertions of other options pinned a widening this option leaves out and now match the new form: undefname #4, charbyte #1 #2 #4 #7 #8, PEBNAMES #18, ptrfromuse #10, TIEDPHITRIM #1 #2. docs/baseline.json and docs/baseline-stages.json unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011Q4qgBGM28rgY6CEh5pird
mahaloz
added a commit
that referenced
this pull request
Sep 23, 2026
…ending) Union #26 (union_datatype.xml) pins upstream's `res = (int4)ptr->b->bCharField;` and opts out with `option castimplied off`. Ten stage assertions of other options pinned a widening this option leaves out and now match the new form: undefname #4, charbyte #1 #2 #4 #7 #8, PEBNAMES #18, ptrfromuse #10, TIEDPHITRIM #1 #2. docs/baseline.json and docs/baseline-stages.json unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011Q4qgBGM28rgY6CEh5pird
mahaloz
added a commit
that referenced
this pull request
Sep 23, 2026
…d) (#721) kuna printed a cast where C's own conversion already performs it: a value widened into a type-locked parameter of that type, into a variable declared with it, out through `return`, or under another integer widening. The new option `castimplied` (P9 cast-policy, default on) leaves such a cast out at print time; the IR and CastStrategyC are unchanged. Only a value-preserving integer conversion goes, judged on the operand's printed C type; truncations, sign changes, float/pointer/bool/enum conversions, varargs slots and truncarg/boolbyte casts always stay. Rust output is unaffected. On the landing base: casts on the 4,815 functions kuna and IDA both emit go 45,039 -> 43,673 (1.191x -> 1.155x IDA), 570 functions fewer, 0 more; every changed line in the 45-binary corpus is the old line with integer casts deleted (3,360 casts). The 444-slice typesweep stays at 1,615 perfect with variables[] identical in all 10,748 functions. A gcc/clang round-trip test compiles the printed C with the option off and on and requires the binary's output. Union #26 (upstream datatest) opts out; ten stage assertions of other options now match the new form. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011Q4qgBGM28rgY6CEh5pird
mahaloz
added a commit
to borancar/kuna
that referenced
this pull request
Nov 14, 2026
…t, a wide reload or ECX, and from reusing walks across the option Three lost-read shapes the stack-address tracking still missed each dropped a real argument: a local's address stored over the callee's own argument slot and loaded back, a slot holding one copied by an 8-byte move, and a stack address a nested call leaves in ECX. A store of a stack address to a stack location whose slot is not followed now leaves the extent unstated, a load is lost when it overlaps any followed slot, and every caller-saved register a returning callee leaves a stack address in is lost. The walk summaries are cached on the architecture, and the tracking only runs with calleeargs on, so turning the option on in a session that had walked a callee with it off reused the untracked walk and dropped the arguments again. The cache now drops its walks when the option changes. Stage cases CALLEEARGS Noelo-Lab#26-Noelo-Lab#29 (calleelost_pe_i386 extended, recipe in its header) fail on the previous head and pass now; the 62-binary i386 corpus is byte-identical to the previous head. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz
added a commit
to borancar/kuna
that referenced
this pull request
Nov 14, 2026
…ious call The vtable's object was followed back through copies past intervening calls, so `mov esi,ecx; call f; mov eax,[esi]; push esi; call [eax+k]` (COM calls through ESI, and a C table through ESI) took ECX as the receiver although the earlier call clobbered it; the COM push check also compared two scans of different reach and missed the pushed interface. The object, the last push and EAX are now compared as values over the run of ops since the previous call, carried forward through copies. The vcall fixture gains comesi and crosscall (stage Noelo-Lab#26, Noelo-Lab#27, the custom test). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz
added a commit
that referenced
this pull request
Nov 22, 2026
libpng's png_decompress_chunk (Ultra, plain VMProtect and Themida builds) lost `if (*a3 != size) ret = -7` and `if (ret == 1 && a1 - a2 != avail) png_chunk_benign_error(...)` after the second png_inflate call, with no warning. png_inflate gets &avail and the pointer parameter a3 in its 5th and 7th arguments, which Windows x86-64 passes on the stack. Exploration: the call summary looked at no stack-passed argument on x86-64 (eight words on x86) and made only the 16 bytes behind each pointer argument unknown, so both reads after the call folded to the values before it and the paths to -7 and to png_chunk_benign_error were pruned (the overlay had 23 CBRANCH and no call to it). Now the argument registers and the 16 words of the outgoing argument area (past the home space on Win64) are the pointers; every frame offset among them escapes, and a round that escapes a new one is followed by another. State::clobber_call leaves the call's output in all mutable image memory, in every region under a symbolic base but the entry stack pointer, and in the frame from the lowest escaped local up to the return address (and from the lowest escaped incoming argument up), the same bytes the emitter keeps alive across a call. CallOutputAt carries the base. Decompiler: with the paths back (25 CBRANCH, the call present), the benign-error test still folded. The store that passed &avail has no reader in the body and is gone before the stack alias mapping, which then marked avail `nolocalalias`, and RuleIndirectCollapse removed the call's INDIRECT on it. The exploration's escaped offsets are now kept on the Funcdata (kuna_call_escapes), and syncVarnodesWithSymbols never gives a slot from the lowest escaped local up to the return address `nolocalalias` (kuna_pushan::frame_escaped). Fixture: pushan_vm2_x86_64 gets ext7 (writes through its stack-passed 7th argument and 32 bytes past its pointer argument) and f_out; stage kuna-pushan-sound #26/#27 pin both tests (before: `ext7(); return 3;`). Stage baseline 5035 -> 5037. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Nov 22, 2026
[AUTOMATED] Re-recorded after adding PUSHAN-SOUND #26 and #27 and merging main. Co-Authored-By: Claude Fable 5.2 <[email protected]>
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.
Increment 30 — the read/query surface over the PR0-built
Listing(
docs/listing-tier-design.md§6 consumer API + §7 PR3 and PR4, combinedinto one increment because both finalize read queries over the already-built model
and would self-conflict on
listing/mod.rs).Purely additive read API over a dormant module: no engine path touched, still
no
--optionflag (PR1) and no engine invocation (PR2). The PR0 walk already fillsthe
insns/refs_to/refs_from/funcsmaps +covered/exec_ranges;this PR locks the public read API + ordering/dedup on top. Signatures match §6
verbatim so the future discovered-no-return consumer transliterates cleanly.
Query surface added (on
Listing)Code-unit partition (PR3) — the partition the walk leaves behind
(
partition_code_units):code_unit_at(vma) -> CodeUnit— start-or-interior of a decoded insn ⇒Instruction(start)(ordered interior lookupinsns.range(..=vma).next_back()+an
[addr, addr+len)span test); any other exec-range VMA ⇒Undefined;outside the exec ranges ⇒
Data(the conservative split; the keystone has noper-byte symbol-typed-data model).
is_data,is_undefined,num_instructions,first_undefined_after(vma)(theAIF gap walk — forward scan skipping each instruction's byte span).
Ordered function model (PR3):
function_containing(vma)—funcs.range(..=vma).next_back()(nearest precedingentry; the faithful analog of Ghidra's ordered FunctionManager).
function_at,next_function_after(vma)(range(vma+1..).next()),function_count.Xref read API (PR4) over the bidirectional multimap:
refs_to,refs_from,ref_source_iter()(distinct reference sources,ascending — the call-site worklist),
has_refs_to,ref_count_to.finalize_refs): each bucket is sorted(
refs_toby source VMA then kind,refs_fromby target VMA then kind) andde-duplicated on
(from, to, kind), so a target referenced twice from one sitecontributes one edge and
ref_count_toequals the number of distinct sites.exec_rangesis sorted at build for the partition/gap scan.Sample query results on the fixture (
fauxware, x86-64)The new
verify_listing_queries.rsreuses the PR0 bootstrap, seedscollect_entries ∪ {main, __libc_csu_init}, builds theListing, and recovers185 instructions / 16 functions / 169 ref sources:
Testcase
decompiler/crates/kuna-console/tests/verify_listing_queries.rs(sibling of thePR0
verify_listing_core.rs) asserts §7 PR3 + PR4: the partition (instructionstart + interior byte ⇒
Instruction; non-exec ⇒Data;first_undefined_afterlands on a genuine Undefined byte), the ordered function model
(
function_containing(0x40073e)=main,next_function_after(main)=0x4007e0,function_count==functions().count()), and the xref API(
refs_to(authenticate)=[0x4007ae Call],ref_source_iterincludes & is ascending,ref_count_to=1,refs_fromcarries the outgoing Call, terminalretfiles none).The test RAN (not skipped) against the built
x86-64.sla.Gates
make test— 675/675 PARITY OKmake test-stages— 158/158 PARITY OKmake rust-test— green (incl.verify_listing_queries+verify_listing_core)🤖 Generated with Claude Code
https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb