public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Jacek Caban <jacek@codeweavers.com>
To: libffi-discuss@sourceware.org
Subject: [PATCH] Fixed compilation on mingw-w64 after recent ABI change.
Date: Thu, 04 Nov 2010 14:23:00 -0000	[thread overview]
Message-ID: <4CD2C1BF.5060008@codeweavers.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

Hi,

mingw-w64 ABI has been recently changed to use nonunderscored symbol names 
(for compatibility with MSVC). The attached patch fixes libffi compilation 
with recent mingw-w64. For backward compatibility, I've added a configure 
check for underscored symbols.

Thanks,
     Jacek

[-- Attachment #2: patch.diff --]
[-- Type: text/plain, Size: 2588 bytes --]

commit 96e8ff948be4c853a36510ee40171063e1610d2d
Author: Jacek Caban <jacek@codeweavers.com>
Date:   Thu Nov 4 15:00:56 2010 +0000

    Fixed compilation on mingw-w64 after recent ABI change.

diff --git a/configure.ac b/configure.ac
index 50f24bc..3380ca1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -315,6 +315,21 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
     fi
 fi
 
+if test x$TARGET = xX86_WIN64; then
+    AC_CACHE_CHECK([sumbols are underscored],
+       libffi_cv_symbol_underscore, [
+       libffi_cv_symbol_underscore=unknown
+       # Check if symbols are underscored
+       AC_TRY_LINK([int cvar;],
+		   [asm ("mov \$_cvar, %rax\n");],
+		   [libffi_cv_symbol_underscore=yes],
+		   [libffi_cv_symbol_underscore=no])
+    ])
+    if test "x$libffi_cv_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)

             reply	other threads:[~2010-11-04 14:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04 14:23 Jacek Caban [this message]
2010-11-10 12:12 ` Jacek Caban
2010-11-13  7:12   ` Anthony Green
2010-11-13 14:26     ` Jacek Caban

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CD2C1BF.5060008@codeweavers.com \
    --to=jacek@codeweavers.com \
    --cc=libffi-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).