got rid of dlerr[MAXDLERRLEN]
svn-id: r51678
This commit is contained in:
parent
934c0b922c
commit
9be8f0a544
1 changed files with 13 additions and 10 deletions
|
@ -31,8 +31,6 @@
|
||||||
|
|
||||||
#include "backends/plugins/elf-loader.h"
|
#include "backends/plugins/elf-loader.h"
|
||||||
|
|
||||||
static char dlerr[MAXDLERRLEN];
|
|
||||||
|
|
||||||
class ELFPlugin : public DynamicPlugin {
|
class ELFPlugin : public DynamicPlugin {
|
||||||
protected:
|
protected:
|
||||||
void *_dlHandle;
|
void *_dlHandle;
|
||||||
|
@ -40,14 +38,20 @@ protected:
|
||||||
|
|
||||||
virtual VoidFunc findSymbol(const char *symbol) {
|
virtual VoidFunc findSymbol(const char *symbol) {
|
||||||
void *func;
|
void *func;
|
||||||
|
bool handleNull;
|
||||||
if (_dlHandle == NULL) {
|
if (_dlHandle == NULL) {
|
||||||
strcpy(dlerr, "Handle is NULL.");
|
|
||||||
func = NULL;
|
func = NULL;
|
||||||
|
handleNull = true;
|
||||||
} else {
|
} else {
|
||||||
func = ((DLObject *)_dlHandle)->symbol(symbol);
|
func = ((DLObject *)_dlHandle)->symbol(symbol);
|
||||||
}
|
}
|
||||||
if (!func)
|
if (!func) {
|
||||||
warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.c_str(), dlerr);
|
if (handleNull) {
|
||||||
|
warning("Failed loading symbol '%s' from plugin '%s' (Handle is NULL)", symbol, _filename.c_str());
|
||||||
|
} else {
|
||||||
|
warning("Failed loading symbol '%s' from plugin '%s'", symbol, _filename.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME HACK: This is a HACK to circumvent a clash between the ISO C++
|
// FIXME HACK: This is a HACK to circumvent a clash between the ISO C++
|
||||||
// standard and POSIX: ISO C++ disallows casting between function pointers
|
// standard and POSIX: ISO C++ disallows casting between function pointers
|
||||||
|
@ -69,7 +73,7 @@ public:
|
||||||
|
|
||||||
bool loadPlugin() {
|
bool loadPlugin() {
|
||||||
assert(!_dlHandle);
|
assert(!_dlHandle);
|
||||||
DLObject *obj = new DLObject(dlerr);
|
DLObject *obj = new DLObject(NULL);
|
||||||
if (obj->open(_filename.c_str())) {
|
if (obj->open(_filename.c_str())) {
|
||||||
_dlHandle = (void *)obj;
|
_dlHandle = (void *)obj;
|
||||||
} else {
|
} else {
|
||||||
|
@ -78,7 +82,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_dlHandle) {
|
if (!_dlHandle) {
|
||||||
warning("Failed loading plugin '%s' (%s)", _filename.c_str(), dlerr);
|
warning("Failed loading plugin '%s'", _filename.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,12 +101,11 @@ public:
|
||||||
if (_dlHandle) {
|
if (_dlHandle) {
|
||||||
DLObject *obj = (DLObject *)_dlHandle;
|
DLObject *obj = (DLObject *)_dlHandle;
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
strcpy(dlerr, "Handle is NULL.");
|
warning("Failed unloading plugin '%s' (Handle is NULL)", _filename.c_str());
|
||||||
warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerr);
|
|
||||||
} else if (obj->close()) {
|
} else if (obj->close()) {
|
||||||
delete obj;
|
delete obj;
|
||||||
} else {
|
} else {
|
||||||
warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerr);
|
warning("Failed unloading plugin '%s'", _filename.c_str());
|
||||||
}
|
}
|
||||||
_dlHandle = 0;
|
_dlHandle = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue