From 37dabfb295f6757d90cd2e661b985d602c29152f Mon Sep 17 00:00:00 2001 From: Ethan Lafrenais Date: Thu, 16 Jan 2025 01:00:31 -0500 Subject: [PATCH 1/2] Apply renamed_funcs to reference symbols --- src/config.cpp | 8 +++++++- src/elf.cpp | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index a54421a..c299471 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -663,7 +663,13 @@ bool N64Recomp::Context::import_reference_context(const N64Recomp::Context& refe // Copy the functions from the reference context into the reference context's function map. for (const N64Recomp::Function& func_in: reference_context.functions) { - if (!add_reference_symbol(func_in.name, func_in.section_index, func_in.vram, true)) { + // Rename if necessary + std::string name = func_in.name; + if (N64Recomp::renamed_funcs.contains(name)) { + name = name + "_recomp"; + } + + if (!add_reference_symbol(name, func_in.section_index, func_in.vram, true)) { return false; } } diff --git a/src/elf.cpp b/src/elf.cpp index 25f84da..d850f23 100644 --- a/src/elf.cpp +++ b/src/elf.cpp @@ -416,6 +416,11 @@ ELFIO::section* read_sections(N64Recomp::Context& context, const N64Recomp::ElfP // Check if the symbol is undefined and to know whether to look for it in the reference symbols. if (rel_symbol_section_index == ELFIO::SHN_UNDEF) { + // Get renamed version of symbol name if necessary + if (N64Recomp::renamed_funcs.contains(rel_symbol_name)) { + rel_symbol_name = rel_symbol_name + "_recomp"; + } + // Undefined sym, check the reference symbols. N64Recomp::SymbolReference sym_ref; if (!context.find_reference_symbol(rel_symbol_name, sym_ref)) { From 91be352ee0dcb85da9d547bec83f6693faf125a6 Mon Sep 17 00:00:00 2001 From: Ethan Lafrenais Date: Thu, 16 Jan 2025 01:00:31 -0500 Subject: [PATCH 2/2] Also apply reimplemented_funcs and ignored_funcs --- src/config.cpp | 4 +++- src/elf.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index c299471..477ab88 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -665,7 +665,9 @@ bool N64Recomp::Context::import_reference_context(const N64Recomp::Context& refe for (const N64Recomp::Function& func_in: reference_context.functions) { // Rename if necessary std::string name = func_in.name; - if (N64Recomp::renamed_funcs.contains(name)) { + if (N64Recomp::reimplemented_funcs.contains(name) || + N64Recomp::ignored_funcs.contains(name) || + N64Recomp::renamed_funcs.contains(name)) { name = name + "_recomp"; } diff --git a/src/elf.cpp b/src/elf.cpp index d850f23..68f6cc7 100644 --- a/src/elf.cpp +++ b/src/elf.cpp @@ -417,7 +417,9 @@ ELFIO::section* read_sections(N64Recomp::Context& context, const N64Recomp::ElfP // Check if the symbol is undefined and to know whether to look for it in the reference symbols. if (rel_symbol_section_index == ELFIO::SHN_UNDEF) { // Get renamed version of symbol name if necessary - if (N64Recomp::renamed_funcs.contains(rel_symbol_name)) { + if (N64Recomp::reimplemented_funcs.contains(rel_symbol_name) || + N64Recomp::ignored_funcs.contains(rel_symbol_name) || + N64Recomp::renamed_funcs.contains(rel_symbol_name)) { rel_symbol_name = rel_symbol_name + "_recomp"; }