#include "Support/DynamicLinker.h"
#include "Config/dlfcn.h"
#include <cassert>
+using namespace llvm;
-bool LinkDynamicObject (const char *filename, std::string *ErrorMessage) {
+bool llvm::LinkDynamicObject (const char *filename, std::string *ErrorMessage) {
#if defined (HAVE_DLOPEN)
if (dlopen (filename, RTLD_NOW | RTLD_GLOBAL) == 0) {
if (ErrorMessage) *ErrorMessage = dlerror ();
#endif
}
-void *GetAddressOfSymbol (const char *symbolName) {
+void *llvm::GetAddressOfSymbol (const char *symbolName) {
#if defined (HAVE_DLOPEN)
+#ifdef RTLD_DEFAULT
return dlsym (RTLD_DEFAULT, symbolName);
+#else
+ static void* CurHandle = dlopen(0, RTLD_LAZY);
+ return dlsym(CurHandle, symbolName);
+#endif
#else
assert (0 && "Dynamic symbol lookup not implemented for this platform");
#endif
}
// soft, cushiony C++ interface.
-void *GetAddressOfSymbol (const std::string &symbolName) {
+void *llvm::GetAddressOfSymbol (const std::string &symbolName) {
return GetAddressOfSymbol (symbolName.c_str ());
}