summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2012-05-07 15:27:13 +0100
committerIan Lynagh <igloo@earth.li>2012-05-07 15:27:13 +0100
commit85ae01ba38d06af2715a39b8f371b4e166c9fabd (patch)
tree927612c120194eb1e9eec3d444b65be62699cf76 /rts
parentada138569326adf704a8b17ad8aa1ecbf2216f43 (diff)
downloadhaskell-85ae01ba38d06af2715a39b8f371b4e166c9fabd.tar.gz
Fix alignment when loading .a files on Win64
Diffstat (limited to 'rts')
-rw-r--r--rts/Linker.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 62096e69c9..6486d4de98 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -2283,8 +2283,23 @@ loadArchive( pathchar *path )
#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);
+ {
+ int offset;
+#if defined(x86_64_HOST_ARCH)
+ /* We get back 8-byte aligned memory (is that guaranteed?), but
+ the offsets to the sections within the file are all 4 mod 8
+ (is that guaranteed?). We therefore need to offset the image
+ by 4, so that all the pointers are 8-byte aligned, so that
+ pointer tagging works. */
+ offset = 4;
+#else
+ offset = 0;
+#endif
+ image = VirtualAlloc(NULL, memberSize + offset,
+ MEM_RESERVE | MEM_COMMIT,
+ PAGE_EXECUTE_READWRITE);
+ image += offset;
+ }
#elif defined(darwin_HOST_OS)
/* See loadObj() */
misalignment = machoGetMisalignment(f);