diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index 980e427e83..d85867978c 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -401,9 +401,6 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) // e_ident[EI_VERSION] is ignored - sectionOffsets = new u32[GetNumSections()]; - sectionAddrs = new u32[GetNumSections()]; - // Should we relocate? bRelocate = (header->e_type != ET_EXEC); @@ -513,6 +510,9 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) DEBUG_LOG(LOADER,"%i sections:", header->e_shnum); + sectionOffsets = new u32[GetNumSections()]; + sectionAddrs = new u32[GetNumSections()]; + for (int i = 0; i < GetNumSections(); i++) { const Elf32_Shdr *s = §ions[i]; @@ -534,7 +534,7 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) } } - DEBUG_LOG(LOADER,"Relocations:"); + DEBUG_LOG(LOADER, "Relocations:"); // Second pass: Do necessary relocations for (int i = 0; i < GetNumSections(); i++) diff --git a/Core/ELF/ElfReader.h b/Core/ELF/ElfReader.h index 0284b56bd4..f3ddbfee4b 100644 --- a/Core/ELF/ElfReader.h +++ b/Core/ELF/ElfReader.h @@ -154,7 +154,7 @@ private: u32 entryPoint = 0; u32 totalSize = 0; u32 vaddr = 0; - u32 segmentVAddr[32]; + u32 segmentVAddr[32]{}; size_t size_ = 0; u32 firstSegAlign = 0; }; diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index a482395a73..a5d7264827 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1198,6 +1198,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load } const auto maxElfSize = std::max(head->elf_size, head->psp_size); newptr = new u8[maxElfSize]; + elfSize = maxElfSize; ptr = newptr; magicPtr = (u32_le *)ptr; int ret = pspDecryptPRX(in, (u8*)ptr, head->psp_size);