Skip to main content
Print

PSP Imports, NIDs, and Stub Tables: Positional Reconstruction for Static Recompilation

Status: IMPLEMENTATION FACT / PRIOR ART · Evidence: public format documentation and current source validation · Last reviewed: 2026-08-11

Why position matters

PSP PRX imports are a table-reconstruction problem, not a numeric-name guessing exercise. In the common import layout, each imported function has an 8-byte slot in .sceStub.text and a 4-byte numeric identifier in .rodata.sceNid. The k-th stub pairs with the k-th NID within the claimed library window. Preserving that positional relationship is what lets a recompiler register the right unresolved call.

Metadata windows

SceModuleInfo library records describe windows over the stub and NID regions. A robust importer parses the global regions, then validates each window and its alignment before pairing entries. The checks should reject truncated records, non-multiple sizes, mismatched stub/NID counts, overlapping or overflowing ranges, and arithmetic that wraps before the bounds check. A malformed module should remain visibly malformed; it must not be turned into a fabricated successful import.

Field Public meaning Safe reconstruction rule
Stub slot call veneer for one imported function read exactly one 8-byte slot at the validated position
NID numeric identifier pair by index; do not derive a name from the number
Library window claimed slice of the global tables validate start, count, alignment, and checked end arithmetic

Names are provenance, not arithmetic

A NID identifies an API entry; it does not prove the human-readable name. Names come from library metadata, public SDK headers, symbol databases, or carefully attributed tooling. When a name is unresolved, retain the numeric NID and mark the provenance instead of inventing a label.

Current implementation reference

Nakagawa’s public import parser documents the one-to-one stub/NID model and validates truncation, alignment, count, and overflow conditions before registration. That is an implementation fact and a reproducible review target; the underlying import-table convention is prior art. The public PSPSDK import-fixup tool provides the SDK-side pairing check, and the PSP Developer Wiki PRX format page documents the module structure. This page does not claim that Nakagawa invented NIDs or the PRX format.

Review checklist

  • Confirm the module’s claimed windows before reading bytes.
  • Check the complete readable span and checked size arithmetic.
  • Require one stub per NID in every accepted library slice.
  • Keep unresolved identifiers visible and source-attributed.
  • Exercise malformed metadata as a negative test.

Start with the PSP Executable Model, then compare the result with the Evidence Standard and Static Recompilation Architecture.

Table of Contents