Format:REL relocatable module
| Platforms | Platform:Nintendo GameCube, Wii |
|---|---|
| Magic | none (module id, version 1-3 at 0x1C) |
| Extensions | .rel (with .str string table, .map) |
| Endianness | big |
| On this wiki | Facts · Code · Notes · Topics |
Dynamically linked module format of GameCube and Wii games (.rel): an OSModuleHeader (0x40, 0x48 or 0x4C bytes for versions 1-3) with a section table, an import table naming the modules it references (0 = the main DOL) and per-import relocation streams of 8-byte OSRel records, linked at run time by the SDK's OSLink.
Overview
RELs let a game keep code out of the main Format:DOL executable and load it on demand: Software:The Legend of Zelda: The Wind Waker has about 415 of them (one per actor or scene object: d_a_*.rel), 180 packed in files/RELS.arc (a Yaz0-compressed Format:RARC archive, directories rels/mmem and rels/amem) and the rest loose in files/rels/. The format comes from the Library:Dolphin SDK (OSLink.h); decomp-toolkit builds them from ELF objects with dtk rel make.
A REL holds no symbol names: exports are found by relocation only, and prolog, epilog and unresolved (the module's entry points, usually _prolog, _epilog, _unresolved) are given as section + offset. The module name is an offset into a separate string file (the SDK's OSSetStringTable), often absent in retail games.
Header (OSModuleHeader)
| Offset | Field |
|---|---|
| 0x00 | id: module number (unique; 0 is the DOL)
|
| 0x04 / 0x08 | next / prev: list links, 0 in the file
|
| 0x0C | numSections
|
| 0x10 | sectionInfoOffset (file offset of the section table)
|
| 0x14 / 0x18 | nameOffset / nameSize (into the string table)
|
| 0x1C | version (1, 2 or 3)
|
| 0x20 | bssSize
|
| 0x24 | relOffset (start of all relocation data)
|
| 0x28 / 0x2C | impOffset / impSize (import table, bytes)
|
| 0x30-0x33 | section numbers of prolog, epilog, unresolved; bssSection (set at run time)
|
| 0x34 / 0x38 / 0x3C | offsets of prolog, epilog, unresolved in their sections |
| 0x40 / 0x44 | version >= 2: align, bssAlign
|
| 0x48 | version 3: fixSize
|
The section table has numSections entries of (offset, size). Bit 0 of the offset marks an executable section; an entry with offset 0 and non-zero size is the BSS section; offset 0 and size 0 is an unused (ELF-numbering placeholder) section, so section numbers match the ELF section indexes of the object the REL was made from.
Imports and relocations
The import table is a list of (module id, offset) pairs. Each offset points to a stream of 8-byte OSRel records: u16 offset (bytes from the previous relocation), u8 type, u8 section, u32 addend. Special types: R_DOLPHIN_SECTION (202) selects the section of this module to patch and resets the position, R_DOLPHIN_NOP (201) only advances the position (for gaps over 0xFFFF), R_DOLPHIN_END (203) ends the stream. For other types, section is the section of the imported module and the target is that section's address + addend; for module 0 (the DOL) addend is the absolute address. The SDK applies R_PPC_ADDR32, ADDR24, ADDR16, ADDR16_LO, ADDR16_HI, ADDR16_HA, ADDR14*, REL24, REL14* (ELF PowerPC numbering 1-13) and reports others as OSLink: unknown relocation type.
Linking at run time
OSLink(module, bss) (Link in os/OSLink.c): checks the version and alignment, appends the module to the list at 0x800030C8, turns every offset into a pointer, gives the BSS section the bss address, applies the module's relocations against the DOL, then against every loaded module and every loaded module's relocations against the new one, flushing the caches of executable sections. OSLinkFixed (version 3) does the same and then cuts the import table at the first entry for module 0 or the module itself, so the memory from fixSize on (those relocations) can be reused, e.g. for BSS. Because of that cut, linkers write imports of other RELs first and the self and DOL imports last.
Tools
- decomp-toolkit:
dtk rel info,dtk rel make(src/util/rel.rs). - Code:DOL executable/GameCube formats toolkit (Python) prints the header, sections and relocation counts.
Code & repositories
- https://github.com/encounter/decomp-toolkit @
0645e16511814920ffb05b25615dd71f1af73e4c· license: Apache-2.0
decomp-toolkit (dtk, Rust, MIT OR Apache-2.0): splits GameCube/Wii DOLs and RELs into objects for matching decompilations, reads and writes DOL, REL, RARC, U8, Yaz0/Yay0 and the CodeWarrior .comment section, and generates symbols.txt/splits.txt configurations.
Tested on: Read at commit 0645e16: src/util/dol.rs (DolHeader), src/util/rel.rs (R_DOLPHIN_* types), src/util/rarc.rs, src/util/comment.rs; not built. · checked 2026-10-17; last activity 2026-09-10; Note: the latest release ships binaries; the wiki links only the source, never the binaries