RSO (File Format): Difference between revisions
m
→Header
>Aruki |
>Aruki m (→Header) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 110: | Line 110: | ||
| 1 | | 1 | ||
| '''Internal Relocation Table Offset''' | | '''Internal Relocation Table Offset''' | ||
| Absolute offset of the [[#Relocation Table|relocation table]] for internal relocations (relocations | | Absolute offset of the [[#Relocation Table|relocation table]] for internal relocations (relocations for symbols within this module). | ||
|- | |- | ||
| 0x34 | | 0x34 | ||
Line 122: | Line 122: | ||
| 1 | | 1 | ||
| '''External Relocation Table Offset''' | | '''External Relocation Table Offset''' | ||
| Absolute offset of the [[#Relocation Table|relocation table]] for external relocations (relocations | | Absolute offset of the [[#Relocation Table|relocation table]] for external relocations (relocations for symbols within other modules). | ||
|- | |- | ||
| 0x3C | | 0x3C | ||
Line 152: | Line 152: | ||
| 1 | | 1 | ||
| '''Import Symbol Table Offset''' | | '''Import Symbol Table Offset''' | ||
| Absolute offset of the [[#Symbol Table|symbol table]] for imports (symbols within other modules). | | Absolute offset of the [[#Symbol Table|symbol table]] for imports (symbols within other modules, referenced by this one). | ||
|- | |- | ||
| 0x50 | | 0x50 | ||
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 | 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 in the RSO 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 | 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" | ||
Line 328: | Line 328: | ||
| 1 | | 1 | ||
| '''Symbol Offset''' | | '''Symbol Offset''' | ||
| The section-relative offset to the symbol. | | The section-relative offset to the symbol. This is always 0 for imports. | ||
|- | |- | ||
| 0x8 | | 0x8 | ||
Line 334: | Line 334: | ||
| 1 | | 1 | ||
| '''Symbol Section Index''' | | '''Symbol Section Index''' | ||
| | | For exports, index of the section that contains this symbol. For imports, appears to be an offset? | ||
|- | |- | ||
| 0xC | | 0xC | ||
Line 340: | Line 340: | ||
| 1 | | 1 | ||
| '''ELF Hash''' | | '''ELF Hash''' | ||
| A hash. Exact details unknown, but isn't required to link to the symbol. | | A hash. Exact details unknown, but isn't required to link to the symbol. This field is omitted for imports. | ||
|- | |- | ||
| 0x10 | | 0x10 |