diff --git a/include/recompiler/context.h b/include/recompiler/context.h index 8231d75..1d3f2e4 100644 --- a/include/recompiler/context.h +++ b/include/recompiler/context.h @@ -223,6 +223,8 @@ namespace N64Recomp { std::vector rom; // Whether reference symbols should be validated when emitting function calls during recompilation. bool skip_validating_reference_symbols = true; + // Whether all function calls (excluding reference symbols) should go through lookup. + bool use_lookup_for_all_function_calls = false; //// Only used by the CLI, TODO move this to a struct in the internal headers. // A mapping of function name to index in the functions vector diff --git a/src/recompilation.cpp b/src/recompilation.cpp index 0253d17..5403ff1 100644 --- a/src/recompilation.cpp +++ b/src/recompilation.cpp @@ -22,6 +22,11 @@ enum class JalResolutionResult { }; JalResolutionResult resolve_jal(const N64Recomp::Context& context, size_t cur_section_index, uint32_t target_func_vram, size_t& matched_function_index) { + // Skip resolution if all function calls should use lookup and just return Ambiguous. + if (context.use_lookup_for_all_function_calls) { + return JalResolutionResult::Ambiguous; + } + // Look for symbols with the target vram address const N64Recomp::Section& cur_section = context.sections[cur_section_index]; const auto matching_funcs_find = context.functions_by_vram.find(target_func_vram); @@ -316,7 +321,10 @@ bool process_instruction(GeneratorType& generator, const N64Recomp::Context& con call_by_name = true; break; case JalResolutionResult::Ambiguous: - fmt::print(stderr, "[Info] Ambiguous jal target 0x{:08X} in function {}, falling back to function lookup\n", target_func_vram, func.name); + // Print a warning if lookup isn't forced for all non-reloc function calls. + if (!context.use_lookup_for_all_function_calls) { + fmt::print(stderr, "[Info] Ambiguous jal target 0x{:08X} in function {}, falling back to function lookup\n", target_func_vram, func.name); + } // Relocation isn't necessary for jumps inside a relocatable section, as this code path will never run if the target vram // is in the current function's section (see the branch for `in_current_section` above). // If a game ever needs to jump between multiple relocatable sections, relocation will be necessary here.