x86: Copy fix for clang .org from unix64.S Clang doesn't understand .org with symbolic operands.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
diff --git a/src/x86/win64.S b/src/x86/win64.S
index 9d4f8b9..09b9854 100644
--- a/src/x86/win64.S
+++ b/src/x86/win64.S
@@ -22,10 +22,15 @@
#define arg3 %rcx
#endif
-.macro E which
- .align 8
- .org 0b + \which * 8
-.endm
+/* This macro allows the safe creation of jump tables without an
+ actual table. The entry points into the table are all 8 bytes.
+ The use of ORG asserts that we're at the correct location. */
+/* ??? The clang assembler doesn't handle .org with symbolic expressions. */
+#if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__))
+# define E(BASE, X) .balign 8
+#else
+# define E(BASE, X) .balign 8; .org BASE + X * 8
+#endif
.text
@@ -88,62 +93,62 @@ ffi_call_win64:
.align 8
0:
-E FFI_TYPE_VOID
+E(0b, FFI_TYPE_VOID)
epilogue
-E FFI_TYPE_INT
+E(0b, FFI_TYPE_INT)
movslq %eax, %rax
movq %rax, (%r8)
epilogue
-E FFI_TYPE_FLOAT
+E(0b, FFI_TYPE_FLOAT)
movss %xmm0, (%r8)
epilogue
-E FFI_TYPE_DOUBLE
+E(0b, FFI_TYPE_DOUBLE)
movsd %xmm0, (%r8)
epilogue
-E FFI_TYPE_LONGDOUBLE
+E(0b, FFI_TYPE_LONGDOUBLE)
call PLT(C(abort))
-E FFI_TYPE_UINT8
+E(0b, FFI_TYPE_UINT8)
movzbl %al, %eax
movq %rax, (%r8)
epilogue
-E FFI_TYPE_SINT8
+E(0b, FFI_TYPE_SINT8)
movsbq %al, %rax
jmp 98f
-E FFI_TYPE_UINT16
+E(0b, FFI_TYPE_UINT16)
movzwl %ax, %eax
movq %rax, (%r8)
epilogue
-E FFI_TYPE_SINT16
+E(0b, FFI_TYPE_SINT16)
movswq %ax, %rax
jmp 98f
-E FFI_TYPE_UINT32
+E(0b, FFI_TYPE_UINT32)
movl %eax, %eax
movq %rax, (%r8)
epilogue
-E FFI_TYPE_SINT32
+E(0b, FFI_TYPE_SINT32)
movslq %eax, %rax
movq %rax, (%r8)
epilogue
-E FFI_TYPE_UINT64
+E(0b, FFI_TYPE_UINT64)
98: movq %rax, (%r8)
epilogue
-E FFI_TYPE_SINT64
+E(0b, FFI_TYPE_SINT64)
movq %rax, (%r8)
epilogue
-E FFI_TYPE_STRUCT
+E(0b, FFI_TYPE_STRUCT)
epilogue
-E FFI_TYPE_POINTER
+E(0b, FFI_TYPE_POINTER)
movq %rax, (%r8)
epilogue
-E FFI_TYPE_COMPLEX
+E(0b, FFI_TYPE_COMPLEX)
call PLT(C(abort))
-E FFI_TYPE_SMALL_STRUCT_1B
+E(0b, FFI_TYPE_SMALL_STRUCT_1B)
movb %al, (%r8)
epilogue
-E FFI_TYPE_SMALL_STRUCT_2B
+E(0b, FFI_TYPE_SMALL_STRUCT_2B)
movw %ax, (%r8)
epilogue
-E FFI_TYPE_SMALL_STRUCT_4B
+E(0b, FFI_TYPE_SMALL_STRUCT_4B)
movl %eax, (%r8)
epilogue