From 29ed48c32aabe03cb086634b6dd0a26c6a57d7f1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 2 Jan 2018 22:21:08 -0800 Subject: [PATCH] Module: Avoid scanning stubs if possible. In this case, we often scan some garbage, but let's reduce it at least. --- Core/HLE/sceKernelModule.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index b65394ddb0..26d54d8794 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1283,7 +1283,18 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd // Some games don't have any sections at all. if (scan && codeSections.empty()) { - MIPSAnalyst::ScanForFunctions(module->textStart, module->textEnd, !gotSymbols); + u32 scanStart = module->textStart; + 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, !gotSymbols); + 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, !gotSymbols); + scanStart = std::max(modinfo->libentend, modinfo->libstubend); + } + MIPSAnalyst::ScanForFunctions(scanStart, scanEnd, !gotSymbols); } }