REL (File Format): Difference between revisions

Jump to navigation Jump to search
>Aruki
No edit summary
>Aruki
 
(5 intermediate revisions by the same user not shown)
Line 165: Line 165:
| 1
| 1
| '''Prolog Function Offset'''
| '''Prolog Function Offset'''
| Section-relative offset of the prolog function. 0 if this module doesn't contain a prolog function.
| Section-relative offset of the prolog function. 0 if this module doesn't contain a prolog function. This is converted into a function pointer at runtime by OSLink.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 174: Line 174:
| 1
| 1
| '''Epilog Function Offset'''
| '''Epilog Function Offset'''
| Section-relative offset of the epilog function. 0 if this module doesn't contain an epilog function.
| Section-relative offset of the epilog function. 0 if this module doesn't contain an epilog function. This is converted into a function pointer at runtime by OSLink.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 183: Line 183:
| 1
| 1
| '''Unresolved Function Offset'''
| '''Unresolved Function Offset'''
| Section-relative offset of the unresolved function. 0 if this module doesn't contain an unresolved function.
| Section-relative offset of the unresolved function. 0 if this module doesn't contain an unresolved function. This is converted into a function pointer at runtime by OSLink.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 272: Line 272:
=== Relocation Table ===
=== Relocation Table ===


This data is pointed to by the ''Relocation Table Offset'' value in the header. 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 REL 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 REL symbols, and patch them to point to the correct address.
This data is pointed to by the ''Relocation Table Offset'' value in the header. 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 REL are correct; this includes both symbols within the REL itself, which don't have a fixed address until the REL 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 multiple distinct groups of relocations, with each one being pointed to by an entry in the [[#Import Table|import table]]. To read the relocations for a given module, you need to iterate over all relocation entries until you hit an R_DOLPHIN_END directive. Each relocation is 0x8 bytes.
There are multiple distinct groups of relocations, with each one being pointed to by an entry in the [[#Import Table|import table]]. To read the relocations for a given module, you need to iterate over all relocation entries until you hit an R_DOLPHIN_END directive. Each relocation is 0x8 bytes.
Line 299: Line 299:
| 1
| 1
| '''Section Index'''
| '''Section Index'''
| The section index of the symbol being patched to.
| The section index of the symbol being patched to. This is only used for module patches.
|-
|-
| 0x4
| 0x4
Line 366: Line 366:
| 9
| 9
| R_PPC_ADDR14_BRNTAKEN
| R_PPC_ADDR14_BRNTAKEN
| Write the 14-bit address of the symbol. Leave the existing value of the bottom two bits intact. '''Note:''' Needs a proper check on the differences between this and ADDR14
| Write the 14-bit address of the symbol. Leave the existing value of the bottom two bits intact. '''Note:''' Needs a proper check on differences between this and ADDR14
| {{nocheck}}
| {{nocheck}}
|-
|-
Anonymous user

Navigation menu