Warning fixes, alignment checks

This commit is contained in:
Henrik Rydgård
2025-05-15 09:48:23 +02:00
parent fba2489c79
commit 5260be6f69
7 changed files with 28 additions and 9 deletions
+7 -2
View File
@@ -1331,7 +1331,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
// Seen in WWE: Smackdown vs Raw 2009. See #17435.
continue;
}
if (!Memory::IsValidRange(start, len)) {
if (!Memory::IsValid4AlignedRange(start, len)) {
ERROR_LOG(Log::Loader, "Bad section %08x (len %08x) of section %d", start, len, id);
continue;
}
@@ -1351,7 +1351,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
u32 scanStart = module->textStart;
u32 scanEnd = module->textEnd;
if (Memory::IsValidRange(scanStart, scanEnd - scanStart)) {
if (Memory::IsValid4AlignedRange(scanStart, scanEnd - scanStart)) {
// Skip the exports and imports sections, they're not code.
if (scanEnd >= std::min(modinfo->libent, modinfo->libstub)) {
insertSymbols = MIPSAnalyst::ScanForFunctions(scanStart, std::min(modinfo->libent, modinfo->libstub) - 4, insertSymbols);
@@ -1473,6 +1473,11 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
u32 nid = residentPtr[ent->fcount + j];
u32 exportAddr = exportPtr[ent->fcount + j];
if (exportAddr & 3) {
ERROR_LOG(Log::Loader, "Bad export address %08x", exportAddr);
continue;
}
int size;
switch (nid) {
case NID_MODULE_INFO: