Commit 069495a3 authored by Don Stewart's avatar Don Stewart
Browse files

Use --export-dynamic to ensure ghci works on newer openbsds

Changes to the RTLD_DEFAULT semantics broke the trick we used to ensure
libc symbols were available to the ghci linker, in OpenBSD 4.0. We can
fix this by linking the ghc binary itself with --export-dynamic on this
system, removing the need for any magic Linker.c games.

GHCi now works on OpenBSD 4.0

Contributed by Eric Mertens <emertens at gmail.com>
parent 712a6f8a
......@@ -18,6 +18,9 @@ SRC_HC_OPTS += \
-cpp -fglasgow-exts -fno-generics -Rghc-timing \
-I. -IcodeGen -InativeGen -Iparser
SRC_HC_OPTS += $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
ifeq "$(TargetOS_CPP)" "openbsd"
SRC_HC_OPTS += -optl-Xlinker -optl-E
endif
ifeq "$(GhcWithInterpreter)" "YES"
SRC_HC_OPTS += -DGHCI -DBREAKPOINT
......
......@@ -941,11 +941,6 @@ static int linker_init_done = 0 ;
static void *dl_prog_handle;
#endif
/* dlopen(NULL,..) doesn't work so we grab libc explicitly */
#if defined(openbsd_HOST_OS)
static void *dl_libc_handle;
#endif
void
initLinker( void )
{
......@@ -975,9 +970,6 @@ initLinker( void )
dl_prog_handle = RTLD_DEFAULT;
# else
dl_prog_handle = dlopen(NULL, RTLD_LAZY);
# if defined(openbsd_HOST_OS)
dl_libc_handle = dlopen("libc.so", RTLD_LAZY);
# endif
# endif /* RTLD_DEFAULT */
# endif
}
......@@ -1128,10 +1120,7 @@ lookupSymbol( char *lbl )
if (val == NULL) {
# if defined(OBJFORMAT_ELF)
# if defined(openbsd_HOST_OS)
val = dlsym(dl_prog_handle, lbl);
return (val != NULL) ? val : dlsym(dl_libc_handle,lbl);
# elif defined(x86_64_HOST_ARCH)
# if defined(x86_64_HOST_ARCH)
val = dlsym(dl_prog_handle, lbl);
if (val >= (void *)0x80000000) {
void *new_val;
......@@ -1141,7 +1130,7 @@ lookupSymbol( char *lbl )
} else {
return val;
}
# else /* not openbsd */
# else
return dlsym(dl_prog_handle, lbl);
# endif
# elif defined(OBJFORMAT_MACHO)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment