mirror of
https://github.com/N64Recomp/N64Recomp.git
synced 2025-05-20 02:14:55 +00:00
Implemented function stubbing
This commit is contained in:
parent
fba0085946
commit
7df3e28c76
4 changed files with 99 additions and 78 deletions
14
src/main.cpp
14
src/main.cpp
|
@ -665,6 +665,7 @@ bool read_symbols(RecompPort::Context& context, const ELFIO::elfio& elf_file, EL
|
|||
if (num_instructions > 0) {
|
||||
context.section_functions[section_index].push_back(context.functions.size());
|
||||
}
|
||||
context.functions_by_name[name] = context.functions.size();
|
||||
context.functions.emplace_back(
|
||||
vram,
|
||||
rom_address,
|
||||
|
@ -1069,6 +1070,19 @@ int main(int argc, char** argv) {
|
|||
|
||||
fmt::print("Working dir: {}\n", std::filesystem::current_path().string());
|
||||
|
||||
// Stub out any functions specified in the config file.
|
||||
for (const std::string& stubbed_func : config.stubbed_funcs) {
|
||||
// Check if the specified function exists.
|
||||
auto func_find = context.functions_by_name.find(stubbed_func);
|
||||
if (func_find == context.functions_by_name.end()) {
|
||||
// Function doesn't exist, present an error to the user instead of silently failing to stub it out.
|
||||
// This helps prevent typos in the config file or functions renamed between versions from causing issues.
|
||||
exit_failure(fmt::format("Function {} is stubbed out in the config file but does not exist!", stubbed_func));
|
||||
}
|
||||
// Mark the function as stubbed.
|
||||
context.functions[func_find->second].stubbed = true;
|
||||
}
|
||||
|
||||
//#pragma omp parallel for
|
||||
for (size_t i = 0; i < context.functions.size(); i++) {
|
||||
const auto& func = context.functions[i];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue