[commit: ghc] master: Have the RTS linker search symbols in the originating windows binary. (d2f0100)

git at git.haskell.org git at git.haskell.org
Tue Aug 19 04:34:27 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/d2f01000ac07678b971743ebf1650837aad19b9f/ghc

>---------------------------------------------------------------

commit d2f01000ac07678b971743ebf1650837aad19b9f
Author: Facundo Domínguez <facundo.dominguez at tweag.io>
Date:   Mon Aug 18 21:50:33 2014 -0500

    Have the RTS linker search symbols in the originating windows binary.
    
    Summary: In initLinker, this patch adds the handle of the module corresponding to the program binary to the list of DLL handles that lookupSymbol uses to search for symbols.
    
    Test Plan: validate
    
    Reviewers: simonmar, austin
    
    Reviewed By: simonmar, austin
    
    Subscribers: phaskell, simonmar, relrod, ezyang, carter
    
    Differential Revision: https://phabricator.haskell.org/D103
    
    GHC Trac Issues: #9382


>---------------------------------------------------------------

d2f01000ac07678b971743ebf1650837aad19b9f
 rts/Linker.c              | 20 ++++++++++++++------
 testsuite/tests/rts/all.T |  4 +---
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/rts/Linker.c b/rts/Linker.c
index a0ad90c..0a81b83 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1592,6 +1592,8 @@ static regex_t re_realso;
 #ifdef THREADED_RTS
 static Mutex dl_mutex; // mutex to protect dlopen/dlerror critical section
 #endif
+#elif defined(OBJFORMAT_PEi386)
+void addDLLHandle(pathchar* dll_name, HINSTANCE instance);
 #endif
 
 void initLinker (void)
@@ -1689,6 +1691,7 @@ initLinker_ (int retain_cafs)
      */
     addDLL(WSTR("msvcrt"));
     addDLL(WSTR("kernel32"));
+    addDLLHandle(WSTR("*.exe"), GetModuleHandle(NULL));
 #endif
 
     IF_DEBUG(linker, debugBelch("initLinker: done\n"));
@@ -1753,6 +1756,16 @@ typedef
 /* A list thereof. */
 static IndirectAddr* indirects = NULL;
 
+/* Adds a DLL instance to the list of DLLs in which to search for symbols. */
+void addDLLHandle(pathchar* dll_name, HINSTANCE instance) {
+   OpenedDLL* o_dll;
+   o_dll = stgMallocBytes( sizeof(OpenedDLL), "addDLLHandle" );
+   o_dll->name     = dll_name ? pathdup(dll_name) : NULL;
+   o_dll->instance = instance;
+   o_dll->next     = opened_dlls;
+   opened_dlls     = o_dll;
+}
+
 #endif
 
 #  if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO)
@@ -1960,12 +1973,7 @@ addDLL( pathchar *dll_name )
    }
    stgFree(buf);
 
-   /* Add this DLL to the list of DLLs in which to search for symbols. */
-   o_dll = stgMallocBytes( sizeof(OpenedDLL), "addDLL" );
-   o_dll->name     = pathdup(dll_name);
-   o_dll->instance = instance;
-   o_dll->next     = opened_dlls;
-   opened_dlls     = o_dll;
+   addDLLHandle(dll_name, instance);
 
    return NULL;
 
diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T
index e9d3ff9..59114bd 100644
--- a/testsuite/tests/rts/all.T
+++ b/testsuite/tests/rts/all.T
@@ -231,9 +231,7 @@ test('T9045', [ omit_ways(['ghci']), extra_run_opts('10000 +RTS -A8k -RTS') ], c
 # with the non-threaded one.
 test('T9078', [ omit_ways(threaded_ways) ], compile_and_run, ['-with-rtsopts="-DS" -debug'])
 
-# -rdynamic is implemented in windows, but the RTS linker does
-# not pickup yet the symbols exported in executables.
-test('rdynamic', unless(opsys('linux'), skip),
+test('rdynamic', unless(opsys('linux') or opsys('mingw32'), skip),
      compile_and_run, ['-rdynamic -package ghc'])
 
 # 251 = RTS exit code for "out of memory"



More information about the ghc-commits mailing list