aboutsummaryrefslogtreecommitdiff
path: root/backends/plugins/elf-provider.cpp
diff options
context:
space:
mode:
authorTony Puccinelli2010-08-06 01:36:47 +0000
committerTony Puccinelli2010-08-06 01:36:47 +0000
commit415a5aaa363634d76c3b75bf76a51172166e2306 (patch)
tree678e231397e38c1ab135c8f477a80b3c00fe2b36 /backends/plugins/elf-provider.cpp
parent9369c769fe3c9741f5b1aa8ae7552c108e5ed94d (diff)
downloadscummvm-rg350-415a5aaa363634d76c3b75bf76a51172166e2306.tar.gz
scummvm-rg350-415a5aaa363634d76c3b75bf76a51172166e2306.tar.bz2
scummvm-rg350-415a5aaa363634d76c3b75bf76a51172166e2306.zip
hacky way to put ELFPlugin::findSymbol in elf-provider.cpp without compiler errors
svn-id: r51775
Diffstat (limited to 'backends/plugins/elf-provider.cpp')
-rw-r--r--backends/plugins/elf-provider.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/backends/plugins/elf-provider.cpp b/backends/plugins/elf-provider.cpp
index 08ef7899d2..43f999b461 100644
--- a/backends/plugins/elf-provider.cpp
+++ b/backends/plugins/elf-provider.cpp
@@ -31,6 +31,33 @@
#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() {
assert(!_dlHandle);
DLObject *obj = new DLObject(NULL);