aboutsummaryrefslogtreecommitdiff
path: root/backends/plugins/elf-provider.cpp
diff options
context:
space:
mode:
authorTony Puccinelli2010-08-03 06:25:03 +0000
committerTony Puccinelli2010-08-03 06:25:03 +0000
commit934c0b922c3927a203f2027f73a472fff5c48d4b (patch)
treeef48b2b212c7a8af37dbddee2a9adabe33203d29 /backends/plugins/elf-provider.cpp
parentd889a706f20c7d37ab56feb182fe14d04fb2cd4f (diff)
downloadscummvm-rg350-934c0b922c3927a203f2027f73a472fff5c48d4b.tar.gz
scummvm-rg350-934c0b922c3927a203f2027f73a472fff5c48d4b.tar.bz2
scummvm-rg350-934c0b922c3927a203f2027f73a472fff5c48d4b.zip
got rid of dlopen, dlclose, etc. wrappers
svn-id: r51677
Diffstat (limited to 'backends/plugins/elf-provider.cpp')
-rw-r--r--backends/plugins/elf-provider.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/backends/plugins/elf-provider.cpp b/backends/plugins/elf-provider.cpp
index b623f0d881..4d4c66084d 100644
--- a/backends/plugins/elf-provider.cpp
+++ b/backends/plugins/elf-provider.cpp
@@ -31,6 +31,7 @@
#include "backends/plugins/elf-loader.h"
+static char dlerr[MAXDLERRLEN];
class ELFPlugin : public DynamicPlugin {
protected:
@@ -38,9 +39,15 @@ protected:
Common::String _filename;
virtual VoidFunc findSymbol(const char *symbol) {
- void *func = dlsym(_dlHandle, symbol);
+ void *func;
+ if (_dlHandle == NULL) {
+ strcpy(dlerr, "Handle is NULL.");
+ func = NULL;
+ } else {
+ func = ((DLObject *)_dlHandle)->symbol(symbol);
+ }
if (!func)
- warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.c_str(), dlerror());
+ warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.c_str(), dlerr);
// FIXME HACK: This is a HACK to circumvent a clash between the ISO C++
// standard and POSIX: ISO C++ disallows casting between function pointers
@@ -62,17 +69,25 @@ public:
bool loadPlugin() {
assert(!_dlHandle);
- _dlHandle = dlopen(_filename.c_str(), RTLD_LAZY);
+ DLObject *obj = new DLObject(dlerr);
+ if (obj->open(_filename.c_str())) {
+ _dlHandle = (void *)obj;
+ } else {
+ delete obj;
+ _dlHandle = NULL;
+ }
if (!_dlHandle) {
- warning("Failed loading plugin '%s' (%s)", _filename.c_str(), dlerror());
+ warning("Failed loading plugin '%s' (%s)", _filename.c_str(), dlerr);
return false;
}
bool ret = DynamicPlugin::loadPlugin();
- if (ret)
- dlforgetsyms(_dlHandle);
+ if (ret) {
+ if (_dlHandle != NULL)
+ ((DLObject *)_dlHandle)->discard_symtab();
+ }
return ret;
}
@@ -80,8 +95,15 @@ public:
void unloadPlugin() {
DynamicPlugin::unloadPlugin();
if (_dlHandle) {
- if (dlclose(_dlHandle) != 0)
- warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());
+ DLObject *obj = (DLObject *)_dlHandle;
+ if (obj == NULL) {
+ strcpy(dlerr, "Handle is NULL.");
+ warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerr);
+ } else if (obj->close()) {
+ delete obj;
+ } else {
+ warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerr);
+ }
_dlHandle = 0;
}
}