aboutsummaryrefslogtreecommitdiff
path: root/backends/plugins
diff options
context:
space:
mode:
authorTony Puccinelli2010-08-06 23:30:27 +0000
committerTony Puccinelli2010-08-06 23:30:27 +0000
commit646587f79a4249e25e47af74d36c72602f00dd0f (patch)
tree1fe8447d711d17971eaa5a7e6e2e8e93210e14d4 /backends/plugins
parent66225374b2f75f8c5b4406564c35ca476242aa81 (diff)
downloadscummvm-rg350-646587f79a4249e25e47af74d36c72602f00dd0f.tar.gz
scummvm-rg350-646587f79a4249e25e47af74d36c72602f00dd0f.tar.bz2
scummvm-rg350-646587f79a4249e25e47af74d36c72602f00dd0f.zip
got rid of gp2xwiz loader (anything useful from it is already incorporated into the ARM loader in the plugins directory at this point) and implemented ARMDLObject as a subtype of DLObject
svn-id: r51813
Diffstat (limited to 'backends/plugins')
-rw-r--r--backends/plugins/arm-loader.cpp9
-rw-r--r--backends/plugins/ds/ds-provider.cpp7
-rw-r--r--backends/plugins/ds/ds-provider.h3
-rw-r--r--backends/plugins/elf-loader.h22
-rw-r--r--backends/plugins/elf-provider.cpp33
-rw-r--r--backends/plugins/elf-provider.h6
6 files changed, 22 insertions, 58 deletions
diff --git a/backends/plugins/arm-loader.cpp b/backends/plugins/arm-loader.cpp
index 8ceccfb7e8..61d7c73236 100644
--- a/backends/plugins/arm-loader.cpp
+++ b/backends/plugins/arm-loader.cpp
@@ -23,9 +23,12 @@
*
*/
+#if defined(DYNAMIC_MODULES) && defined(ARM)
+
#include "backends/fs/ds/ds-fs.h"
#include "elf-loader.h"
#include "dsmain.h"
+#include "arm-loader.h"
#define __DEBUG_PLUGINS__
@@ -45,7 +48,7 @@
* @param size Size of relocation section
*
*/
-bool DLObject::relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) {
+bool ARMDLObject::relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) {
Elf32_Rel *rel = NULL; //relocation entry
// Allocate memory for relocation table
@@ -135,7 +138,7 @@ bool DLObject::relocate(Common::SeekableReadStream* DLFile, unsigned long offset
return true;
}
-bool DLObject::relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) {
+bool ARMDLObject::relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) {
// Loop over sections, finding relocation sections
for (int i = 0; i < ehdr->e_shnum; i++) {
@@ -162,3 +165,5 @@ bool DLObject::relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr
return true;
}
+
+#endif /* defined(DYNAMIC_MODULES) && defined(ARM) */
diff --git a/backends/plugins/ds/ds-provider.cpp b/backends/plugins/ds/ds-provider.cpp
index 999781754b..c83f198b5e 100644
--- a/backends/plugins/ds/ds-provider.cpp
+++ b/backends/plugins/ds/ds-provider.cpp
@@ -23,15 +23,18 @@
*
*/
+#if defined(DYNAMIC_MODULES) && defined(__DS__)
+
/*#include "base/plugins.h"
#include "backends/plugins/dynamic-plugin.h"
#include "common/fs.h"
#include "backends/plugins/elf-loader.h"*/
+#include "backends/plugins/arm-loader.h"
#include "backends/plugins/elf-provider.h"
#include "backends/plugins/ds/ds-provider.h"
-#if defined(DYNAMIC_MODULES) && defined(__DS__)
+
class DSPlugin : public ELFPlugin {
public:
@@ -50,7 +53,7 @@ public:
bool DSPlugin::loadPlugin() {
assert(!_dlHandle);
- DLObject *obj = new DLObject(NULL);
+ DLObject *obj = new ARMDLObject();
if (obj->open(_filename.c_str())) {
_dlHandle = obj;
} else {
diff --git a/backends/plugins/ds/ds-provider.h b/backends/plugins/ds/ds-provider.h
index d9b1ee9cf4..462c3e3b63 100644
--- a/backends/plugins/ds/ds-provider.h
+++ b/backends/plugins/ds/ds-provider.h
@@ -25,11 +25,8 @@
#include "backends/plugins/elf-provider.h"
-#if defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET)
-
class DSPluginProvider : public ELFPluginProvider {
Plugin* createPlugin(const Common::FSNode &node) const;
};
-#endif // defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET)
diff --git a/backends/plugins/elf-loader.h b/backends/plugins/elf-loader.h
index 0a84d9c0b9..423a97bc42 100644
--- a/backends/plugins/elf-loader.h
+++ b/backends/plugins/elf-loader.h
@@ -28,6 +28,7 @@
#include "elf32.h"
#include "common/stream.h"
+#include "backends/plugins/dynamic-plugin.h"
#if defined(__PLAYSTATION2__) || defined(__PSP__)
#define MIPS_TARGET
@@ -38,12 +39,8 @@
#define ARM_TARGET
#endif
-#define MAXDLERRLEN 80
-
class DLObject {
protected:
- char *_errbuf; /* For error messages, at least MAXDLERRLEN in size */
-
void *_segment, *_symtab;
char *_strtab;
int _symbol_cnt;
@@ -57,9 +54,9 @@ protected:
unsigned int _gpVal; // Value of Global Pointer
#endif
- void seterror(const char *fmt, ...);
+ //void seterror(const char *fmt, ...);
void unload();
- virtual bool relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment);
+ virtual bool relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) = 0;
bool load(Common::SeekableReadStream* DLFile);
bool readElfHeader(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr);
@@ -69,7 +66,7 @@ protected:
int loadSymbolTable(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr);
bool loadStringTable(Common::SeekableReadStream* DLFile, Elf32_Shdr *shdr);
void relocateSymbols(Elf32_Addr offset);
- virtual bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr);
+ virtual bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) = 0;
public:
bool open(const char *path);
@@ -77,15 +74,6 @@ public:
void *symbol(const char *name);
void discard_symtab();
- DLObject(char *errbuf = NULL) : _errbuf(errbuf), _segment(NULL), _symtab(NULL),
- _strtab(NULL), _symbol_cnt(0), _symtab_sect(-1), _dtors_start(NULL), _dtors_end(NULL),
- _segmentSize(0) {
-#ifdef MIPS_TARGET
- _shortsSegment = NULL;
- _gpVal = 0;
-#endif
- }
-
};
-#endif /* LOADER_H */
+#endif /* ELF_LOADER_H */
diff --git a/backends/plugins/elf-provider.cpp b/backends/plugins/elf-provider.cpp
index 22e365130b..03218130fb 100644
--- a/backends/plugins/elf-provider.cpp
+++ b/backends/plugins/elf-provider.cpp
@@ -23,14 +23,14 @@
*
*/
+#if defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET)
+
#include "backends/plugins/elf-provider.h"
#include "backends/plugins/dynamic-plugin.h"
#include "common/fs.h"
#include "backends/plugins/elf-loader.h"
-#if defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET)
-
DynamicPlugin::VoidFunc ELFPlugin::findSymbol(const char *symbol) {
void *func;
bool handleNull;
@@ -58,30 +58,6 @@ DynamicPlugin::VoidFunc ELFPlugin::findSymbol(const char *symbol) {
return tmp;
}
-bool ELFPlugin::loadPlugin() {
- assert(!_dlHandle);
- DLObject *obj = new DLObject(NULL);
- 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) {
@@ -93,11 +69,6 @@ void ELFPlugin::unloadPlugin() {
}
}
-
-Plugin* ELFPluginProvider::createPlugin(const Common::FSNode &node) const {
- return new ELFPlugin(node.getPath());
-}
-
bool ELFPluginProvider::isPluginFilename(const Common::FSNode &node) const {
// Check the plugin suffix
Common::String filename = node.getName();
diff --git a/backends/plugins/elf-provider.h b/backends/plugins/elf-provider.h
index eb0ea5d51d..fd047fd0d3 100644
--- a/backends/plugins/elf-provider.h
+++ b/backends/plugins/elf-provider.h
@@ -53,14 +53,14 @@ public:
unloadPlugin();
}
- virtual bool loadPlugin();
- virtual void unloadPlugin();
+ virtual bool loadPlugin() = 0;
+ void unloadPlugin();
};
class ELFPluginProvider : public FilePluginProvider {
protected:
- virtual Plugin* createPlugin(const Common::FSNode &node) const;
+ virtual Plugin* createPlugin(const Common::FSNode &node) const = 0;
bool isPluginFilename(const Common::FSNode &node) const;