From 9d9784263ae1cb1d2add4b714ca676ca4b6cc22c Mon Sep 17 00:00:00 2001 From: sof Date: Fri, 20 Jul 2001 01:05:11 +0000 Subject: [PATCH] [project @ 2001-07-20 01:05:11 by sof] lookupSymbol (PEi386-only): When chasing down a label in a DLL, try removing the initial underscore (if any). I've prefixed the comment next to the change with the label 'HACK', as I'm not sure whether this is a name mangling operation you should always do when going from the import library name to the DLL-bound thing. (Julian, could you have a look?) Fixes probs with 'foreign import'ing DLL-bound symbols. --- ghc/rts/Linker.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ghc/rts/Linker.c b/ghc/rts/Linker.c index 6c43d7d..a376c53 100644 --- a/ghc/rts/Linker.c +++ b/ghc/rts/Linker.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Linker.c,v 1.51 2001/07/20 00:44:33 sof Exp $ + * $Id: Linker.c,v 1.52 2001/07/20 01:05:11 sof Exp $ * * (c) The GHC Team, 2000 * @@ -502,6 +502,15 @@ lookupSymbol( char *lbl ) void* sym; for (o_dll = opened_dlls; o_dll != NULL; o_dll = o_dll->next) { /* fprintf(stderr, "look in %s for %s\n", o_dll->name, lbl); */ + if (lbl[0] == '_') { + /* HACK: if the name has an initial underscore, try stripping + it off & look that up first. I've yet to verify whether there's + a Rule that governs whether an initial '_' *should always* be + stripped off when mapping from import lib name to the DLL name. + */ + sym = GetProcAddress(o_dll->instance, (lbl+1)); + if (sym != NULL) return sym; + } sym = GetProcAddress(o_dll->instance, lbl); if (sym != NULL) return sym; } -- 1.7.10.4