diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index dd0cf8247..3ead77cf2 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -271,7 +271,6 @@ bool ElfReader::LoadInto(u32 loadAddress) } DEBUG_LOG(LOADER,"Relocations:"); - bool oldRelocs = false; // Second pass: Do necessary relocations for (int i=0; ish_type == SHT_REL) { DEBUG_LOG(LOADER, "Traditional relocation section found."); - if (bRelocate) + if (!bRelocate) { DEBUG_LOG(LOADER, "Binary is prerelocated. Skipping relocations."); } else { - oldRelocs = true; + //We have a relocation table! + int sectionToModify = s->sh_info; + if (!(sections[sectionToModify].sh_flags & SHF_ALLOC)) + { + ERROR_LOG(LOADER,"Trying to relocate non-loaded section %s, ignoring",GetSectionName(sectionToModify)); + continue; + } + ERROR_LOG(LOADER,"Traditional relocations unsupported."); } } } - if (oldRelocs) - { - INFO_LOG(LOADER, "Game uses old relocations (often for debugging, should be harmless)"); - } // Segment relocations (a few games use them) if (GetNumSections() == 0) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 5daa4d89f..11578688c 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -120,6 +120,43 @@ struct dirent { }; #endif +class FileNode : public KernelObject { +public: + FileNode() : callbackID(0), callbackArg(0), asyncResult(0), pendingAsyncResult(false), sectorBlockMode(false) {} + ~FileNode() { + pspFileSystem.CloseFile(handle); + } + const char *GetName() {return fullpath.c_str();} + const char *GetTypeName() {return "OpenFile";} + void GetQuickInfo(char *ptr, int size) { + sprintf(ptr, "Seekpos: %08x", (u32)pspFileSystem.GetSeekPos(handle)); + } + static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_BADF; } + int GetIDType() const { return PPSSPP_KERNEL_TMID_File; } + + virtual void DoState(PointerWrap &p) { + p.Do(fullpath); + p.Do(handle); + p.Do(callbackID); + p.Do(callbackArg); + p.Do(asyncResult); + p.Do(pendingAsyncResult); + p.Do(sectorBlockMode); + p.DoMarker("File"); + } + + std::string fullpath; + u32 handle; + + u32 callbackID; + u32 callbackArg; + + u32 asyncResult; + + bool pendingAsyncResult; + bool sectorBlockMode; +}; + void __IoInit() { INFO_LOG(HLE, "Starting up I/O..."); @@ -175,6 +212,15 @@ void __IoShutdown() { defParam = 0; } +u32 __IoGetFileHandleFromId(u32 id, u32 &outError) +{ + FileNode *f = kernelObjects.Get < FileNode > (id, outError); + if (!f) { + return -1; + } + return f->handle; +} + u32 sceIoAssign(const char *aliasname, const char *physname, const char *devname, u32 flag) { ERROR_LOG(HLE, "UNIMPL sceIoAssign(%s, %s, %s, %08x, ...)", aliasname, physname, devname, flag); diff --git a/Core/HLE/sceIo.h b/Core/HLE/sceIo.h index cd8852140..2945a396c 100644 --- a/Core/HLE/sceIo.h +++ b/Core/HLE/sceIo.h @@ -23,46 +23,10 @@ #include "HLE.h" #include "sceKernel.h" -class FileNode : public KernelObject { -public: - FileNode() : callbackID(0), callbackArg(0), asyncResult(0), pendingAsyncResult(false), sectorBlockMode(false) {} - ~FileNode() { - pspFileSystem.CloseFile(handle); - } - const char *GetName() {return fullpath.c_str();} - const char *GetTypeName() {return "OpenFile";} - void GetQuickInfo(char *ptr, int size) { - sprintf(ptr, "Seekpos: %08x", (u32)pspFileSystem.GetSeekPos(handle)); - } - static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_BADF; } - int GetIDType() const { return PPSSPP_KERNEL_TMID_File; } - - virtual void DoState(PointerWrap &p) { - p.Do(fullpath); - p.Do(handle); - p.Do(callbackID); - p.Do(callbackArg); - p.Do(asyncResult); - p.Do(pendingAsyncResult); - p.Do(sectorBlockMode); - p.DoMarker("File"); - } - - std::string fullpath; - u32 handle; - - u32 callbackID; - u32 callbackArg; - - u32 asyncResult; - - bool pendingAsyncResult; - bool sectorBlockMode; -}; - void __IoInit(); void __IoDoState(PointerWrap &p); void __IoShutdown(); +u32 __IoGetFileHandleFromId(u32 id, u32 &outError); KernelObject *__KernelFileNodeObject(); KernelObject *__KernelDirListingObject(); diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 89b7cd540..d590dc36e 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -794,8 +794,8 @@ void sceKernelFindModuleByName() u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr) { u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); - if (!f) { + u32 handle = __IoGetFileHandleFromId(id, error); + if (handle < 0) { ERROR_LOG(HLE,"sceKernelLoadModuleByID(%08x, %08x, %08x): could not open file id",id,flags,lmoptionPtr); return error; } @@ -803,13 +803,13 @@ u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr) if (lmoptionPtr) { lmoption = (SceKernelLMOption *)Memory::GetPointer(lmoptionPtr); } - u32 pos = pspFileSystem.SeekFile(f->handle, 0, FILEMOVE_CURRENT); - u32 size = pspFileSystem.SeekFile(f->handle, 0, FILEMOVE_END); + u32 pos = pspFileSystem.SeekFile(handle, 0, FILEMOVE_CURRENT); + u32 size = pspFileSystem.SeekFile(handle, 0, FILEMOVE_END); std::string error_string; - pspFileSystem.SeekFile(f->handle, pos, FILEMOVE_BEGIN); + pspFileSystem.SeekFile(handle, pos, FILEMOVE_BEGIN); Module *module = 0; u8 *temp = new u8[size]; - pspFileSystem.ReadFile(f->handle, temp, size); + pspFileSystem.ReadFile(handle, temp, size); module = __KernelLoadELFFromPtr(temp, 0, &error_string); delete [] temp;