diff options
-rw-r--r-- | backends/plugins/arm-loader.h | 11 | ||||
-rw-r--r-- | backends/plugins/ds/ds-provider.cpp | 36 | ||||
-rw-r--r-- | backends/plugins/elf-loader.h | 2 | ||||
-rw-r--r-- | backends/plugins/elf-provider.cpp | 24 | ||||
-rw-r--r-- | backends/plugins/elf-provider.h | 7 | ||||
-rw-r--r-- | backends/plugins/mips-loader.h | 10 | ||||
-rw-r--r-- | backends/plugins/ps2/ps2-provider.cpp | 36 | ||||
-rw-r--r-- | backends/plugins/psp/psp-provider.cpp | 36 |
8 files changed, 37 insertions, 125 deletions
diff --git a/backends/plugins/arm-loader.h b/backends/plugins/arm-loader.h index babbe69739..7f7a1f7f4b 100644 --- a/backends/plugins/arm-loader.h +++ b/backends/plugins/arm-loader.h @@ -33,14 +33,5 @@ protected: bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr); public: - ARMDLObject() { - _segment = NULL; - _symtab = NULL; - _strtab = NULL; - _symbol_cnt = 0; - _symtab_sect = -1; - _dtors_start = NULL; - _dtors_end = NULL; - _segmentSize = 0; - } + ARMDLObject() : DLObject() {} }; diff --git a/backends/plugins/ds/ds-provider.cpp b/backends/plugins/ds/ds-provider.cpp index 66e063f151..7365a2e6e9 100644 --- a/backends/plugins/ds/ds-provider.cpp +++ b/backends/plugins/ds/ds-provider.cpp @@ -32,41 +32,9 @@ class DSPlugin : public ELFPlugin { public: - DSPlugin(const Common::String &filename) { - _dlHandle = 0; - _filename = filename; - } + DSPlugin(const Common::String &filename) : ELFPlugin(filename) {} - ~DSPlugin() { - if (_dlHandle) - unloadPlugin(); - } - - bool loadPlugin(); -}; - -bool DSPlugin::loadPlugin() { - assert(!_dlHandle); - DLObject *obj = new ARMDLObject(); - if (obj->open(_filename.c_str())) { - _dlHandle = obj; - } else { - delete obj; - _dlHandle = NULL; - } - - if (!_dlHandle) { - warning("Failed loading plugin '%s'", _filename.c_str()); - return false; - } - - bool ret = DynamicPlugin::loadPlugin(); - - if (ret && _dlHandle) { - _dlHandle->discard_symtab(); - } - - return ret; + DLObject *makeDLObject() { return new ARMDLObject(); } }; Plugin* DSPluginProvider::createPlugin(const Common::FSNode &node) const { diff --git a/backends/plugins/elf-loader.h b/backends/plugins/elf-loader.h index 56a9fa3767..1d30aa0c3b 100644 --- a/backends/plugins/elf-loader.h +++ b/backends/plugins/elf-loader.h @@ -60,6 +60,8 @@ public: void *symbol(const char *name); void discard_symtab(); + DLObject() : _segment(NULL), _symtab(NULL), _strtab(NULL), _symbol_cnt(0), + _symtab_sect(-1), _dtors_start(NULL), _dtors_end(NULL), _segmentSize(0) {} }; #endif /* ELF_LOADER_H */ diff --git a/backends/plugins/elf-provider.cpp b/backends/plugins/elf-provider.cpp index 03218130fb..e6edd4c578 100644 --- a/backends/plugins/elf-provider.cpp +++ b/backends/plugins/elf-provider.cpp @@ -58,6 +58,30 @@ DynamicPlugin::VoidFunc ELFPlugin::findSymbol(const char *symbol) { return tmp; } +bool ELFPlugin::loadPlugin() { + assert(!_dlHandle); + DLObject *obj = makeDLObject(); + if (obj->open(_filename.c_str())) { + _dlHandle = obj; + } else { + delete obj; + _dlHandle = NULL; + } + + if (!_dlHandle) { + warning("Failed loading plugin '%s'", _filename.c_str()); + return false; + } + + bool ret = DynamicPlugin::loadPlugin(); + + if (ret && _dlHandle) { + _dlHandle->discard_symtab(); + } + + return ret; +}; + void ELFPlugin::unloadPlugin() { DynamicPlugin::unloadPlugin(); if (_dlHandle) { diff --git a/backends/plugins/elf-provider.h b/backends/plugins/elf-provider.h index fd047fd0d3..e0382c3e45 100644 --- a/backends/plugins/elf-provider.h +++ b/backends/plugins/elf-provider.h @@ -42,9 +42,6 @@ protected: virtual VoidFunc findSymbol(const char *symbol); public: - ELFPlugin() { - } - ELFPlugin(const Common::String &filename) : _dlHandle(0), _filename(filename) {} @@ -53,7 +50,9 @@ public: unloadPlugin(); } - virtual bool loadPlugin() = 0; + virtual DLObject *makeDLObject() = 0; + + bool loadPlugin(); void unloadPlugin(); }; diff --git a/backends/plugins/mips-loader.h b/backends/plugins/mips-loader.h index 9d13feccbb..eb22e368f4 100644 --- a/backends/plugins/mips-loader.h +++ b/backends/plugins/mips-loader.h @@ -39,15 +39,7 @@ protected: void unload(); public: - MIPSDLObject() { - _segment = NULL; - _symtab = NULL; - _strtab = NULL; - _symbol_cnt = 0; - _symtab_sect = -1; - _dtors_start = NULL; - _dtors_end = NULL; - _segmentSize = 0; + MIPSDLObject() : DLObject() { _shortsSegment = NULL; _gpVal = 0; } diff --git a/backends/plugins/ps2/ps2-provider.cpp b/backends/plugins/ps2/ps2-provider.cpp index 7305c27c74..096c6d4050 100644 --- a/backends/plugins/ps2/ps2-provider.cpp +++ b/backends/plugins/ps2/ps2-provider.cpp @@ -32,41 +32,9 @@ class PS2Plugin : public ELFPlugin { public: - PS2Plugin(const Common::String &filename) { - _dlHandle = 0; - _filename = filename; - } + PS2Plugin(const Common::String &filename) : ELFPlugin(filename) {} - ~PS2Plugin() { - if (_dlHandle) - unloadPlugin(); - } - - bool loadPlugin(); -}; - -bool PS2Plugin::loadPlugin() { - assert(!_dlHandle); - DLObject *obj = new MIPSDLObject(); - if (obj->open(_filename.c_str())) { - _dlHandle = obj; - } else { - delete obj; - _dlHandle = NULL; - } - - if (!_dlHandle) { - warning("Failed loading plugin '%s'", _filename.c_str()); - return false; - } - - bool ret = DynamicPlugin::loadPlugin(); - - if (ret && _dlHandle) { - _dlHandle->discard_symtab(); - } - - return ret; + DLObject *makeDLObject() { return new MIPSDLObject(); } }; Plugin* PS2PluginProvider::createPlugin(const Common::FSNode &node) const { diff --git a/backends/plugins/psp/psp-provider.cpp b/backends/plugins/psp/psp-provider.cpp index f542373b87..99aa33c123 100644 --- a/backends/plugins/psp/psp-provider.cpp +++ b/backends/plugins/psp/psp-provider.cpp @@ -32,41 +32,9 @@ class PSPPlugin : public ELFPlugin { public: - PSPPlugin(const Common::String &filename) { - _dlHandle = 0; - _filename = filename; - } + PSPPlugin(const Common::String &filename) : ELFPlugin(filename) {} - ~PSPPlugin() { - if (_dlHandle) - unloadPlugin(); - } - - bool loadPlugin(); -}; - -bool PSPPlugin::loadPlugin() { - assert(!_dlHandle); - DLObject *obj = new MIPSDLObject(); - if (obj->open(_filename.c_str())) { - _dlHandle = obj; - } else { - delete obj; - _dlHandle = NULL; - } - - if (!_dlHandle) { - warning("Failed loading plugin '%s'", _filename.c_str()); - return false; - } - - bool ret = DynamicPlugin::loadPlugin(); - - if (ret && _dlHandle) { - _dlHandle->discard_symtab(); - } - - return ret; + DLObject *makeDLObject() { return new MIPSDLObject(); } }; Plugin* PSPPluginProvider::createPlugin(const Common::FSNode &node) const { |