diff options
Diffstat (limited to 'backends/plugins/elf')
-rw-r--r-- | backends/plugins/elf/arm-loader.h | 5 | ||||
-rw-r--r-- | backends/plugins/elf/elf-loader.cpp | 49 | ||||
-rw-r--r-- | backends/plugins/elf/elf-loader.h | 11 | ||||
-rw-r--r-- | backends/plugins/elf/elf-provider.h | 2 | ||||
-rw-r--r-- | backends/plugins/elf/mips-loader.cpp | 4 | ||||
-rw-r--r-- | backends/plugins/elf/mips-loader.h | 6 | ||||
-rw-r--r-- | backends/plugins/elf/ppc-loader.h | 5 |
7 files changed, 30 insertions, 52 deletions
diff --git a/backends/plugins/elf/arm-loader.h b/backends/plugins/elf/arm-loader.h index 52a3be5447..c4df671060 100644 --- a/backends/plugins/elf/arm-loader.h +++ b/backends/plugins/elf/arm-loader.h @@ -25,6 +25,9 @@ #if defined(DYNAMIC_MODULES) && defined(ARM_TARGET) +#ifndef BACKENDS_PLUGINS_ARM_LOADER_H +#define BACKENDS_PLUGINS_ARM_LOADER_H + #include "backends/plugins/elf/elf-loader.h" class ARMDLObject : public DLObject { @@ -36,4 +39,6 @@ public: ARMDLObject() : DLObject() {} }; +#endif /* BACKENDS_PLUGINS_ARM_LOADER_H */ + #endif /* defined(DYNAMIC_MODULES) && defined(ARM_TARGET) */ diff --git a/backends/plugins/elf/elf-loader.cpp b/backends/plugins/elf/elf-loader.cpp index 5ce8af6295..e11f9fcce6 100644 --- a/backends/plugins/elf/elf-loader.cpp +++ b/backends/plugins/elf/elf-loader.cpp @@ -25,53 +25,12 @@ #if defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET) -#include <string.h> -#include <stdarg.h> - -#ifdef __PSP__ -#include <psputils.h> -#include <psputilsforkernel.h> -#endif - -#ifdef __DS__ -#include <nds.h> -#endif - -#ifdef __WII__ -#include <malloc.h> -#include <ogc/cache.h> -#endif - #include "backends/plugins/elf/elf-loader.h" #include "common/debug.h" #include "common/file.h" #include "common/fs.h" -/** - * Flushes the data cache (Platform Specific). - */ -static void flushDataCache(void *ptr, uint32 len) { -#ifdef __DS__ - DC_FlushRange(ptr, len); - IC_InvalidateRange(ptr, len); -#endif -#ifdef __PLAYSTATION2__ - (void) ptr; - (void) len; - FlushCache(0); - FlushCache(2); -#endif -#ifdef __PSP__ - sceKernelDcacheWritebackRange(ptr, len); - sceKernelIcacheInvalidateRange(ptr, len); -#endif -#ifdef __WII__ - DCFlushRange(ptr, len); - ICInvalidateRange(ptr, len); -#endif -} - DLObject::DLObject() : _segment(0), _symtab(0), @@ -86,7 +45,6 @@ DLObject::DLObject() : } DLObject::~DLObject() { - unload(); } // Expel the symbol table from memory @@ -101,8 +59,11 @@ void DLObject::discard_symtab() { // Unload all objects from memory void DLObject::unload() { discard_symtab(); - free(_segment); + freeSegment(_segment); _segment = 0; + _segmentSize = 0; + _segmentOffset = 0; + _segmentVMA = 0; } bool DLObject::readElfHeader(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr) { @@ -193,7 +154,7 @@ bool DLObject::loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *phdr) int extra = phdr->p_vaddr % phdr->p_align; // Get extra length TODO: check logic here debug(2, "elfloader: Extra mem is %x", extra); - if (!(_segment = (char *)memalign(phdr->p_align, phdr->p_memsz + extra))) { + if (!(_segment = (char *) allocSegment(phdr->p_align, phdr->p_memsz + extra))) { warning("elfloader: Out of memory."); return false; } diff --git a/backends/plugins/elf/elf-loader.h b/backends/plugins/elf/elf-loader.h index 6413c46cea..7c1d0830f3 100644 --- a/backends/plugins/elf/elf-loader.h +++ b/backends/plugins/elf/elf-loader.h @@ -25,8 +25,8 @@ #if defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET) -#ifndef ELF_LOADER_H -#define ELF_LOADER_H +#ifndef BACKENDS_PLUGINS_ELF_LOADER_H +#define BACKENDS_PLUGINS_ELF_LOADER_H #include <stddef.h> @@ -65,9 +65,14 @@ protected: bool loadStringTable(Common::SeekableReadStream* DLFile, Elf32_Shdr *shdr); virtual void relocateSymbols(ptrdiff_t offset); + // architecture specific virtual bool relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) = 0; virtual bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) = 0; + // platform specific + virtual void *allocSegment(size_t boundary, size_t size) const = 0; + virtual void freeSegment(void *segment) const = 0; + virtual void flushDataCache(void *ptr, uint32 len) const = 0; public: DLObject(); virtual ~DLObject(); @@ -78,6 +83,6 @@ public: void discard_symtab(); }; -#endif /* ELF_LOADER_H */ +#endif /* BACKENDS_PLUGINS_ELF_LOADER_H */ #endif /* defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET) */ diff --git a/backends/plugins/elf/elf-provider.h b/backends/plugins/elf/elf-provider.h index f06621f5b7..447e71ea18 100644 --- a/backends/plugins/elf/elf-provider.h +++ b/backends/plugins/elf/elf-provider.h @@ -52,7 +52,7 @@ public: ELFPlugin(const Common::String &filename) : _dlHandle(0), _filename(filename) {} - ~ELFPlugin() { + virtual ~ELFPlugin() { if (_dlHandle) unloadPlugin(); } diff --git a/backends/plugins/elf/mips-loader.cpp b/backends/plugins/elf/mips-loader.cpp index 642ea0427a..027ff34698 100644 --- a/backends/plugins/elf/mips-loader.cpp +++ b/backends/plugins/elf/mips-loader.cpp @@ -321,10 +321,6 @@ bool MIPSDLObject::loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *p // Unload all objects from memory void MIPSDLObject::unload() { - discard_symtab(); - free(_segment); - _segment = 0; - if (_shortsSegment) { ShortsMan.deleteSegment(_shortsSegment); _shortsSegment = 0; diff --git a/backends/plugins/elf/mips-loader.h b/backends/plugins/elf/mips-loader.h index a3210b5b12..28b8c7f636 100644 --- a/backends/plugins/elf/mips-loader.h +++ b/backends/plugins/elf/mips-loader.h @@ -26,6 +26,9 @@ #if defined(DYNAMIC_MODULES) && defined(MIPS_TARGET) +#ifndef BACKENDS_PLUGINS_MIPS_LOADER_H +#define BACKENDS_PLUGINS_MIPS_LOADER_H + #include "backends/plugins/elf/elf-loader.h" #include "backends/plugins/elf/shorts-segment-manager.h" @@ -47,4 +50,7 @@ public: } }; +#endif /* BACKENDS_PLUGINS_MIPS_LOADER_H */ + #endif /* defined(DYNAMIC_MODULES) && defined(MIPS_TARGET) */ + diff --git a/backends/plugins/elf/ppc-loader.h b/backends/plugins/elf/ppc-loader.h index 13043924bb..574ba104e6 100644 --- a/backends/plugins/elf/ppc-loader.h +++ b/backends/plugins/elf/ppc-loader.h @@ -25,6 +25,9 @@ #if defined(DYNAMIC_MODULES) && defined(PPC_TARGET) +#ifndef BACKENDS_PLUGINS_PPC_LOADER_H +#define BACKENDS_PLUGINS_PPC_LOADER_H + #include "backends/plugins/elf/elf-loader.h" class PPCDLObject : public DLObject { @@ -36,5 +39,7 @@ public: PPCDLObject() : DLObject() {} }; +#endif /* BACKENDS_PLUGINS_PPC_LOADER_H */ + #endif /* defined(DYNAMIC_MODULES) && defined(PPC_TARGET) */ |