Skip to content

Static Recompiler

Jason edited this page Aug 11, 2026 · 1 revision

Static Recompiler

This page maps the implementation concepts that turn PSP code into generated C. It does not replace the deeper PSP format and binary-translation research on the research site.

Input and executable inventory

The loader and build orchestration identify the user-supplied ELF/PRX modules, their bases, sections, BSS metadata, and supported relocation records. tools/prxload.py produces a flat guest image; the build manifest keeps module identity and generated artifacts separate from private input bytes.

Imports and NIDs

PSP imports are represented by library metadata, NID tables, and positional stub slots. tools/imports.py reconstructs that information for codegen and runtime registration. A name or numeric NID is an identity clue, not proof that the operation is implemented. Missing or uncertain operations stay visible.

Analysis and ownership

tools/analyze.py reconstructs function boundaries and control-flow metadata. Nakagawa distinguishes:

  • callable entries that begin a function under the normal call contract;
  • resume/interior entries that re-enter an existing function with live state;
  • indirect targets discovered from tables or computed control flow;
  • unresolved or ambiguous targets that must remain conservative.

Function ownership is separate from โ€œwhat address was reached.โ€ This prevents an interior entry or adjacent function from being incorrectly emitted with the wrong prologue/epilogue assumptions.

Code generation

tools/codegen.py consumes the loader, import, and analysis products and emits C that operates on the shared CpuState. Generated functions are split into dynamic chunks. Translation-specific compatibility overrides are narrow semantic debt: they require evidence, a regression or bounded route, and a retirement criterion.

Source ownership

Work on the generator, analyzer, loader, runtime, or testsโ€”not on generated C. When a generated function looks wrong, inspect the earliest divergence, verify the source inputs and manifest, then regenerate and compare the resulting output.

Deeper references:

Next: Architecture โ†’ Verification and Testing.

Nakagawa Recomp

Architecture

Development

Project

Research site

Clone this wiki locally