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.
/* -----------------------------------------------------------------------------
- * $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"
# 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
}