aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/DynamicLibrary.cpp
diff options
context:
space:
mode:
authorVassil Vassilev <v.g.vassilev@gmail.com>2017-03-02 17:56:45 +0000
committerVassil Vassilev <v.g.vassilev@gmail.com>2017-03-02 17:56:45 +0000
commit7f1c255dfe8e6559c6181901a1420b3e06ef2a5c (patch)
tree3c0ea16a147d7abe2f1127a78bee45881d7606c3 /llvm/lib/Support/DynamicLibrary.cpp
parent8139eab3c3b50155e5333f201745765e9492e3d3 (diff)
downloadllvm-7f1c255dfe8e6559c6181901a1420b3e06ef2a5c.zip
llvm-7f1c255dfe8e6559c6181901a1420b3e06ef2a5c.tar.gz
llvm-7f1c255dfe8e6559c6181901a1420b3e06ef2a5c.tar.bz2
Reland r296442 with modifications reverted in r296463.
Original commit message: "Allow externally dlopen-ed libraries to be registered as permanent libraries. This is also useful in cases when llvm is in a shared library. First we dlopen the llvm shared library and then we register it as a permanent library in order to keep the JIT and other services working. Patch reviewed by Vedant Kumar (D29955)!" llvm-svn: 296774
Diffstat (limited to 'llvm/lib/Support/DynamicLibrary.cpp')
-rw-r--r--llvm/lib/Support/DynamicLibrary.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Support/DynamicLibrary.cpp b/llvm/lib/Support/DynamicLibrary.cpp
index 74d94d3..92ce618 100644
--- a/llvm/lib/Support/DynamicLibrary.cpp
+++ b/llvm/lib/Support/DynamicLibrary.cpp
@@ -76,6 +76,18 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
return DynamicLibrary(handle);
}
+DynamicLibrary DynamicLibrary::addPermanentLibrary(void *handle,
+ std::string *errMsg) {
+ SmartScopedLock<true> lock(*SymbolsMutex);
+ // If we've already loaded this library, tell the caller.
+ if (!OpenedHandles->insert(handle).second) {
+ if (errMsg) *errMsg = "Library already loaded";
+ return DynamicLibrary();
+ }
+
+ return DynamicLibrary(handle);
+}
+
void *DynamicLibrary::getAddressOfSymbol(const char *symbolName) {
if (!isValid())
return nullptr;