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)!"




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296774 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vassil Vassilev
2017-03-02 17:56:45 +00:00
parent 3f339ad775
commit 3983dc252d
3 changed files with 35 additions and 0 deletions
+12
View File
@@ -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;