commit a413fb475b6b64371a916c670b79404cc47813e6 Author: Jacek Caban Date: Thu Nov 4 15:00:56 2010 +0000 Fixed compilation on mingw-w64 after recent ABI change. diff --git a/ChangeLog b/ChangeLog index 5768c10..6232f46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-11-13 Jacek Caban + * configure.ac: Check for symbol underscores on mingw-w64. + * src/x86/win64.S: Correctly access extern symbols in respect to + underscores. + 2010-08-05 Dan Witte * Makefile.am: Pass FFI_DEBUG define to msvcc.sh for linking to the diff --git a/configure.ac b/configure.ac index 50f24bc..ac11a9a 100644 --- a/configure.ac +++ b/configure.ac @@ -315,6 +315,13 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64 fi fi +if test x$TARGET = xX86_WIN64; then + LT_SYS_SYMBOL_USCORE + if test "x$sys_symbol_underscore" = xyes; then + AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.]) + fi +fi + case "$target" in *-apple-darwin10* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*) AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1, diff --git a/src/x86/win64.S b/src/x86/win64.S index 6e91818..fcdb270 100644 --- a/src/x86/win64.S +++ b/src/x86/win64.S @@ -232,10 +232,18 @@ ret_void$: ffi_call_win64 ENDP _TEXT ENDS END -#else + +#else + +#ifdef SYMBOL_UNDERSCORE +#define SYMBOL_NAME(name) _##name +#else +#define SYMBOL_NAME(name) name +#endif + .text -.extern _ffi_closure_win64_inner +.extern SYMBOL_NAME(ffi_closure_win64_inner) # ffi_closure_win64 will be called with these registers set: # rax points to 'closure' @@ -246,8 +254,8 @@ END # call ffi_closure_win64_inner for the actual work, then return the result. # .balign 16 - .globl _ffi_closure_win64 -_ffi_closure_win64: + .globl SYMBOL_NAME(ffi_closure_win64) +SYMBOL_NAME(ffi_closure_win64): # copy register arguments onto stack test $1,%r11 jne .Lfirst_is_float @@ -287,7 +295,7 @@ _ffi_closure_win64: mov %rax, %rcx # context is first parameter mov %rsp, %rdx # stack is second parameter add $48, %rdx # point to start of arguments - mov $_ffi_closure_win64_inner, %rax + mov $SYMBOL_NAME(ffi_closure_win64_inner), %rax callq *%rax # call the real closure function add $40, %rsp movq %rax, %xmm0 # If the closure returned a float, @@ -296,8 +304,8 @@ _ffi_closure_win64: .ffi_closure_win64_end: .balign 16 - .globl _ffi_call_win64 -_ffi_call_win64: + .globl SYMBOL_NAME(ffi_call_win64) +SYMBOL_NAME(ffi_call_win64): # copy registers onto stack mov %r9,32(%rsp) mov %r8,24(%rsp)