cpu: bind call targets without unwind data through an opt-in range manifest #424
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/430"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by grahamster2 on 2026-11-22T01:45:36Z.
Stacked on #425 and #420; review only commit
4b2e125(the merges of #425, #420 and main on top of it change no code of this PR;01fb256brings in #425's843154fand #420's head5ec180f).Refs #317 (step 2, follow-up). Narrowed, as requested in the review, from heuristic acceptance to opt-in bindings. #425's entry boundary stays the default.
Change
Default. A direct call or tail-jump target with no unwind entry and no export is still refused. The message now gives the target RVA and the binding it needs:
Tail jumps that used to stop at
edge outside owned rangesfor such a target now get the same message.Opt-in binding. The invoker passes
cpu_switch_aot.py --bind-ranges MANIFEST, orRANGES <file>in the CMake functioncpu_translation. The manifest is JSON:tools/range_manifest.py IMAGE MAP OUT NAME...writes it from the source labels an MSVC/MAPfile lists: the function's symbol forstart, itsNAME_endlabel forend, and the image's SHA-256. PDB function symbols would be another source; they are not read yet.The translator checks the manifest before translating anything:
.pdatainterval.Then, for each call or tail jump:
[start, end)only. An edge that leaves it is refused, and the message names what the edge reaches: another function's unwind interval, another bound range, or unbound code. Code outside the range is never decoded as part of the callee.Verification
Environment: Windows 11 Pro build 26200, VS Build Tools 2026 18.3 / MSVC 19.50.35725, ML64, Windows SDK 10.0.26100, Python 3.12.
ctest --preset dev --no-tests=error -R '^cpu_aot_bound_callees$' -V: passed. Everything below uses the same source-built DLL,tests/cpu/bare_calls.asmlinked with/MAP. Its two leaves are declared withoutFRAME, so they have no.pdataentry, and neither is exported.Refused by default: without a manifest,
call_bare's call andtail_bare's tail jump are refused, each with its target RVA and the binding message.Matches native with the binding: the build writes the manifest from the map and translates with it. 3 exports x 545 inputs = 1,635 calls per side. The original and the translation match a Python reference on the defined return bytes, guarded trace, RBX and RSI. Each bound callee is emitted once, and
tail_barereports width 1.Interior label:
bare_mix_inneris aligned, andMOV,SUBandRETfrom it translate. Bound as its own range, a call to it translates. Withbare_mix's range bound, the same call is refused. So the refusal comes from the binding rule alone.16 controls, each refused with its stated reason:
TimeDateStamp(another build)range binding is for another imageinside the bound range bare_mix [0x1000, 0x100b), not its startinside the bound range bare_mixjump target ... inside the bound range bare_low.rdata... is not inside executable code.text... is not inside executable codeoverlaps the runtime function at 0x1016range binding bare_low ... overlaps range binding bare_mixRETedge outside owned ranges at RVA 0x100a: outside the bound range bare_mixanother function's unwind intervaljump target 0x1004 ... inside the bound range bare_mixjump target 0x1010 ... a range binding ... is neededJMP [RIP+slot]thunkbound function fake_thunk ... is an import thunkcall in a function without unwind dataPUSH/POPstack change in a function without unwind dataself-recursionEvery control except the first rehashes the manifest for the patched copy, so only the intended check can fail.
Mutation checks, each planted and restored:
unsupported control flow); the test fails on the messageThe generated C++ for every earlier fixture of this translator is byte-identical to #425's head (
843154f). That covers the jump-table,addr32, entry-order, narrow and fourth-argument fixtures, #420'scpu_frame,cpu_callsandcpu_call_entries.cpu_bare_callsis byte-identical to this PR's previous head (5f7a0e0).Full Debug suite, run serially:
ctest --preset dev --no-tests=error -E '^(conditional_import_paths|static_exe_intake|bundled_export_forwarders)$'. At01fb256: 154 passed, 3 capability skips (bvh_wave64_hardware,bvh_wave64_warp,wave_shuffle_warp). I did not run the three intake tests.docs_links,tests/bidi_controls_check.pyandtests/form_coverage_check.pypassed.Corpus, against #425's translator: a Release (
/O2) build of this branch, covering every.pdataentry of 97 readable non-generated images, with each unique function body translated with four arguments and no manifest.Evidence and follow-up
tests/cpu/bare_calls.asm,bare_calls.def,bare_calls_check.pyandtools/range_manifest.pyare original sources written for this PR (MIT). The DLL, its map and its manifest are produced in the build, and no binaries are added.bare_callsis classified intools/form_coverage.py. Docs: the jump-table section ofdocs/experiments.mdand the README CPU row.For review:
[start, end)RVAs. The fixture's evidence is the linker map's source labels, a publicNAMEandNAME_endper function. A PDB reader could produce the same file later.Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T01:57:00Z.
Please narrow the top commit to opt-in bindings, or leave #425’s boundary in place. A direct call/jump can land on an aligned interior label that decodes cleanly, never adjusts RSP and runs to RET. Even together with a missing
.pdataentry, those observations do not establish a distinct function. Unbound corpus hits can be counted as candidates only.For an opt-in path, the caller supplies trusted start and end evidence for this exact image. A source-label
[start,end)manifest bound to the image hash is sufficient; a matching link-time PDB function symbol and length is another source. PDB parsing can wait. Verify image identity, executable bounds, overlaps and all reachable edges. Reject instruction-interior targets and entry into or traversal across another known function or an unauthorized range. Keep the existing leaf, stack, import-thunk and recursion checks. When evidence is missing, report the target RVA and which binding is needed.On the same source-built DLL, show that an actual no-unwind leaf is refused by default and matches native execution with the right binding. Include an aligned interior label with a valid path to RET that still gets refused, plus wrong-build and out-of-range bindings. Please rebase after #425; #420 and #425 can proceed independently of this change.
Imported from R0Y00/Xbox2Windows. Originally posted by grahamster2 on 2026-11-22T02:16:09Z.
Narrowed to opt-in bindings, as you asked, and rebased onto #425's updated head (
165a66f). #425's boundary remains the default: an unbound target with no unwind entry is refused, and the message gives the target RVA and says a range binding is needed.--bind-rangestakes a[start, end)manifest bound to the image's SHA-256, which the fixture's build writes from source labels in the linker map. The translator checks the hash, executable bounds, overlaps with other bindings and with.pdata, entry only at the start of a range, and every edge of the callee staying inside its range. The leaf, stack, thunk and recursion checks are unchanged. On the same DLL, the no-unwind leaf is refused by default and matches native with the binding (1,635 calls). An aligned interior label that translates when bound on its own is refused, and so are a wrong-build and out-of-range bindings. With overlap and traversal controls, that makes 16 controls; 4 of the 8 mutations get their control accepted, and the other 4 make it fail on the expected message. The corpus is unchanged without a manifest (97 of 2,346), and unbound hits are reported only as candidates: 872 functions, 421 targets.