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.
This commit is contained in:
Unknown W. Brackets 2013-12-01 19:43:40 -08:00
parent 7bdca82dca
commit eac8b1a84d
2 changed files with 15 additions and 1 deletions

View File

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

View File

@ -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