summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-10-21 11:15:55 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2014-12-02 14:38:36 +0100
commit864cf2a6cd658e4b98e1248e9aaab6fe6afc038f (patch)
tree61ca5ea284c9155af09c0d10d1af0989306e9137 /src/corelib
parentf6eb3c220b17ecb56befe1a1ea2241ca6d5ab0c8 (diff)
Add DeepBind option to QLibrary
Adds an option to request the RTLD_DEEPBIND flag to dlopen. On Linux this can be used to force a library to resolve global symbols locally instead of using the similarly named symbols already loaded. This makes it possible to load and use plugins linked against Qt 4 without crashing. [ChangeLog][QtCore][QLibrary] Added DeepBindHint which maps to RTLD_DEEPBIND on Linux making it possible to load libraries with external symbols that clash with already loaded ones, such as plugins linked to Qt4. Change-Id: I4edb4af68e4a47e932a87d108360dba8d91dc34a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/plugin/qlibrary.cpp5
-rw-r--r--src/corelib/plugin/qlibrary.h3
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp4
3 files changed, 11 insertions, 1 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 7bc6d1cc47..c9ce5c342e 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -168,6 +168,11 @@ QT_BEGIN_NAMESPACE
Prevents the library from being unloaded from the address space if close()
is called. The library's static variables are not reinitialized if open()
is called at a later time.
+ \value DeepBindHint
+ Instructs the linker to prefer definitions in the loaded library
+ over exported definitions in the loading application when resolving
+ external symbols in the loaded library. This option is only supported
+ on Linux.
\sa loadHints
*/
diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h
index 77fe432761..327af8aada 100644
--- a/src/corelib/plugin/qlibrary.h
+++ b/src/corelib/plugin/qlibrary.h
@@ -53,7 +53,8 @@ public:
ResolveAllSymbolsHint = 0x01,
ExportExternalSymbolsHint = 0x02,
LoadArchiveMemberHint = 0x04,
- PreventUnloadHint = 0x08
+ PreventUnloadHint = 0x08,
+ DeepBindHint = 0x10
};
Q_DECLARE_FLAGS(LoadHints, LoadHint)
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index 4f96f3bccf..b178c173c5 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -171,6 +171,10 @@ bool QLibraryPrivate::load_sys()
dlFlags |= RTLD_LOCAL;
}
#endif
+#if defined(RTLD_DEEPBIND)
+ if (loadHints & QLibrary::DeepBindHint)
+ dlFlags |= RTLD_DEEPBIND;
+#endif
// Provide access to RTLD_NODELETE flag on Unix
// From GNU documentation on RTLD_NODELETE: