refined constructors, removed destructors, got rid of unneccessary method duplication in DLObject and its subtypes
svn-id: r51845
This commit is contained in:
parent
68b986545a
commit
de1e941370
8 changed files with 37 additions and 125 deletions
|
@ -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() {}
|
||||
};
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue