Always zap the trailing @N from symbols when looking up in a DLL
authorSimon Marlow <marlowsd@gmail.com>
Wed, 12 Nov 2008 11:15:18 +0000 (11:15 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 12 Nov 2008 11:15:18 +0000 (11:15 +0000)
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

index c73fbec..e32d324 100644 (file)
@@ -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;