Skip to main content
The recompiler is configured via a TOML file that controls code generation behavior, analysis settings, and manual overrides.

Required Fields

project_name
string
default:"rex"
Project name used for generated files and namespaces.
file_path
string
required
Path to the input XEX or ELF executable file to recompile.
out_directory_path
string
default:"generated"
Output directory for generated C++ source files.

Patch Files (Not Yet Implemented)

patch_file_path
string
Path to binary patch file to apply before analysis.
patch_file_path
string
Path to save the patched executable.

Code Generation Options

These flags control register allocation and optimization behavior:
skip_lr
boolean
default:false
Skip saving/restoring the Link Register (LR) when not modified. Reduces overhead for leaf functions.
skip_msr
boolean
default:false
Skip Machine State Register (MSR) emulation. Use only if the binary doesn’t modify MSR.
ctr_as_local
boolean
default:false
Allocate Count Register (CTR) as a local variable instead of state struct field. Improves performance when CTR is used locally.
xer_as_local
boolean
default:false
Allocate XER (Fixed-Point Exception Register) as local variable.
reserved_as_local
boolean
default:false
Allocate reserved registers (r2, r13) as local variables.
cr_as_local
boolean
default:false
Allocate Condition Register fields as local variables.
non_argument_as_local
boolean
default:false
Allocate non-argument registers (r11-r31) as local variables when not used for parameters.
non_volatile_as_local
boolean
default:false
Allocate non-volatile registers (r14-r31) as local variables.
generate_exception_handlers
boolean
default:false
Generate SEH (Structured Exception Handling) wrapper functions for Windows exception handling.

Special Addresses

longjmp_address
uint32
default:0
Address of longjmp function for setjmp/longjmp analysis. Use hex format: 0x82000100.
setjmp_address
uint32
default:0
Address of setjmp function for setjmp/longjmp analysis.

Analysis Section

Fine-tune the analysis pipeline:
[analysis]
max_jump_extension = 65536
data_region_threshold = 16
large_function_threshold = 1048576
exception_handler_funcs = [0x82000200, 0x82000300]
analysis.max_jump_extension
uint32
default:65536
Maximum bytes to extend function boundaries when jump table targets are found outside initial function size.
analysis.data_region_threshold
uint32
default:16
Number of consecutive invalid instructions before marking region as data (not code). Helps detect embedded constants.
analysis.large_function_threshold
uint32
default:1048576
Size in bytes (1MB default) to warn about unusually large functions. May indicate analysis errors.
analysis.exception_handler_funcs
array
Array of exception handler function addresses for code region segmentation.
exception_handler_funcs = [0x82000200, 0x82000300]

Invalid Instructions Hints

Mark regions that contain data (not code) to prevent disassembly errors:
[[invalid_instructions]]
data = 0x82001000
size = 0x40

[[invalid_instructions]]
data = 0x82002000
size = 0x10
invalid_instructions
array of tables
Array of data regions that should not be disassembled as code.Each entry requires:
  • data (uint32): Starting address of data region
  • size (uint32): Size of data region in bytes

Indirect Call Hints

Mark bctr instructions as indirect calls (vtable dispatch, computed jumps) rather than switch tables:
indirect_calls = [0x82000400, 0x82000800]
indirect_calls
array
Array of addresses where bctr instructions are vtable/computed calls, not switch table jumps.

Example Configuration

project_name = "mygame"
file_path = "default.xex"
out_directory_path = "generated"

# Enable optimizations
skip_lr = true
ctr_as_local = true
xer_as_local = true
cr_as_local = true

# Analysis settings
[analysis]
max_jump_extension = 131072  # 128KB
data_region_threshold = 20
large_function_threshold = 2097152  # 2MB

# Mark embedded constant table as data
[[invalid_instructions]]
data = 0x82100000
size = 0x1000

# Known indirect calls
indirect_calls = [0x82000450, 0x82000890]

# Manual function override
[functions."0x82000100"]
size = 0x400
name = "GameInit"

Validation Rules

The configuration is validated before code generation:
  1. Alignment: All addresses must be 4-byte aligned (PowerPC instruction size)
  2. Required fields: file_path must be provided
  3. No overlaps: Function boundaries cannot overlap (standalone functions)
  4. Size constraints: Cannot specify both size and end for functions
  5. End address: If using end, it must be greater than the start address

See Also

Build docs developers (and LLMs) love