Skip to content

Commit 1852543

Browse files
authored
Merge pull request #14294 from unknownbrackets/module-start
Module: Correctly handle modules with -1 entry
2 parents 63a94ce + f6ad90f commit 1852543

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

Core/ELF/ElfReader.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop)
445445

446446
if (bRelocate) {
447447
DEBUG_LOG(LOADER,"Relocatable module");
448-
entryPoint += vaddr;
448+
if (entryPoint != (u32)-1)
449+
entryPoint += vaddr;
449450
} else {
450451
DEBUG_LOG(LOADER,"Prerelocated executable");
451452
}

Core/HLE/sceKernelModule.cpp

+3-11
Original file line numberDiff line numberDiff line change
@@ -2085,16 +2085,6 @@ int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValue
20852085
entryAddr = module->nm.module_start_func;
20862086
if (module->nm.module_start_thread_attr != 0)
20872087
attribute = module->nm.module_start_thread_attr;
2088-
} else if (entryAddr == (u32)-1 || entryAddr == module->memoryBlockAddr - 1) {
2089-
if (smoption) {
2090-
// TODO: Does sceKernelStartModule() really give an error when no entry only if you pass options?
2091-
attribute = smoption->attribute;
2092-
} else {
2093-
// TODO: Why are we just returning the module ID in this case?
2094-
WARN_LOG(SCEMODULE, "sceKernelStartModule(): module has no start or entry func");
2095-
module->nm.status = MODULE_STATUS_STARTED;
2096-
return moduleId;
2097-
}
20982088
}
20992089

21002090
if (Memory::IsValidAddress(entryAddr)) {
@@ -2110,14 +2100,16 @@ int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValue
21102100
stacksize = module->nm.module_start_thread_stacksize;
21112101
}
21122102

2103+
// TODO: Why do we skip smoption->attribute here?
2104+
21132105
SceUID threadID = __KernelCreateThread(module->nm.name, moduleId, entryAddr, priority, stacksize, attribute, 0, (module->nm.attribute & 0x1000) != 0);
21142106
__KernelStartThreadValidate(threadID, argsize, argAddr);
21152107
__KernelSetThreadRA(threadID, NID_MODULERETURN);
21162108

21172109
if (needsWait) {
21182110
*needsWait = true;
21192111
}
2120-
} else if (entryAddr == 0) {
2112+
} else if (entryAddr == 0 || entryAddr == (u32)-1) {
21212113
INFO_LOG(SCEMODULE, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x): no entry address", moduleId, argsize, argAddr, returnValueAddr);
21222114
module->nm.status = MODULE_STATUS_STARTED;
21232115
} else {

0 commit comments

Comments
 (0)