diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index a661dd49b51..74a3c867ed7 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -362,12 +362,13 @@ void ExecutionEngine::emitGlobals() { // External variable reference, try to use dlsym to get a pointer to it in // the LLI image. #if defined(sparc) || defined(__sparc__) || defined(__sparcv9) + // RTLD_SELF is already defined and it's not zero +#else + // Linux/x86 wants to use a 0, other systems may differ +#define RTLD_SELF 0 +#endif if (void *SymAddr = dlsym(RTLD_SELF, I->getName().c_str())) GlobalAddress[I] = SymAddr; -#else - if (void *SymAddr = dlsym(0, I->getName().c_str())) - GlobalAddress[I] = SymAddr; -#endif else { std::cerr << "Could not resolve external global address: " << I->getName() << "\n";