summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorYan Shapochnik <shapochniky@seapine.com>2012-04-20 08:41:18 -0400
committerQt by Nokia <qt-info@nokia.com>2012-04-24 19:37:13 +0200
commit33a4e3b4706e6819f4471fc431436ec69bee1d33 (patch)
tree387c08af51296475f9d8540a42ea68c83249eddc /src/corelib
parent0723e14699704c35d5d61fa7f5e9f3bdbb378afa (diff)
Provide access to RTLD_NODELETE flag on Unix.
Introduce a new QLibrary::PreventUnloadHint to support the RTLD_NODELETE flag support by dlcompat on Unix platforms. Change-Id: Ib1327e968a2a888850ad1086a102a143f86c5090 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/plugin/qlibrary.cpp6
-rw-r--r--src/corelib/plugin/qlibrary.h3
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp12
3 files changed, 20 insertions, 1 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 7bb1ef1263..a704b8f02d 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -163,6 +163,10 @@ static QBasicMutex qt_library_mutex;
If this hint is given, the filename of the library consists of
a path, which is a reference to an archive file, followed by
a reference to the archive member.
+ \value PreventUnloadHint
+ 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.
\sa loadHints
*/
@@ -1230,6 +1234,8 @@ QString QLibrary::errorString() const
to the library \c shr_64.o in the archive file named \c libGL.a. This
is only supported on the AIX platform.
+ Setting PreventUnloadHint will only apply on Unix platforms.
+
The interpretation of the load hints is platform dependent, and if
you use it you are probably making some assumptions on which platform
you are compiling for, so use them only if you understand the consequences
diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h
index f373ad06b6..80e6fd3d4c 100644
--- a/src/corelib/plugin/qlibrary.h
+++ b/src/corelib/plugin/qlibrary.h
@@ -68,7 +68,8 @@ public:
enum LoadHint {
ResolveAllSymbolsHint = 0x01,
ExportExternalSymbolsHint = 0x02,
- LoadArchiveMemberHint = 0x04
+ LoadArchiveMemberHint = 0x04,
+ PreventUnloadHint = 0x08
};
Q_DECLARE_FLAGS(LoadHints, LoadHint)
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index cb81440c7e..0ad7a87c97 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -167,6 +167,18 @@ bool QLibraryPrivate::load_sys()
dlFlags |= RTLD_LOCAL;
}
#endif
+
+ // Provide access to RTLD_NODELETE flag on Unix
+ // From GNU documentation on RTLD_NODELETE:
+ // Do not unload the library during dlclose(). Consequently, the
+ // library's specific static variables are not reinitialized if the
+ // library is reloaded with dlopen() at a later time.
+#ifdef RTLD_NODELETE
+ if (loadHints & QLibrary::PreventUnloadHint) {
+ dlFlags |= RTLD_NODELETE;
+ }
+#endif
+
#if defined(Q_OS_AIX) // Not sure if any other platform actually support this thing.
if (loadHints & QLibrary::LoadArchiveMemberHint) {
dlFlags |= RTLD_MEMBER;