Files
andeecollard 26de405194 fix(disasm): the returning-body probe follows a switch through a measured table
probes_as_returning_body ended at any unconditional jmp that was not an
immediate forward branch, so a `jmp [reg*4 + table]` switch dispatch looked
like a tail call. The imm-ref pass relies on that probe, which left one shape
of function undiscoverable: reached only as an immediate (`mov eax, offset
fn`), no prologue, packed straight after the previous function's ret, and
opening with the dispatch. The cc-boundary pass needs int3 padding and the
gap-prologue pass needs a prologue, so nothing found it.

The cost is larger than one missing function. The switch it owns is
translated nowhere, and the gap-prologue pass then starts "functions" at its
later arms (`mov eax, 1 ; ret` probes as a constant stub) and at the npad in
front of the table, which decodes the table as code. A recompiled title
calls garbage from those and carries their bytes as untranslated
instructions.

resync_jump_tables has already measured the table by the time the imm-ref
pass asks, so the probe now continues at the first arm past the dispatch,
keeping its instruction budget. A dispatch through a table the engine has not
measured is still tail-call shaped: nothing says where its arms are.

test_returning_body_switch.py pins the probe on both sides and runs
detect_all over a caller plus such a function. Against the old probe the
end-to-end test finds three false functions (two arms and the table) and not
the real one; with the fix it finds the function and none of its arms.
Found on a retail title, where two such functions owned 21 switch tables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017QvivF8psGzR3Ws8tv21Ut
2026-09-26 09:45:45 +01:00
..