mirror of
https://github.com/N64Recomp/N64Recomp.git
synced 2025-05-14 08:12:19 +00:00
Add an option to the context to force function lookup for all non-relocated function calls
This commit is contained in:
parent
f09031e84e
commit
8641508cd3
2 changed files with 11 additions and 1 deletions
|
@ -223,6 +223,8 @@ namespace N64Recomp {
|
|||
std::vector<uint8_t> 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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue