diff --git a/N64Recomp b/N64Recomp index 81213c1..1c2569e 160000 --- a/N64Recomp +++ b/N64Recomp @@ -1 +1 @@ -Subproject commit 81213c1831fab2521a6a5459c67b63437d67e253 +Subproject commit 1c2569e2e3fa0965caaf90265b2a84ff951219d8 diff --git a/librecomp/include/librecomp/overlays.hpp b/librecomp/include/librecomp/overlays.hpp index 35703bd..a3196e7 100644 --- a/librecomp/include/librecomp/overlays.hpp +++ b/librecomp/include/librecomp/overlays.hpp @@ -34,6 +34,7 @@ namespace recomp { void init_overlays(); const std::unordered_map& get_vrom_to_section_map(); uint32_t get_section_ram_addr(uint16_t code_section_index); + std::optional get_section_got_ram_addr(uint16_t code_section_index); std::span get_section_relocs(uint16_t code_section_index); recomp_func_t* get_func_by_section_rom_function_vram(uint32_t section_rom, uint32_t function_vram); bool get_func_entry_by_section_index_function_offset(uint16_t code_section_index, uint32_t function_offset, FuncEntry& func_out); diff --git a/librecomp/include/librecomp/sections.h b/librecomp/include/librecomp/sections.h index 0fdb724..de09c34 100644 --- a/librecomp/include/librecomp/sections.h +++ b/librecomp/include/librecomp/sections.h @@ -1,6 +1,7 @@ #ifndef __SECTIONS_H__ #define __SECTIONS_H__ +#include #include #include "recomp.h" @@ -43,6 +44,7 @@ typedef struct { RelocEntry* relocs; size_t num_relocs; size_t index; + std::optional got_ram_addr; } SectionTableEntry; typedef struct { diff --git a/librecomp/src/mods.cpp b/librecomp/src/mods.cpp index ff40212..2e93608 100644 --- a/librecomp/src/mods.cpp +++ b/librecomp/src/mods.cpp @@ -1258,6 +1258,7 @@ struct RegeneratedSection { size_t first_func_index; size_t first_reloc_index; bool relocatable; + std::optional got_ram_addr; }; struct RegeneratedFunction { @@ -1323,6 +1324,7 @@ N64Recomp::Context context_from_regenerated_list(const RegeneratedList& regenlis section_out.executable = true; section_out.relocatable = section_in.relocatable; section_out.has_mips32_relocs = false; + section_out.got_ram_addr = section_in.got_ram_addr; std::vector& section_funcs_out = ret.section_functions[section_index]; section_funcs_out.resize(cur_num_funcs); @@ -1856,14 +1858,17 @@ std::vector build_regen_list( uint16_t section_index = find_section_it->second; uint32_t section_ram_addr; + std::optional got_ram_addr; if constexpr (patched_regenlist) { section_ram_addr = recomp::overlays::get_patch_section_ram_addr(section_index); cur_section_relocs = recomp::overlays::get_patch_section_relocs(section_index); + got_ram_addr = std::nullopt; } else { section_ram_addr = recomp::overlays::get_section_ram_addr(section_index); cur_section_relocs = recomp::overlays::get_section_relocs(section_index); + got_ram_addr = recomp::overlays::get_section_got_ram_addr(section_index); } // Allocate a new section. @@ -1874,7 +1879,8 @@ std::vector build_regen_list( .first_func_index = regenlist.functions.size(), .first_reloc_index = regenlist.relocs.size(), // Patch sections are never relocatable, so a section is relocatable if it has any relocs and is not a base patch section. - .relocatable = !patched_regenlist && !cur_section_relocs.empty() + .relocatable = !patched_regenlist && !cur_section_relocs.empty(), + .got_ram_addr = got_ram_addr }); // Update the tracked section fields. diff --git a/librecomp/src/overlays.cpp b/librecomp/src/overlays.cpp index 8c8e5d1..04fa31e 100644 --- a/librecomp/src/overlays.cpp +++ b/librecomp/src/overlays.cpp @@ -137,6 +137,10 @@ uint32_t recomp::overlays::get_section_ram_addr(uint16_t code_section_index) { return sections_info.code_sections[code_section_index].ram_addr; } +std::optional recomp::overlays::get_section_got_ram_addr(uint16_t code_section_index) { + return sections_info.code_sections[code_section_index].got_ram_addr; +} + std::span recomp::overlays::get_section_relocs(uint16_t code_section_index) { if (code_section_index < sections_info.num_code_sections) { const auto& section = sections_info.code_sections[code_section_index];