[PATCH] msvcrt: Fix vtable alignment on macOS.

Ken Thomases ken at codeweavers.com
Wed Mar 6 19:01:32 CST 2019


On macOS, the .align <n> directive aligns to 2^n, not just n.

Signed-off-by: Ken Thomases <ken at codeweavers.com>
---
 dlls/msvcrt/cxx.h | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/dlls/msvcrt/cxx.h b/dlls/msvcrt/cxx.h
index 027026e..7174f7e 100644
--- a/dlls/msvcrt/cxx.h
+++ b/dlls/msvcrt/cxx.h
@@ -42,9 +42,15 @@
 
 #define VTABLE_ADD_FUNC(name) "\t.quad " THISCALL_NAME(name) "\n"
 
+#ifdef __APPLE__
+#define __ASM_VTABLE_ALIGN ".align 3"
+#else
+#define __ASM_VTABLE_ALIGN ".align 8"
+#endif
+
 #define __ASM_VTABLE(name,funcs) \
     __asm__(".data\n" \
-            "\t.align 8\n" \
+            "\t" __ASM_VTABLE_ALIGN "\n" \
             "\t.quad " __ASM_NAME(#name "_rtti") "\n" \
             "\t.globl " __ASM_NAME("MSVCRT_" #name "_vtable") "\n" \
             __ASM_NAME("MSVCRT_" #name "_vtable") ":\n" \
@@ -54,9 +60,15 @@
 
 #define VTABLE_ADD_FUNC(name) "\t.long " THISCALL_NAME(name) "\n"
 
+#ifdef __APPLE__
+#define __ASM_VTABLE_ALIGN ".align 2"
+#else
+#define __ASM_VTABLE_ALIGN ".align 4"
+#endif
+
 #define __ASM_VTABLE(name,funcs) \
     __asm__(".data\n" \
-            "\t.align 4\n" \
+            "\t" __ASM_VTABLE_ALIGN "\n" \
             "\t.long " __ASM_NAME(#name "_rtti") "\n" \
             "\t.globl " __ASM_NAME("MSVCRT_" #name "_vtable") "\n" \
             __ASM_NAME("MSVCRT_" #name "_vtable") ":\n" \
-- 
2.10.2




More information about the wine-devel mailing list