hacky way to put ELFPlugin::findSymbol in elf-provider.cpp without compiler errors
svn-id: r51775
This commit is contained in:
parent
9369c769fe
commit
415a5aaa36
2 changed files with 28 additions and 28 deletions
|
@ -31,6 +31,33 @@
|
||||||
|
|
||||||
#if defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET)
|
#if defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET)
|
||||||
|
|
||||||
|
void (* ELFPlugin::findSymbol(const char *symbol))() {
|
||||||
|
void *func;
|
||||||
|
bool handleNull;
|
||||||
|
if (_dlHandle == NULL) {
|
||||||
|
func = NULL;
|
||||||
|
handleNull = true;
|
||||||
|
} else {
|
||||||
|
func = _dlHandle->symbol(symbol);
|
||||||
|
}
|
||||||
|
if (!func) {
|
||||||
|
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++
|
||||||
|
// standard and POSIX: ISO C++ disallows casting between function pointers
|
||||||
|
// and data pointers, but dlsym always returns a void pointer. For details,
|
||||||
|
// see e.g. <http://www.trilithium.com/johan/2004/12/problem-with-dlsym/>.
|
||||||
|
assert(sizeof(VoidFunc) == sizeof(func));
|
||||||
|
VoidFunc tmp;
|
||||||
|
memcpy(&tmp, &func, sizeof(VoidFunc));
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
bool ELFPlugin::loadPlugin() {
|
bool ELFPlugin::loadPlugin() {
|
||||||
assert(!_dlHandle);
|
assert(!_dlHandle);
|
||||||
DLObject *obj = new DLObject(NULL);
|
DLObject *obj = new DLObject(NULL);
|
||||||
|
|
|
@ -39,34 +39,7 @@ protected:
|
||||||
DLObject *_dlHandle;
|
DLObject *_dlHandle;
|
||||||
Common::String _filename;
|
Common::String _filename;
|
||||||
|
|
||||||
//FIXME: The code for this method should be in elf-provider.cpp,
|
virtual VoidFunc findSymbol(const char *symbol);
|
||||||
// but VoidFunc isn't recognized if we do that as is.
|
|
||||||
virtual VoidFunc findSymbol(const char *symbol) {
|
|
||||||
void *func;
|
|
||||||
bool handleNull;
|
|
||||||
if (_dlHandle == NULL) {
|
|
||||||
func = NULL;
|
|
||||||
handleNull = true;
|
|
||||||
} else {
|
|
||||||
func = _dlHandle->symbol(symbol);
|
|
||||||
}
|
|
||||||
if (!func) {
|
|
||||||
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++
|
|
||||||
// standard and POSIX: ISO C++ disallows casting between function pointers
|
|
||||||
// and data pointers, but dlsym always returns a void pointer. For details,
|
|
||||||
// see e.g. <http://www.trilithium.com/johan/2004/12/problem-with-dlsym/>.
|
|
||||||
assert(sizeof(VoidFunc) == sizeof(func));
|
|
||||||
VoidFunc tmp;
|
|
||||||
memcpy(&tmp, &func, sizeof(VoidFunc));
|
|
||||||
return tmp;;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ELFPlugin(const Common::String &filename)
|
ELFPlugin(const Common::String &filename)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue