[commit: ghc] ghc-8.2: Fix loading of dlls on 32bit windows (5a1ae9e)

git at git.haskell.org git at git.haskell.org
Fri Aug 25 19:11:33 UTC 2017


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

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/5a1ae9e32535fe4a891a515d44dd13968161ff27/ghc

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

commit 5a1ae9e32535fe4a891a515d44dd13968161ff27
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
    
    (cherry picked from commit 34bd43d9c24207a1897aaa4ee6cb70592a3f7acc)


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

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

diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
index c27dd31..bb10900 100644
--- a/rts/linker/PEi386.c
+++ b/rts/linker/PEi386.c
@@ -156,6 +156,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