RSO (File Format)

The RSO format is the file format for shared objects for Wii games. This is essentially the Wii's equivalent of a DLL file, allowing for code modules to be dynamically linked at runtime and unlinked when not in use to save memory. It's very similar to the GameCube's REL format, with the main difference being that the RSO format resolves symbol references via runtime symbol lookups rather than having pre-calculated offsets into the game's module files.

RSO files are usually accompanied by a SEL file, which is an RSO file that contains no code or data sections, and instead just has an export table for the DOL file. This is used to resolve module references to symbols in the main executable.

Section Info Table
This data is pointed to by the Section Info Offset value in the header. It specifies the layout of the file. The structure loops once for each section in the file, as specified by the Section Count in the header. Any compiler-generated sections that are unused (such as the symbol table or the section name table) are nulled out and listed with a size/offset of 0. The first section is always null. The BSS section is listed with a valid size but an offset of 0 (as the BSS section is not included in the file, but instead has space allocated at runtime).

Relocation Table
Since modules have space allocated at runtime and can therefore do not have a fixed memory address, the relocations table is needed to ensure all references to symbols within the RSO have the correct address. When the module is linked in, the game uses the relocation table to iterate over all instructions and data values referring to RSO symbols, and patch them to point to the correct address.

There are two relocation tables in the file; one for internal relocations (relocations for addresses in this RSO pointing to symbols also in this RSO), and one for external relocations (relocations for addresses in this RSO pointing to symbols in the main DOL executable). These tables are pointed to by the Internal Relocation Table Offset and External Relocation Table Offset values in the header. You can calculate the number of relocation entries by dividing the size of the table by 0xC (the size of one relocation entry).

These are the possible relocation types. The "used" column indicates whether this relocation type is used by any of the modules in any of Retro's games.

Symbol Table
RSO modules resolve references to symbols at runtime, rather than using precalculated offsets into the module files like REL does. To accomplish this, there's two symbol tables in the file; one for exports (symbols that are included in this RSO), and imports (symbols that are included in other modules but are referenced from this module). The name of the symbol in the import table is used to locate the same symbol in another module's export table, from which the address of the symbol can be calculated. Note that although the main DOL file doesn't contain an export table, there is a DOL export table in the SEL file, which can usually be found alongside the RSOs.