Files
sp00nz e54233e752 tools.split: one byte-exact .s per function, for decompilation
Asked for by someone using the recomp as a function splitter for a decomp,
which the toolkit was already most of the way to without saying so anywhere.
The analysis half -- boundaries, call graph, calling conventions, frame shapes,
recovered names -- is the same whether you go on to recompile or not, and
tools/recomp was simply the only consumer of it.

Each function gets a file: a header with its address range, size, section,
detection method and confidence, its signature from tools.abi_analysis, and its
callers; then the body, with branch targets inside the function labelled and
callees named.

The bytes are `db` and the disassembly is a comment beside them, which is the
opposite of what an N64 decomp does and deliberately so. MIPS round-trips
through an assembler because the encoding is fixed-width and unambiguous. x86
does not -- `mov eax, ecx` has two encodings, immediates have short forms, and
which one MSVC picked cannot be recovered from the mnemonic. Reassembling a
listing gives code that runs identically and does not match, and matching is
the only oracle a decomp has. Emitting the original bytes as data makes the
file byte-exact by construction and still leaves the disassembly to read.

Verified rather than asserted, and the verification found two real bugs:

  - reconstructing bytes from the instruction stream produced files longer than
    the function, because a decoded instruction can start inside a function and
    run past its end wherever data was decoded as code. 102 of 2,254 functions,
    silently. Bytes now come from the image and coverage is exact by
    construction.
  - filling only the trailing gap left three functions short, because MSVC
    parks switch tables in the middle of a function body and the disassembler
    correctly marks those as data. memcpy has two. Gaps are filled wherever
    they occur and come out as labelled data runs in place.

Xbox Dashboard .text: 2,254 of 2,254 functions byte-identical to the shipped
binary.

docs/DECOMP.md is the guide, separate from GETTING_STARTED because it is a
different job with a different endpoint -- and it is honest about what is not
solved: no object-file grouping, code only, inferred boundaries that are wrong
in data-heavy regions, and byte-identical is not build-identical.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013pS5pcx2cx9JXyKurjok17
2026-09-02 23:50:15 -07:00
..