Repository navigation
[AUTOMATED] dyld cache: load several images as one program and follow a callee into its image - #1685
Merged
Merged
Conversation
…nstruction `--assert 'callproto [<func>::]<callsite> <C declaration>'` states the arguments and return of the call made by one instruction. A call through a pointer or a register has no callee symbol to carry a signature, and a variadic callback takes different arguments at each call, so `prototype` and `data` cannot say it. The directive goes through the per-call-site prototype override the engine already has (the console's `override prototype`), on both the script surface and the in-process one. A parameter may be followed by `@<storage>` to be read from that storage rather than the place the calling convention gives it, and a `@<storage>` after the parameter list places the return. `override prototype` takes the same declaration, and no longer needs the trailing `;`. An address at which the function makes no call is rejected with `No call is made at this address`. Fixes Noelo-Lab#1643
…ta through the cache In an image loaded from a dyld shared cache the objc pass recovered nothing: methods kept only the names the .symbols file has, self and _cmd were untyped, and every objc_msgSend$<sel> stub stayed sub_<addr>. - kuna_dyldcache: objc_selector_base() from the header's ObjCOptimizationHeader, else libobjc's objc_opt_t (__objc_opt_ro, version 16 on). - analyzers/objc/kuna_objccache.rs: the pass reads addresses outside the image's own sections through the cache, a slid page at a time, each read charged to the walk budget. - methods.rs: direct selectors (0x40000000) and type strings relative to the selector base (0x20000000). The entry size is entsizeAndFlags & 0xfffc: the two low bits are the uniqued and sorted flags a cache carries on disk. - classt.rs: baseMethods with its low bit set is a relative list of lists. A preattached category method whose IMP is in another image is named there as an import. - A symbol at the IMP spelling the same class and selector under another category name is kept as the label, so the prototype reaches a function the symbol table already named (the linker merges categories). Foundation out of an iOS 16.4 arm64e cache: 3,979 objc_msgSend$<sel> stubs named (0 before); every selector, class, super and protocol reference slot named; self and _cmd typed. No option: it rides objc and is inert off a cache image. make test and make test-stages move no existing expectation. Stage test kuna-dyldcacheobjc.xml on two synthetic caches built by dyld_cache_objc.py (header selector base; objc_opt_t only). Fixes Noelo-Lab#1623
…dimage A+B, --follow-images) A callee in another image of a dyld shared cache could not be decompiled in the same run as its caller: its address was "not mapped", and `--image` took one name. `dyldimage` (and `--image`) now takes several names joined by `+`. Each image is rebuilt as before and the results are joined into one thin Mach-O with a header page of its own: every segment at its cache address, one symbol table with section ordinals renumbered, one indirect-symbol table, one function-starts table and one cross-image reference note. One name is rebuilt exactly as before. `decompile`, `disassemble` and `xrefs` look each 0x address of the request up in the cache's image ranges and add the image that holds it, bounded by the global `--follow-images N` (default 2, 0 turns it off). `decompile` and `disassemble` first follow a stub island to the function it jumps to. The ObjC, CFString and Swift passes read every section of a name instead of the first, and function starts count from the first __TEXT command, so each image of a joined Mach-O keeps its metadata. Fixes Noelo-Lab#1622
The header-room reason and the same-text claim were worded as general facts. They rest on one measured pair (Foundation and CoreFoundation, iOS 16.4.1) and a sample of 24 functions, in which one local was also renamed by a name collision. Say so in the spec and the module header. Fixes Noelo-Lab#1622
…the collections it links A macOS Auxiliary or System kernel collection points into the boot collection (and an Auxiliary one into the System collection) with kernel-cache chained fixups that are offsets from the other file's base. Those slots kept their packed chain words, so a kext's calls into the kernel printed as indirect calls through a data word. The new load-time option kernelcache-boot (auto|off|<path>, default auto) finds the collection whose LC_UUID or _PrelinkKCID is the UUID the input's __PRELINK_INFO names (_BootKCID, _PageableKCID), beside the input or at the given path, rebases the level-0 and level-1 slots against its base and names the functions they reach from its symbol tables. A symbol-pointer or __auth_ptr slot of a collection kext that holds a bound import's address is that import's slot. When no file matches, the load note counts the unresolved slots and names the missing UUID. Fixes Noelo-Lab#1624
… one, refuse a named convention - calltargettype skipped every call with a locked prototype, so stating the prototype a call already had turned `(*(int (*)(int,int))cb)(a,b)` into the uncompilable `(*(void *)cb)(a,b)`. A prototype stated at the call itself (`override prototype` / `callproto`, not a format string's) is now typed from its arguments like an unlocked call, with the stated parameters' storage standing in for the recovered storage it does not have. - Two callproto directives for one call both reported `applied` while only the later took effect; the earlier is now rejected on both surfaces. - The override is built under the default model, so a declaration naming another calling convention is rejected by name instead of a syntax error. - The fixture recipe gains -fcf-protection=full (the committed binary has endbr64); docs example now carries the `data` assertion its output needs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…ed prototype Building the type from the arguments' recovered types spelled a stated `long f(long, long)` as `unsigned long (*)(unsigned long,unsigned long)` and a string-literal parameter as `void *`. A call whose prototype was stated at the call now takes its return and parameter types from that declaration. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…ffset objc_opt_t.relativeMethodSelectorBaseAddressOffset is an int64_t from the record (dyld objc-shared-cache.h, relativeMethodListsBaseAddress()), so a selector base below libobjc's __objc_opt_ro is a negative offset; the unsigned add overflowed and lost the base. The fixture test now also checks the header path and the objc_opt_t path each on their own (the fallback hid a broken header read). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Resolves the stage corpus count (783 + kuna-dyldcacheobjc = 784) and re-synthesizes docs/baseline-stages.json (main's 4,524 + this PR's 7). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…part of that name dyldimage A+B split the value at every +, so --image libc++.1.dylib, libc++abi.dylib or libstdc++.6.dylib (which load on main) failed with "no image named \".1.dylib\"". select_all now takes, from each piece, the longest run of +-joined pieces that names an image; a run ends only at the end of the value or before a non-empty piece, so libc++ is never read as libc. A value without + resolves exactly as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
A call-site prototype is laid out under the default model, and a declaration naming any other convention is rejected. The check compared names only, so on x86-64 Windows `__cdecl` and `__stdcall`, which the compiler spec declares as aliases of the default `__fastcall` (`<modelalias>`), were rejected with a message saying they are not the default. A named model is now accepted when it is the default or an alias of it with the same `this` handling (`ProtoModel::is_compatible`). The CLI test helper passed `--assert-strict` as a directive, so the strict-exit check passed on a usage error; it is now a flag, and the check pins exit code 1. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
A prototype stated at an indirect call types the call's target so the call stays one C can make, but a variadic statement was still skipped, so `callproto <site> void f(char *, ...)` printed the call through `(void *)`, which no C compiler accepts, where the unstated call had been compilable. A stated variadic prototype now types the target with its fixed parameters and `...` when the call passes at least those, laid out in the storage the stated parameters were given. Calls without a stated prototype take exactly the path they took before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Count-only conflicts: the stage corpus count in xml.rs (main 783 + this branch's kuna-callproto = 784) and docs/baseline-stages.json, synthesized from both sides (main 4524 + 4 = 4528). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Resolves the stage corpus count in kuna-base/src/xml.rs (both comment lines kept) and docs/baseline-stages.json (synthesized from both sides). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…input, and say which file text decompile used A linked collection named by path is read only if it is a regular file, so a FIFO no longer blocks the load and a device such as /dev/zero is not read until memory runs out. The input itself is never a candidate: it was read whole a second time on every load, and an input naming its own UUID was taken as its own boot collection. Text `kuna decompile` now forwards the engine's MH_FILESET load note, as `functions` and `decompile --json` already print it, so the file that resolved the pointers is visible. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
The first 4096 directory entries are taken in listing order and then tried in name order; only regular files other than the input are candidates. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Contributor
|
[AUTOMATED] Pushed two commits on top of this branch:
|
Resolves the stage corpus count (kuna-base/src/xml.rs), the tier counts in kuna_phases/tests.rs, docs/baseline-stages.json (synthesized from both sides) and docs/cli.md (the kernelcache-boot subsection stays under the kernelcache section, before main's new `--member` section). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Both sides added one option, so the settable, catalog-record and KUNA-CATALOG Noelo-Lab#15 counts each move by two from the merge base. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Resolves kuna-cli/src/main.rs against the ar-member loader (Noelo-Lab#1675): --follow-images is taken before armember::resolve, and the image selection is exported and widened after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Main gained callee (Noelo-Lab#1676) and format/isolate (Noelo-Lab#1679) beside callproto in the same assertion files: every directive list, Body variant and match arm keeps both sides, assertions.rs keeps record_rejected_callee_overrides and record_unbound_call_prototypes whole, project.rs calls both, and assertion_outcomes runs both restatement passes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
coleleavitt
added a commit
to coleleavitt/kuna
that referenced
this pull request
Nov 22, 2026
[AUTOMATED] Resync of the combined branch with Noelo-Lab/kuna main. Superseded by upstream (fork copy dropped, upstream's version kept): - gortti -> upstream gotypes (itabs + typeglobals); the fork's Go fieldtypes/structorder/itabs copies and the go_rtti stream removed. - tailcontract -> upstream protoorder bootstrap. - unmergecall -> upstream `returndup calls`. - treeswitch/linearswitch -> upstream `loweredswitch tree|linear`. - whilecontinue -> upstream continue_points. - compacttable -> upstream AArch64 compact-table fold in kuna_switchtable. - repstring: upstream's version (Noelo-Lab#1650, adds repz cmpsb); fork copyrun kept. - dyld cache: upstream Noelo-Lab#1684/Noelo-Lab#1685 (select_all/extract_merged, ObjC methods/stubs, hardening); fork-only 32-bit caches, slide v4 and the exporttrie cross-image names ported onto it. - kernelcache linked collections, Mach-O data slots, panicloc, calltable, gotonext, postinc, typevote, condexe/extrapop/kernelcache stage tests: upstream's versions. - kuna_gomoduledata: upstream's module (pclntab extent); the fork's full-record locator renamed kuna_gomodlayout. Fork-only tracks kept and adapted to upstream's API (engine commit, architecture fields, option dispatch, passes, xrefs storage, userop ids renumbered after upstream's new builtins, chained-fixup linked targets). switchtrim now runs after switchextent. codestrings also keeps a string after an x86 call-over-data (callpopret CLI test). Stage/CLI/web tests from upstream that a fork default-on option changes pin that option off (calleeretpurge, gotosink, looprotate, rangefold, bitidioms, fdeflowbound, formatcallees, globalwidth, dwarfscopes). copyrun's i386 case gets its own fixture (copyrun_i386); repstring's i386 fixture is upstream's. Generated files regenerated, not hand-merged: docs/options.md, catalog counts (308 settables), phase_catalog.json, list_action snapshot, corpus count (941). docs/baseline-stages.json re-recorded at the merge (sanctioned re-pin for an upstream sync, 5403/5403); docs/baseline.json is upstream's (675/675).
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.
[AUTOMATED]
kuna loads one image of a dyld shared cache per run, so a callee in another image cannot be decompiled next to its caller: its address is "not mapped", and
--imagetakes one name.On the committed two-image cache,
libcallercallscallee_add(0x180002800, inlibcallee) through the stub island at 0x180008800:After, the first command prints (and
0x180008800, the island, gives the same function):On the iOS 16.4 arm64e cache,
--image Foundation+CoreFoundationlists 61,908 functions, exactly the 50,742 and 11,166 the two images list alone, and__NSLogvand__CFLogvEx3decompile in one run.The change
dyldimage(and--image) takes several names joined by+. Each image is rebuilt as before and the results are joined into one thin Mach-O: every segment at its cache address, one symbol table with section ordinals renumbered, one indirect-symbol table, one function-starts table, one cross-image reference note. One name is rebuilt exactly as before.decompile,disassembleandxrefslook each0xaddress of the request up in the cache's image ranges and add the image that holds it, bounded by a global--follow-images N(default 2, 0 = off).decompileanddisassemblefirst follow a stub island to the function it jumps to;xrefsdoes not, since the island is what call sites reference.CFSTR(...)literals and class references.dyldimageplus one CLI flag. Limits: the joined images may hold 255 sections together (a Mach-O symbol names its section in one byte), and a call through a stub island still renders as a named import, soxrefs --tothe callee's own address lists direct calls only.Tests
tests/stages/kuna-dyldimage-merge.xml:libcaller+libcalleedecompilescallee_addin the same script as its caller.kuna-clidyld_follow_images:A+B, an address in another image, a stub island, and--follow-images 0(which keeps today's error). The first three fail without the change.kuna_dyldcacheunit tests: symbol sections, stub imports and function starts of a joined image, the 255-section refusal, andfollow_imageswith and without stubs.decompile <cache> __NSLogv --image Foundationtakes 1.17 s before and 1.09 s after (best of 30), with identical output and a byte-identicalunpack. Joined output was compared with single-image output on 24 sampled functions; it differs only where a reference into the other image now resolves, and in one local renamed by a name collision.Fixes #1622