[commit: ghc] master: Fix loading of dlls on 32bit windows (34bd43d)

git at git.haskell.org git at git.haskell.org
Mon Aug 21 16:24:13 UTC 2017


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

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

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

commit 34bd43d9c24207a1897aaa4ee6cb70592a3f7acc
Author: Sergey Vinokurov <serg.foo at gmail.com>
Date:   Mon Aug 21 00:40:08 2017 +0300

    Fix loading of dlls on 32bit windows
    
    The point of fix is to handle case when loaded dll loads no
    other dlls, i.e. it's import table is empty.
    
    GHC Trac Issues: #14081


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

34bd43d9c24207a1897aaa4ee6cb70592a3f7acc
 rts/linker/PEi386.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
index 42e7008..011b0a8 100644
--- a/rts/linker/PEi386.c
+++ b/rts/linker/PEi386.c
@@ -240,6 +240,13 @@ static void addDLLHandle(pathchar* dll_name, HINSTANCE instance) {
         (PIMAGE_IMPORT_DESCRIPTOR)((BYTE *)instance + header->
         OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
 
+    bool importTableMissing =
+        header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size == 0;
+
+    if (importTableMissing) {
+        return;
+    }
+
     /* Ignore these compatibility shims.  */
     const pathchar* ms_dll = WSTR("api-ms-win-");
     const int len = wcslen(ms_dll);



More information about the ghc-commits mailing list