From c1d326be1992fccf8efe465b78b5735eb37d2265 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Wed, 12 Nov 2008 11:15:18 +0000 Subject: [PATCH] Always zap the trailing @N from symbols when looking up in a DLL Fixes win32002(ghci) Previously we only did this for references from object files, but we should do it for all symbols, including those that GHCi looks up due to FFI calls from bytecode. --- rts/Linker.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rts/Linker.c b/rts/Linker.c index c73fbec..e32d324 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -115,6 +115,7 @@ static int ocAllocateSymbolExtras_ELF ( ObjectCode* oc ); static int ocVerifyImage_PEi386 ( ObjectCode* oc ); static int ocGetNames_PEi386 ( ObjectCode* oc ); static int ocResolve_PEi386 ( ObjectCode* oc ); +static void zapTrailingAtSign ( unsigned char* sym ); #elif defined(OBJFORMAT_MACHO) static int ocVerifyImage_MachO ( ObjectCode* oc ); static int ocGetNames_MachO ( ObjectCode* oc ); @@ -1179,6 +1180,9 @@ lookupSymbol( char *lbl ) # elif defined(OBJFORMAT_PEi386) OpenedDLL* o_dll; void* sym; + + zapTrailingAtSign ( lbl ); + for (o_dll = opened_dlls; o_dll != NULL; o_dll = o_dll->next) { /* debugBelch("look in %s for %s\n", o_dll->name, lbl); */ if (lbl[0] == '_') { @@ -2532,9 +2536,6 @@ ocResolve_PEi386 ( ObjectCode* oc ) copyName ( sym->Name, strtab, symbol, 1000-1 ); S = (UInt32) lookupSymbol( symbol ); if ((void*)S != NULL) goto foundit; - zapTrailingAtSign ( symbol ); - S = (UInt32) lookupSymbol( symbol ); - if ((void*)S != NULL) goto foundit; /* Newline first because the interactive linker has printed "linking..." */ errorBelch("\n%s: unknown symbol `%s'", oc->fileName, symbol); return 0; -- 1.7.10.4