Module: Clarify insertSymbols usage.

This commit is contained in:
Unknown W. Brackets 2018-03-17 13:58:56 -07:00
parent f14f2efa79
commit 892c439fcf
3 changed files with 10 additions and 6 deletions

View File

@ -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<SectionID> 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) {

View File

@ -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<std::recursive_mutex> 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) {

View File

@ -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();