Check .rela instead of ELF64 for the compensation vaue resetting
[oota-llvm.git] / lib / Support / DynamicLibrary.cpp
index 63298b99a0c987c1fb6f1bad31cb8aadbb7a03fb..45fec361c1a6cf26b1768f10032c025fbfe62be4 100644 (file)
@@ -50,6 +50,8 @@ void llvm::sys::DynamicLibrary::AddSymbol(StringRef symbolName,
   (*ExplicitSymbols)[symbolName] = symbolValue;
 }
 
+char llvm::sys::DynamicLibrary::Invalid = 0;
+
 #ifdef LLVM_ON_WIN32
 
 #include "Windows/DynamicLibrary.inc"
@@ -70,6 +72,8 @@ static DenseSet<void *> *OpenedHandles = 0;
 
 DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
                                                    std::string *errMsg) {
+  SmartScopedLock<true> lock(getMutex());
+
   void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
   if (handle == 0) {
     if (errMsg) *errMsg = dlerror();
@@ -83,7 +87,6 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
     handle = RTLD_DEFAULT;
 #endif
 
-  SmartScopedLock<true> lock(getMutex());
   if (OpenedHandles == 0)
     OpenedHandles = new DenseSet<void *>();
 
@@ -157,7 +160,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
 // On linux we have a weird situation. The stderr/out/in symbols are both
 // macros and global variables because of standards requirements. So, we
 // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
-#if defined(__linux__)
+#if defined(__linux__) and !defined(__ANDROID__)
   {
     EXPLICIT_SYMBOL(stderr);
     EXPLICIT_SYMBOL(stdout);