diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index c8ba0aa8dc..69ea38b837 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -393,7 +393,7 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) } bool kernelModule = modInfo ? (modInfo->moduleAttrs & 0x1000) != 0 : false; - BlockAllocator &memblock = kernelModule ? kernelMemory : userMemory; + std::string modName = "ELF"; if (modInfo) { size_t n = strnlen(modInfo->name, 28); @@ -413,6 +413,11 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) } } totalSize = totalEnd - totalStart; + + // If a load address is specified that's in regular RAM, override kernel module status + bool inUser = totalStart > 0x08900000; + BlockAllocator &memblock = (kernelModule && !inUser) ? kernelMemory : userMemory; + if (!bRelocate) { // Binary is prerelocated, load it where the first segment starts @@ -433,7 +438,7 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) ERROR_LOG_REPORT(LOADER, "Failed to allocate memory for ELF!"); return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; } - + if (bRelocate) { DEBUG_LOG(LOADER,"Relocatable module"); entryPoint += vaddr; diff --git a/Core/Util/BlockAllocator.cpp b/Core/Util/BlockAllocator.cpp index 7de62c4950..1a6d2975e9 100644 --- a/Core/Util/BlockAllocator.cpp +++ b/Core/Util/BlockAllocator.cpp @@ -131,7 +131,7 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromT //Out of memory :( ListBlocks(); - ERROR_LOG(HLE, "Block Allocator failed to allocate %i (%08x) bytes of contiguous memory", size, size); + ERROR_LOG(HLE, "Block Allocator (%08x-%08x) failed to allocate %i (%08x) bytes of contiguous memory", rangeStart_, rangeStart_ + rangeSize_, size, size); return -1; } @@ -148,7 +148,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) ERROR_LOG(HLE, "Clearly bogus size: %08x - failing allocation", size); return -1; } - + // Downalign the position so we're allocating full blocks. u32 alignedPosition = position; u32 alignedSize = size; @@ -212,10 +212,10 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) ERROR_LOG(HLE, "Block allocator AllocAt failed :( %08x, %i", position, size); } - + //Out of memory :( ListBlocks(); - ERROR_LOG(HLE, "Block Allocator failed to allocate %i bytes of contiguous memory", alignedSize); + ERROR_LOG(HLE, "Block Allocator (%08x-%08x) failed to allocate %i (%08x) bytes of contiguous memory", rangeStart_, rangeStart_ + rangeSize_, alignedSize, alignedSize); return -1; }