src/x86/win64.S: Handle name mangling and PIC Move the macros from unix64.S into a shared header asmnames.h and use them in win64.S too.
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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
diff --git a/src/x86/asmnames.h b/src/x86/asmnames.h
new file mode 100644
index 0000000..7551021
--- /dev/null
+++ b/src/x86/asmnames.h
@@ -0,0 +1,30 @@
+#ifndef ASMNAMES_H
+#define ASMNAMES_H
+
+#define C2(X, Y) X ## Y
+#define C1(X, Y) C2(X, Y)
+#ifdef __USER_LABEL_PREFIX__
+# define C(X) C1(__USER_LABEL_PREFIX__, X)
+#else
+# define C(X) X
+#endif
+
+#ifdef __APPLE__
+# define L(X) C1(L, X)
+#else
+# define L(X) C1(.L, X)
+#endif
+
+#if defined(__ELF__) && defined(__PIC__)
+# define PLT(X) X@PLT
+#else
+# define PLT(X) X
+#endif
+
+#ifdef __ELF__
+# define ENDF(X) .type X,@function; .size X, . - X
+#else
+# define ENDF(X)
+#endif
+
+#endif /* ASMNAMES_H */
diff --git a/src/x86/unix64.S b/src/x86/unix64.S
index c83010c..129aba5 100644
--- a/src/x86/unix64.S
+++ b/src/x86/unix64.S
@@ -31,31 +31,10 @@
#include <fficonfig.h>
#include <ffi.h>
#include "internal64.h"
+#include "asmnames.h"
.text
-#define C2(X, Y) X ## Y
-#define C1(X, Y) C2(X, Y)
-#ifdef __USER_LABEL_PREFIX__
-# define C(X) C1(__USER_LABEL_PREFIX__, X)
-#else
-# define C(X) X
-#endif
-
-#ifdef __APPLE__
-# define L(X) C1(L, X)
-#else
-# define L(X) C1(.L, X)
-#endif
-
-#ifdef __ELF__
-# define PLT(X) X@PLT
-# define ENDF(X) .type X,@function; .size X, . - X
-#else
-# define PLT(X) X
-# define ENDF(X)
-#endif
-
/* 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. */
diff --git a/src/x86/win64.S b/src/x86/win64.S
index eed57c2..9d4f8b9 100644
--- a/src/x86/win64.S
+++ b/src/x86/win64.S
@@ -2,6 +2,7 @@
#include <fficonfig.h>
#include <ffi.h>
#include <ffi_cfi.h>
+#include "asmnames.h"
#if defined(HAVE_AS_CFI_PSEUDO_OP)
.cfi_sections .debug_frame
@@ -21,12 +22,6 @@
#define arg3 %rcx
#endif
-#ifdef SYMBOL_UNDERSCORE
-#define SYMBOL_NAME(name) _##name
-#else
-#define SYMBOL_NAME(name) name
-#endif
-
.macro E which
.align 8
.org 0b + \which * 8
@@ -106,7 +101,7 @@ E FFI_TYPE_DOUBLE
movsd %xmm0, (%r8)
epilogue
E FFI_TYPE_LONGDOUBLE
- call abort
+ call PLT(C(abort))
E FFI_TYPE_UINT8
movzbl %al, %eax
movq %rax, (%r8)
@@ -141,7 +136,7 @@ E FFI_TYPE_POINTER
movq %rax, (%r8)
epilogue
E FFI_TYPE_COMPLEX
- call abort
+ call PLT(C(abort))
E FFI_TYPE_SMALL_STRUCT_1B
movb %al, (%r8)
epilogue
@@ -153,7 +148,7 @@ E FFI_TYPE_SMALL_STRUCT_4B
epilogue
.align 8
-99: call abort
+99: call PLT(C(abort))
.purgem epilogue