loadArchive: need to allocate executable memory on Win32 (#5371)
authorSimon Marlow <marlowsd@gmail.com>
Wed, 30 Nov 2011 15:34:00 +0000 (15:34 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Thu, 1 Dec 2011 11:29:53 +0000 (11:29 +0000)
rts/Linker.c

index 96a0741..cf2d85a 100644 (file)
@@ -1997,6 +1997,11 @@ loadArchive( char *path )
                we could do better. */
 #if defined(USE_MMAP)
             image = mmapForLinker(memberSize, MAP_ANONYMOUS, -1);
+#elif defined(mingw32_HOST_OS)
+        // TODO: We would like to use allocateExec here, but allocateExec
+        //       cannot currently allocate blocks large enough.
+            image = VirtualAlloc(NULL, memberSize, MEM_RESERVE | MEM_COMMIT,
+                                 PAGE_EXECUTE_READWRITE);
 #elif defined(darwin_HOST_OS)
             /* See loadObj() */
             misalignment = machoGetMisalignment(f);