X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSystem%2FDynamicLibrary.cpp;h=3da50a28b656b97e12fe768c2d6ce3d20ee2a2f3;hb=87e0697a46ad214be0d8fce0955494f4085de95a;hp=6f6890c06c4997b287963ff9e334935ac65f076f;hpb=b35798347ea87b8b6d36155b211016a7769f01ab;p=oota-llvm.git diff --git a/lib/System/DynamicLibrary.cpp b/lib/System/DynamicLibrary.cpp index 6f6890c06c4..3da50a28b65 100644 --- a/lib/System/DynamicLibrary.cpp +++ b/lib/System/DynamicLibrary.cpp @@ -15,6 +15,7 @@ //===----------------------------------------------------------------------===// #include "llvm/System/DynamicLibrary.h" +#include "llvm/System/Mutex.h" #include "llvm/Config/config.h" #include #include @@ -60,6 +61,7 @@ using namespace llvm::sys; //=== independent code. //===----------------------------------------------------------------------===// +static SmartMutex HandlesMutex; static std::vector *OpenedHandles = 0; @@ -70,6 +72,13 @@ bool DynamicLibrary::LoadLibraryPermanently(const char *Filename, if (ErrMsg) *ErrMsg = dlerror(); return true; } +#ifdef __CYGWIN__ + // Cygwin searches symbols only in the main + // with the handle of dlopen(NULL, RTLD_GLOBAL). + if (Filename == NULL) + H = RTLD_DEFAULT; +#endif + SmartScopedLock Lock(HandlesMutex); if (OpenedHandles == 0) OpenedHandles = new std::vector(); OpenedHandles->push_back(H); @@ -104,6 +113,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { #if HAVE_DLFCN_H // Now search the libraries. + SmartScopedLock Lock(HandlesMutex); if (OpenedHandles) { for (std::vector::iterator I = OpenedHandles->begin(), E = OpenedHandles->end(); I != E; ++I) {