RSO (File Format): Difference between revisions

Jump to navigation Jump to search
>Aruki
>Aruki
Line 199: Line 199:
=== Relocation Table ===
=== Relocation Table ===


Since modules have space allocated at runtime and 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.
Since modules have space allocated at runtime and therefore do not have a fixed memory address, the relocations table is needed to ensure all data and function addresses are correct; this includes both symbols within the RSO itself, which don't have a fixed address until the RSO is linked in, and symbols within the DOL, which need corrections due to the usage of relative offsets in branch instructions. The relocation table describes the location of every instruction that needs to be patched, and how to patch it.


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 (File Format)|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).
There are two relocation tables in the file; one for internal relocations (relocations for addresses pointing to symbols within this RSO), and one for external relocations (relocations for addresses pointing to symbols within the main [[DOL (File Format)|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).


{| class="wikitable"
{| class="wikitable"
Anonymous user

Navigation menu