Further documentation for overlay relocation (#1498)

* Further documentation for overlay relocation

* Suggested changes

* Format

* REL_ -> RELOC_
This commit is contained in:
Tharo
2023-02-27 08:14:02 +00:00
committed by GitHub
parent 35887e25ee
commit 12f67e108a
5 changed files with 128 additions and 64 deletions
+3 -3
View File
@@ -1741,11 +1741,11 @@ Gfx* GfxPrint_Close(GfxPrint* this);
s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...);
void RcpUtils_PrintRegisterStatus(void);
void RcpUtils_Reset(void);
void* Overlay_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, void* vRamStart, void* vRamEnd);
void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd);
void MtxConv_F2L(Mtx* m1, MtxF* m2);
void MtxConv_L2F(MtxF* m1, Mtx* m2);
void Overlay_Relocate(void* allocatedVRamAddress, OverlayRelocationSection* overlayInfo, void* vRamStart);
s32 Overlay_Load(uintptr_t vRomStart, uintptr_t vRomEnd, void* vRamStart, void* vRamEnd, void* allocatedVRamAddr);
void Overlay_Relocate(void* allocatedRamAddress, OverlayRelocationSection* ovlRelocs, void* vramStart);
s32 Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd, void* allocatedRamAddr);
// ? func_800FC800(?);
// ? func_800FC83C(?);
// ? func_800FCAB4(?);
+16 -6
View File
@@ -1165,24 +1165,34 @@ typedef struct ArenaNode {
/* 0x28 */ u8 unk_28[0x30-0x28]; // probably padding
} ArenaNode; // size = 0x30
#define RELOC_SECTION(reloc) ((reloc) >> 30)
#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF)
/* Relocation entry field getters */
#define RELOC_SECTION(reloc) ((reloc) >> 30)
#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF)
#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000)
#define RELOC_TYPE_SHIFT 24
/* MIPS Relocation Types */
#define R_MIPS_32 2
#define R_MIPS_26 4
/* MIPS Relocation Types, matches the MIPS ELF spec */
#define R_MIPS_32 2
#define R_MIPS_26 4
#define R_MIPS_HI16 5
#define R_MIPS_LO16 6
/* Reloc section id, must fit in 2 bits otherwise the relocation format must be modified */
typedef enum {
/* 0 */ RELOC_SECTION_NULL,
/* 1 */ RELOC_SECTION_TEXT,
/* 2 */ RELOC_SECTION_DATA,
/* 3 */ RELOC_SECTION_RODATA,
/* 4 */ RELOC_SECTION_MAX
} RelocSectionId;
typedef struct OverlayRelocationSection {
/* 0x00 */ u32 textSize;
/* 0x04 */ u32 dataSize;
/* 0x08 */ u32 rodataSize;
/* 0x0C */ u32 bssSize;
/* 0x10 */ u32 nRelocations;
/* 0x14 */ u32 relocations[1];
/* 0x14 */ u32 relocations[1]; // size is nRelocations
} OverlayRelocationSection; // size >= 0x18
typedef struct {