[llvm] r216563 - Limit the symbol search in DynamicLibrary to the module that was opened.
Zachary Turner
zturner at google.com
Wed Aug 27 10:06:22 PDT 2014
Author: zturner
Date: Wed Aug 27 12:06:22 2014
New Revision: 216563
URL: http://llvm.org/viewvc/llvm-project?rev=216563&view=rev
Log:
Limit the symbol search in DynamicLibrary to the module that was opened.
Differential Revision: http://reviews.llvm.org/D5030
Reviewed By: Reid Kleckner, Rafael Espindola
Modified:
llvm/trunk/lib/Support/DynamicLibrary.cpp
Modified: llvm/trunk/lib/Support/DynamicLibrary.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DynamicLibrary.cpp?rev=216563&r1=216562&r2=216563&view=diff
==============================================================================
--- llvm/trunk/lib/Support/DynamicLibrary.cpp (original)
+++ llvm/trunk/lib/Support/DynamicLibrary.cpp Wed Aug 27 12:06:22 2014
@@ -56,8 +56,15 @@ static DenseSet<void *> *OpenedHandles =
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
std::string *errMsg) {
SmartScopedLock<true> lock(*SymbolsMutex);
-
- void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
+ int flags = RTLD_LAZY | RTLD_GLOBAL;
+#if defined(__APPLE__)
+ // RTLD_FIRST is an apple specific flag which causes dlsym() to search only
+ // the module specified in |filename|, and not dependent modules. This
+ // behavior would be desirable for other platforms as well, except that
+ // there's not a good way to implement it.
+ flags |= RTLD_FIRST;
+#endif
+ void *handle = dlopen(filename, flags);
if (!handle) {
if (errMsg) *errMsg = dlerror();
return DynamicLibrary();
More information about the llvm-commits
mailing list