From 892c439fcf11599f3f74e54f626d5e61361a3f4a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 17 Mar 2018 13:58:56 -0700 Subject: [PATCH] Module: Clarify insertSymbols usage. --- Core/HLE/sceKernelModule.cpp | 9 +++++---- Core/MIPS/MIPSAnalyst.cpp | 4 +++- Core/MIPS/MIPSAnalyst.h | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 63c2d12927..82da25de65 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1268,6 +1268,7 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd scan = g_Config.bFuncReplacements; #endif + // If the ELF has debug symbols, don't add entries to the symbol table. bool insertSymbols = scan && !reader.LoadSymbols(); std::vector codeSections = reader.GetCodeSections(); for (SectionID id : codeSections) { @@ -1281,7 +1282,7 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd module->textEnd = end; if (scan) { - MIPSAnalyst::ScanForFunctions(start, end, insertSymbols); + insertSymbols = MIPSAnalyst::ScanForFunctions(start, end, insertSymbols); } } @@ -1291,14 +1292,14 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd u32 scanEnd = module->textEnd; // Skip the exports and imports sections, they're not code. if (scanEnd >= std::min(modinfo->libent, modinfo->libstub)) { - MIPSAnalyst::ScanForFunctions(scanStart, std::min(modinfo->libent, modinfo->libstub) - 4, insertSymbols); + insertSymbols = MIPSAnalyst::ScanForFunctions(scanStart, std::min(modinfo->libent, modinfo->libstub) - 4, insertSymbols); scanStart = std::min(modinfo->libentend, modinfo->libstubend); } if (scanEnd >= std::max(modinfo->libent, modinfo->libstub)) { - MIPSAnalyst::ScanForFunctions(scanStart, std::max(modinfo->libent, modinfo->libstub) - 4, insertSymbols); + insertSymbols = MIPSAnalyst::ScanForFunctions(scanStart, std::max(modinfo->libent, modinfo->libstub) - 4, insertSymbols); scanStart = std::max(modinfo->libentend, modinfo->libstubend); } - MIPSAnalyst::ScanForFunctions(scanStart, scanEnd, insertSymbols); + insertSymbols = MIPSAnalyst::ScanForFunctions(scanStart, scanEnd, insertSymbols); } if (scan) { diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index b72120ca06..9a31123fef 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -1018,7 +1018,7 @@ skip: return furthestJumpbackAddr; } - void ScanForFunctions(u32 startAddr, u32 endAddr, bool &insertSymbols) { + bool ScanForFunctions(u32 startAddr, u32 endAddr, bool insertSymbols) { std::lock_guard guard(functions_lock); AnalyzedFunction currentFunction = {startAddr}; @@ -1166,6 +1166,8 @@ skip: g_symbolMap->AddFunction(DefaultFunctionName(temp, iter->start), iter->start, iter->end - iter->start + 4); } } + + return insertSymbols; } void FinalizeScan(bool insertSymbols) { diff --git a/Core/MIPS/MIPSAnalyst.h b/Core/MIPS/MIPSAnalyst.h index 030ff0e95c..746fa26f90 100644 --- a/Core/MIPS/MIPSAnalyst.h +++ b/Core/MIPS/MIPSAnalyst.h @@ -105,7 +105,8 @@ namespace MIPSAnalyst // If we have loaded symbols from the elf, we'll register functions as they are touched // so that we don't just dump them all in the cache. void RegisterFunction(u32 startAddr, u32 size, const char *name); - void ScanForFunctions(u32 startAddr, u32 endAddr, bool &insertSymbols); + // Returns new insertSymbols value for FinalizeScan(). + bool ScanForFunctions(u32 startAddr, u32 endAddr, bool insertSymbols); void FinalizeScan(bool insertSymbols); void ForgetFunctions(u32 startAddr, u32 endAddr); void PrecompileFunctions();