From 069495a32aacd7a1f0d543eea81a49c2776c6ede Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Thu, 21 Sep 2006 01:01:55 +0000 Subject: [PATCH] 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 --- compiler/Makefile.ghcbin | 3 +++ rts/Linker.c | 15 ++------------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/compiler/Makefile.ghcbin b/compiler/Makefile.ghcbin index 6d4cbc8..41f0858 100644 --- a/compiler/Makefile.ghcbin +++ b/compiler/Makefile.ghcbin @@ -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 diff --git a/rts/Linker.c b/rts/Linker.c index 933f4dd..93fca03 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -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) -- 1.7.10.4