Repository navigation
[AUTOMATED] Name a jump thunk after its target (option thunknames, default on) - #1879
Merged
Merged
Conversation
…default on) A function that loads a memory cell, returns it when set, and otherwise computes the value, stores it into the cell and returns it was recovered void: at the RETURN the return register is the cell's load on one path and the stored value on the other, and ancestorOpUse refuses both because the load is also branched on and the stored value is also stored. Swift's lazy witness-table accessors, metadata caches and __swift_instantiateConcreteTypeFromMangledName are this shape, and their callers read a result the function did not have. ActionReturnRecovery now takes the trial when every value reaching each live RETURN is a LOAD of one cell or a value a STORE writes into it (same space, same pointer), at least one of each. Stage test kuna-cachereturn.xml.
…fault on) A function whose first instruction is a direct unconditional branch is a jump thunk (a linker branch island, an ICF forwarder, an outlined tail call; one `b <target>` on arm64). Nothing named it, so it stayed `sub_<addr>` and every call through it was anonymous although its target is named. While committing the discovered entries, the engine now decodes each entry's first instruction, and after every other name source renames a placeholder thunk `j_<target>` when the target has a real name; a thunk to a thunk becomes `j_j_<target>`. Under lazyfuncs only thunks whose chain ends at a named entry are made functions eagerly. Stage test kuna-thunknames.xml with the fixture thunknames_aarch64.
A call through a renamed thunk printed the target's name but was typed as a call to an unknown function. After every prototype stream has run, each renamed thunk now takes its chain's target's parked prototype and bound prototype model (where it has none of its own) and its Swift `self` classification, so the call is typed as a call to the target. A thunk with a name of its own keeps its own prototype recovery. The fixture is now built from C with DWARF so the stage test can see the prototype carried into the callers.
…esult and a non-stack cell
As submitted the rule also turned void functions into returning ones:
- gcc AArch64, clang ARM32 and gcc MIPS compile `void init(void) { if (!g) g = make(); }`
to the accessor's exact bytes; in gcc -O2 AArch64 bash and coreutils 10 of the 11
functions it changed are void (initialize_aliases, phash_create, add_temp_dir, ...).
- A value updated in place (`x = *p; if (x) *p = x - n;`) left the cell's value in the
return register of void functions (sqlite selectRefLeave, an ARM firmware routine).
- Go's morestack path spills x0 to [sp+8] and reloads it, so 37 Go runtime functions
on arm64 changed signature, most of them void ones now returning their first argument.
The rule now needs the image's source language to be Swift (the sourcelang fact),
takes a stored value only when it is a call's result (the CALL's output or the
INDIRECT a call creates), and refuses a cell whose pointer is computed from the
stack pointer. Swift lazy witness-table accessors on arm64 Mach-O are unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKNhsvezm24JAGcKtoV
…on a C image The phases.toml row, the spec section and the stage test now say the rule acts on Swift images only and why (gcc AArch64 compiles a void initializer to an accessor's bytes). The stage test forces `option sourcelang swift` for its off/default passes and adds a `sourcelang c` pass where every function stays void. Stage baseline: the five CACHERETURN keys renamed, count unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKNhsvezm24JAGcKtoV
…h alone A delay slot is decoded as part of its branch, so MIPS `j release_box` with `addiu $a0,$a0,16` in its slot (a `this` adjustor) classified as an unconditional branch and was renamed `j_release_box_1` and given release_box's prototype. A thunk now needs the decoded instruction's p-code to be the single BRANCH; `j f; nop` still qualifies. inherit_prototypes also returns before cloning the prototype-model map when nothing was renamed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKNhsvezm24JAGcKtoV
New fixture thunknames_mips (1 KB, source and recipe beside it): two symbol-less `j release_box` entries, one with a nop in its delay slot and one with `addiu $a0,$a0,16`. Stage passes 3-4 assert the first is renamed and the second keeps sub_4000e8 with the option on (THUNKNAMES #7, #8; #8 fails before the fix). The phases.toml row and the spec say a thunk's branch does nothing else. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKNhsvezm24JAGcKtoV
Contributor
|
[AUTOMATED] Pushed b3c6268 and 0b17d4b on top of your head. A MIPS |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKNhsvezm24JAGcKtoV
cachereturn joins switchmerge from main: 234 settables, tiers 50/125/59, 87 live fields, 233 catalog records, KUNA-CATALOG Noelo-Lab#15 242. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKNhsvezm24JAGcKtoV
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKNhsvezm24JAGcKtoV
thunknames joins cachereturn and switchmerge from main: 235 settables, tiers 50/125/60, 234 catalog records, KUNA-CATALOG Noelo-Lab#15 243 (thunknames has no live field: 87 unchanged). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKNhsvezm24JAGcKtoV
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKNhsvezm24JAGcKtoV
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] A function whose whole body is one
b <target>(a linker branch island, an identical-code-folding forwarder, an outlined tail call) keeps the placeholder namesub_<addr>, so every call through it is anonymous although its target is named. arm64 Swift images have hundreds of these.Fix (
option thunknames, default on, any architecture)sub_<addr>becomesj_<target>when the target's function has a real name; a thunk to a thunk becomesj_j_<target>(at most four hops). A taken name gets the first free_<n>suffix.selfclassification (where it has none of its own), so calls through it print the target's argument and return types. A thunk with a name of its own keeps its own prototype recovery.lazyfuncs, only thunks whose chain ends at a named entry are made functions eagerly, so the lazy inventory stays lazy.adrp; ldr; br, arm64ebraa) are left to the stub passes.After:
j_release_box();andj_j_release_box();; with a DWARF prototype onrelease_box, a caller passing its argument through now printslong drop_box(long *a0)instead of(unsigned long a0). On the Perplexity iOS 26.46.0 main binary 618 functions are renamed (e.g.j_swift_release_x1,j_Foundation.UUID.init()), reached by 1,211blsites in 935 functions, and 179 of them take a prototype or prototype model from their target; 160 more across the frameworks.decompile-allon DeviceKit: 2.60 s on vs 2.45 s off (noise).Tests: stage test
tests/stages/kuna-thunknames.xmlwith fixturethunknames_aarch64(source beside it) asserts thesub_calls and untyped callers with the option off, andj_release_box(/j_j_release_box(and thelong *parameter with it on; the "on" assertions fail without the change. Datatests 675/675 and the stage baseline unchanged apart from the four new keys.Model:
anthropic/claude-opus-5-5:high