src/x86/win64.S: Handle name mangling and PIC
authorJosh Triplett <josh@joshtriplett.org>
Mon, 27 Jul 2015 00:17:16 +0000 (17:17 -0700)
committerJosh Triplett <josh@joshtriplett.org>
Mon, 27 Jul 2015 00:18:16 +0000 (17:18 -0700)
Move the macros from unix64.S into a shared header asmnames.h and use
them in win64.S too.

src/x86/asmnames.h [new file with mode: 0644]
src/x86/unix64.S
src/x86/win64.S

diff --git a/src/x86/asmnames.h b/src/x86/asmnames.h
new file mode 100644 (file)
index 0000000..7551021
--- /dev/null
@@ -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 */
index c83010c..129aba5 100644 (file)
 #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.  */
index eed57c2..9d4f8b9 100644 (file)
@@ -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
 #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