[project @ 2004-01-05 17:32:35 by simonmar]
authorsimonmar <unknown>
Mon, 5 Jan 2004 17:32:35 +0000 (17:32 +0000)
committersimonmar <unknown>
Mon, 5 Jan 2004 17:32:35 +0000 (17:32 +0000)
Instead of grabbing the handle to the executable by calling
dlopen(NULL,...), use RTLD_DEFAULT as the handle to lookup symbols if
it is available.  It seems that RTLD_DEFAULT may be required on
certain systems, although I'm not sure it is available everywhere, so
I've left the old code as fallback in case it isn't available.

ghc/rts/Linker.c

index 738791c..c20d23b 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Linker.c,v 1.143 2003/12/23 10:10:53 simonmar Exp $
+ * $Id: Linker.c,v 1.144 2004/01/05 17:32:35 simonmar Exp $
  *
  * (c) The GHC Team, 2000-2003
  *
 #if 0
 #include "PosixSource.h"
 #endif
+
+//  Linux needs _GNU_SOURCE to get RTLD_DEFAULT from <dlfcn.h>.
+#ifdef __linux__
+#define _GNU_SOURCE
+#endif
+
 #include "Rts.h"
 #include "RtsFlags.h"
 #include "HsFFI.h"
@@ -697,7 +703,11 @@ initLinker( void )
 #   endif
 
 #   if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO)
+#   if defined(RTLD_DEFAULT)    
+    dl_prog_handle = RTLD_DEFAULT;
+#   else
     dl_prog_handle = dlopen(NULL, RTLD_LAZY);
+#   endif // RTLD_DEFAULT
 #   endif
 }