From eac8b1a84d27e75b040173162a0ceaf4d718bde8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 1 Dec 2013 19:43:40 -0800 Subject: [PATCH] Scan for functions even without a .text section. It's possible this may be wrong, but every game I've seen loads the funcs in this area. Sometimes there's data after the funcs before the stubs, but it's better than no funcs. --- Core/ELF/ElfReader.cpp | 2 +- Core/HLE/sceKernelModule.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index 0f2a29f9be..f7c0f7ccc6 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -29,7 +29,7 @@ const char *ElfReader::GetSectionName(int section) return 0; int nameOffset = sections[section].sh_name; - char *ptr = (char*)GetSectionDataPtr(header->e_shstrndx); + const char *ptr = (const char *)GetSectionDataPtr(header->e_shstrndx); if (ptr) return ptr + nameOffset; diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 4202611707..fef5918b64 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -838,6 +838,8 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro u32_le *entryPos = (u32_le *)Memory::GetPointer(modinfo->libstub); u32_le *entryEnd = (u32_le *)Memory::GetPointer(modinfo->libstubend); + u32_le firstImportStubAddr = 0; + bool needReport = false; while (entryPos < entryEnd) { PspLibStubEntry *entry = (PspLibStubEntry *)entryPos; @@ -882,6 +884,9 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro func.stubAddr = entry->firstSymAddr + i * 8; module->ImportFunc(func); } + + if (firstImportStubAddr == NULL || firstImportStubAddr > entry->firstSymAddr) + firstImportStubAddr = entry->firstSymAddr; } else if (entry->numFuncs > 0) { WARN_LOG_REPORT(LOADER, "Module entry with %d imports but no valid address", entry->numFuncs); needReport = true; @@ -945,6 +950,15 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro Reporting::ReportMessage("Module linking debug info:\n%s", debugInfo.c_str()); } + if (textSection == -1) { + u32 textStart = reader.GetVaddr(); + u32 textEnd = firstImportStubAddr - 4; +#if !defined(USING_GLES2) + if (!reader.LoadSymbols()) + MIPSAnalyst::ScanForFunctions(textStart, textEnd); +#endif + } + // Look at the exports, too. struct PspLibEntEntry