Various mod fixes (#95)

* Terminate offline mod recompilation if any functions fail to recompile

* Fixed edge case with switch case jump table detection when lo16 immediate is exactly 0

* Prevent emitting duplicate reference symbol defines in offline mod recompilation

* Fix function calls and add missing runtime function pointers in offline mod recompiler
This commit is contained in:
Wiseguy 2024-09-12 18:54:08 -04:00 committed by GitHub
parent cc71b31b09
commit d5ab74220d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 6 deletions

View file

@ -158,9 +158,11 @@ bool analyze_instruction(const rabbitizer::InstructionCpu& instr, const N64Recom
}
// If the base register has a valid lui state and a valid addend before this, then this may be a load from a jump table
else if (reg_states[base].valid_lui && reg_states[base].valid_addend) {
// Exactly one of the lw and the base reg should have a valid lo16 value
// Exactly one of the lw and the base reg should have a valid lo16 value. However, the lo16 may end up just being zero by pure luck,
// so allow the case where the lo16 immediate is zero and the register state doesn't have a valid addiu immediate.
// This means the only invalid case is where they're both true.
bool nonzero_immediate = imm != 0;
if (nonzero_immediate != reg_states[base].valid_addiu) {
if (!(nonzero_immediate && reg_states[base].valid_addiu)) {
uint32_t lo16;
if (nonzero_immediate) {
lo16 = (int16_t)imm;

View file

@ -199,6 +199,8 @@ bool parse_v1(std::span<const char> data, const std::unordered_map<uint32_t, uin
cur_func.rom = cur_section.rom_addr + funcs[func_index].section_offset;
cur_func.words.resize(funcs[func_index].size / sizeof(uint32_t)); // Filled in later
cur_func.section_index = section_index;
mod_context.functions_by_vram[cur_func.vram].emplace_back(start_func_index + func_index);
}
for (size_t reloc_index = 0; reloc_index < num_relocs; reloc_index++) {