Files
xboxrecomp/docs/technical/function-coalescence.md
BearddOddity 309bfbedfc docs: list every RECOMP_* switch in one page, and link it from the index
docs/INDEX.md stays the one index. Every page gets one navigation line under
its title that points back to it, and runtime/ gets a reference page for the
environment variables.

docs/runtime/environment-variables.md lists every RECOMP_* switch the runtime
and tools read: its default, its effect and the source file that reads it,
grouped as bring-up, kernel, pushbuffer executor, video, audio and input.
Fifty-one of them were not in the docs at all. docs/INDEX.md links it from
"Start Here".

No page is renamed, moved or rewritten, and no other index is added.

Checked: every RECOMP_* name read by getenv, env_on, apu_env_on, env_int or
xa2_env_int in src/, tools/, templates/ and include/ is on the page, and
every name on the page is in the source. All relative links in docs/ resolve
(0 broken, as at v0.16.0). The 34 existing pages change by insertion only:
68 lines added, none removed. docs/INDEX.md gains one line.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 04:59:55 -05:00

2.7 KiB

Recovering a function split into false entries

Part of the Documentation Index

The detector can split one function at an interior branch target. Translating the pieces separately can lose a comparison before a conditional branch or turn a local loop into recursive host calls. When independent analysis has established the original owner, use --coalesce-functions before regenerating:

python -m tools.recomp game.xbe --all --coalesce-functions bounds.json

The file is a JSON array. This example describes synthetic code from the test:

[
  {
    "start": "0x00010000",
    "end": "0x0001001b",
    "coalesce_starts": ["0x0001000d", "0x00010014", "0x00010018"]
  }
]

end is exclusive. coalesce_starts must list every current detected entry strictly inside the owner, sorted without duplicates. The flag is repeatable; files and entries apply in order to the updated function database. Keep actual title-specific bounds beside that title's private analysis, outside this repo.

Recovery runs after static callback discovery and before runtime helper detection, automatic CFG ownership and translation. It removes the named fragments and emits the complete owner. Without the option, translation is unchanged. Callback discovery repeats after each repair. Newly visible callbacks protect existing entries; a callback into an already coalesced interior aborts the batch.

The operation rejects conflicting extents, independent entry evidence (prologue, callers, external_entry, or detector-recorded entries, seeds and code pointers), manual/wrapped/referenced project entries, calls to an interior entry from the owner, and code that does not cover the requested extent. Traps (int3, ud2, hlt) terminate the validation walk and the recovered generated path; later blocks need another incoming edge. The Xbox debug-service sequence int 0x2d; int3 is the exception: the kernel skips that int3, so recovery preserves its fallthrough. Only proven alignment no-ops, an exact validated jump-table byte range, or those two combined around the same gap may close a decode gap. Register-jump continuations are accepted only when the jumped register can be tracked from an in-range immediate load, including simple register copies. A local jump table using a sole base or index register can be read beyond the owned end, bounded by the next detected function, if any, and the backed code section. This validates supplied bounds; it does not infer them or prove that unknown indirect callers cannot exist. Review those callers before supplying a recovery file. Invalid input aborts the batch before generated output is written; rerun with corrected inputs.

Regression checks need no game files:

python -m pytest tools/recomp/test_function_coalescence.py