summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2014-08-27 17:06:22 +0000
committerZachary Turner <zturner@google.com>2014-08-27 17:06:22 +0000
commit0611d0141919bd8edf62ed043814a5d175177241 (patch)
tree4a49aa227d4e3a07b66076d6f7a119a70aed16f8
parent8bf410fafae2496f48578fad0bee9a6503693d1b (diff)
downloadbcm5719-llvm-0611d0141919bd8edf62ed043814a5d175177241.tar.gz
bcm5719-llvm-0611d0141919bd8edf62ed043814a5d175177241.zip
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 llvm-svn: 216563
-rw-r--r--llvm/lib/Support/DynamicLibrary.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Support/DynamicLibrary.cpp b/llvm/lib/Support/DynamicLibrary.cpp
index d2b551e8a0a..40072636608 100644
--- a/llvm/lib/Support/DynamicLibrary.cpp
+++ b/llvm/lib/Support/DynamicLibrary.cpp
@@ -56,8 +56,15 @@ static DenseSet<void *> *OpenedHandles = nullptr;
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();
OpenPOWER on IntegriCloud