diff --git a/src/config.cpp b/src/config.cpp index 4c3594e..d3b236f 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -413,7 +413,7 @@ N64Recomp::Config::Config(const char* path) { function_hooks = get_function_hooks(table); } - // Use RE mode if enabled (optional) + // Use trace mode if enabled (optional) std::optional trace_mode_opt = input_data["trace_mode"].value(); if (trace_mode_opt.has_value()) { trace_mode = trace_mode_opt.value(); diff --git a/src/elf.cpp b/src/elf.cpp index a91f07f..a18fdbd 100644 --- a/src/elf.cpp +++ b/src/elf.cpp @@ -58,7 +58,20 @@ bool read_symbols(N64Recomp::Context& context, const ELFIO::elfio& elf_file, ELF continue; } - if (section_index < context.sections.size()) { + if (section_index < context.sections.size()) { + // Check if this symbol is the entrypoint + // TODO this never fires, the check is broken due to signedness + if (elf_config.has_entrypoint && value == elf_config.entrypoint_address && type == ELFIO::STT_FUNC) { + if (found_entrypoint_func) { + fmt::print(stderr, "Ambiguous entrypoint: {}\n", name); + return false; + } + found_entrypoint_func = true; + fmt::print("Found entrypoint, original name: {}\n", name); + size = 0x50; // dummy size for entrypoints, should cover them all + name = "recomp_entrypoint"; + } + // Check if this symbol has a size override auto size_find = elf_config.manually_sized_funcs.find(name); if (size_find != elf_config.manually_sized_funcs.end()) { @@ -100,10 +113,8 @@ bool read_symbols(N64Recomp::Context& context, const ELFIO::elfio& elf_file, ELF context.functions_by_vram[vram].push_back(context.functions.size()); // Find the entrypoint by rom address in case it doesn't have vram as its value - if (rom_address == 0x1000 && type == ELFIO::STT_FUNC) { - if (elf_config.has_entrypoint) { - vram = elf_config.entrypoint_address; - } + if (elf_config.has_entrypoint && rom_address == 0x1000 && type == ELFIO::STT_FUNC) { + vram = elf_config.entrypoint_address; found_entrypoint_func = true; name = "recomp_entrypoint"; if (size == 0) { diff --git a/src/main.cpp b/src/main.cpp index bf8d511..1db3f4d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -499,7 +499,7 @@ int main(int argc, char** argv) { // Check if the specified function exists. auto func_find = context.functions_by_name.find(renamed_func); if (func_find == context.functions_by_name.end()) { - // Function doesn't exist, present an error to the user instead of silently failing to mark it as ignored. + // Function doesn't exist, present an error to the user instead of silently failing to rename it. // This helps prevent typos in the config file or functions renamed between versions from causing issues. exit_failure(fmt::format("Function {} is set as renamed in the config file but does not exist!", renamed_func)); } @@ -508,7 +508,7 @@ int main(int argc, char** argv) { func->name = func->name + "_recomp"; } - // Propogate the re_mode parameter. + // Propogate the trace mode parameter. context.trace_mode = config.trace_mode; // Apply any single-instruction patches.