Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:RPX and RPL

From ReverseEngineering.wiki
Format
Platforms Platform:Nintendo Wii U
Magic 7F 45 4C 46 01 02 01 CA FE
Extensions .rpx, .rpl
Endianness big
On this wiki Facts · Code · Notes · Topics

Executable (.rpx) and shared library (.rpl) format of the Nintendo Wii U: a big-endian 32-bit PowerPC ELF with ABI byte 0xCA and Cafe-specific section types (exports, imports, CRCs, file info), zlib-compressed sections flagged 0x08000000, and link bases 0x02000000 (code), 0x10000000 (data) and 0xC0000000 (loader info).

Overview

Wii U applications are .rpx files (the main executable) and .rpl files (Cafe OS libraries such as coreinit.rpl and gx2.rpl, and libraries shipped with a game's code folder). Both are ELF files with a few Cafe-specific extensions; an RPX is an RPL whose file-info flags carry RPL_IS_RPX (decaf's FileInfoFlags). Details below were read in decaf-emu (src/libdecaf/src/cafe/loader/cafe_loader_rpl.h), Cemu (src/Cafe/OS/RPL) and devkitPro/wut-tools (src/elf2rpl, rplimportgen, rplexportgen). See Format:ELF (Executable and Linkable Format) for the base format and Platform:Nintendo Wii U for the system.

Identification

The ELF header is 32-bit big-endian PowerPC: bytes 7F 45 4C 46 01 02 01 CA FE (class 1, data 2 = MSB, version 1, OS/ABI 0xCA, ABI version 0xFE), e_machine 20. decaf's loader rejects a file whose class is not 32-bit, whose encoding is not MSB, whose ABI is not 0xCA, whose machine is not PPC, whose version is not 1 or whose section count is below 2. Section headers are the standard 0x28-byte ELF32 ones. See Fact:RPX and RPL/identification/Cafe ELF header.

Special sections

Section types 0x80000001 to 0x80000004 are Cafe extensions: exports, imports, CRCs and file info (Fact:RPX and RPL/enum/RPL section types). decaf's loader reads the CRC section at index shnum-2 and the file-info section at shnum-1, so they are the last two sections; the CRC section holds one CRC-32 per section.

  • File info (type 0x80000004): 0x60 bytes in the current layout, version 0xCAFE0402 (Fact:RPX and RPL/struct/RPL file info v4.2). decaf also declares the older versions 0xCAFE0300 and 0xCAFE0401 (0x40 bytes each).
  • Exports (0x80000001): count, signature, then {value, name offset} pairs and the names (Fact:RPX and RPL/struct/RPL exports section). Function exports live in a section named .fexports (executable flag set), data exports in .dexports.
  • Imports (0x80000002): one section per imported library, named .fimport_<lib> (functions) or .dimport_<lib> (data); it starts with a count and a signature, then the library name and 8-byte slots (Fact:RPX and RPL/struct/RPL imports section).

Compressed sections

A section whose flags include 0x08000000 (decaf calls it SHF_DEFLATED, Cemu SHF_RPL_COMPRESSED) stores a big-endian u32 with the inflated size followed by a zlib stream; the section header size is the compressed size. decaf rejects a deflated file-info section. See Fact:RPX and RPL/behavior/Deflated section layout. wut-tools' elf2rpl writes compression level 6 into the file info (Format:Zlib stream, Library:Zlib).

Memory layout

wut-tools' elf2rpl links code at 0x02000000, data at 0x10000000 and the loader-info sections (imports, exports, relocations, symbol tables) at 0xC0000000 (Fact:RPX and RPL/behavior/Link base addresses). Cemu's loader sorts a file's sections into text (flag 4 executable, not exports/imports), data (flag 1 write), loader info (other allocated sections) and temp (not allocated) regions. Relocation types are standard PowerPC ones plus Green Hills SDA and REL16 variants (Fact:RPX and RPL/enum/RPL relocation types).

Loading

The loader checks the file-info and CRC sections (a failed file-info CRC is reported as an error), maps sections to the regions, resolves imports against loaded modules and applies relocations. Cemu treats an import library it has not loaded as a built-in (HLE) module. A game opens further .rpl files itself with OSDynLoad_Acquire (Fact:Nintendo Wii U/enum/OSDynLoad error codes). Loader error numbers seen in decaf: -470025 for a non-Cafe ELF header, -470082 for a bad file-info section, -4700xx for zlib failures (Fact:RPX and RPL/enum/Loader error codes).

Tools

  • wut-tools elf2rpl converts an ELF built by devkitPPC to RPX, readrpl dumps one, rplimportgen and rplexportgen generate import and export assembly.
  • decaf-emu and Cemu load RPX/RPL files directly; their loaders are the best readable references.
  • Unverified: Ghidra and IDA need an RPX-aware loader plugin (or an RPX converted back to a plain ELF with sections inflated) to analyse a retail RPX; no loader was checked for this page.

Code & repositories

  • https://github.com/decaf-emu/decaf-emu @ e6c528a20a41c34e0f9eb91dd3da40f119db2dee · license: GPL-3.0
    decaf-emu, a Wii U emulator; src/libdecaf/src/cafe/loader holds the Cafe OS loader (RPL structs, file info, CRC and zlib handling) and src/libdecaf/src/cafe/kernel/cafe_kernel_mmu.cpp the virtual memory map
    Tested on: source read, not run: source read only, not built · checked 2026-10-18; last activity 2024-09-03; Note: the latest release ships binaries; the wiki links only the source, never the binaries
  • https://github.com/cemu-project/Cemu @ a53cf0ece75964aa361056edab46f281dcc0bc44 · license: MPL-2.0
    Cemu, a Wii U emulator (MPL-2.0); src/Cafe/OS/RPL has the RPX/RPL loader (rpl.cpp, rpl_structs.h)
    Tested on: source read, not run: source read only, not built · checked 2026-10-18; last activity 2026-10-15; Note: the latest release ships binaries; the wiki links only the source, never the binaries
  • https://github.com/devkitPro/wut-tools @ b22de1a3c0c8950c4ad4b4df170c89c05d3196aa · license: GPL-2.0
    wut-tools (GPL-2.0): elf2rpl, readrpl, rplimportgen, rplexportgen; shows how an RPX is produced from an ELF
    Tested on: source read, not run: source read only, not built · checked 2026-10-18; last activity 2024-07-02

Pitfalls

  • Unverified: tools that read the file as plain ELF show compressed sections as garbage; inflate them first.
  • wut-tools writes count 1 and signature 0 in import sections and notes in a comment that hardware does not check them.