From: Jacek Caban <jacek@codeweavers.com>
To: Anthony Green
<green@gmachine.i-did-not-set--mail-host-address--so-tickle-me>
Cc: libffi-discuss@sourceware.org
Subject: Re: [PATCH] Fixed compilation on mingw-w64 after recent ABI change.
Date: Sat, 13 Nov 2010 14:26:00 -0000 [thread overview]
Message-ID: <4CDE9FDE.4070606@codeweavers.com> (raw)
In-Reply-To: <m34oblg0k0.fsf@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1362 bytes --]
On 11/13/10 8:11 AM, Anthony Green wrote:
> Jacek Caban<jacek@codeweavers.com> writes:
>
>> On 11/4/10 3:22 PM, Jacek Caban wrote:
>>> 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.
>> I've got no response in almost a week, is there something wrong with
>> this patch?
> libffi is a volunteer project for me, which means that contributors
> often have to be patient.
I understand, I just wasn't sure if I should wait or did something wrong.
> The patch looks OK to me. There's one spelling error ("sumbols").
> FWIW, I prefer libtool's autoconf macro for underscore prefix tests. It
> compiles code and looks at the nm output to see if symbols are prefixed
> or not. Your test uses x86 assembly code, although I realize that your
> #ifdef around the config test so that it will only be run on x86 hw.
I wasn't aware of the autoconf macro, it definitely make things look better.
> Please resubmit with the spelling fix and a proper ChangeLog file entry
> and I'll merge it in. If you switch to the portable '_' test, I'd be
> even happier, but it's not necessary.
Fixed patch is attached.
Thanks for the review,
Jacek
[-- Attachment #2: patch.diff --]
[-- Type: text/plain, Size: 2706 bytes --]
commit a413fb475b6b64371a916c670b79404cc47813e6
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/ChangeLog b/ChangeLog
index 5768c10..6232f46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-11-13 Jacek Caban <jacek@codeweavers.com>
+ * 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 <dwitte@mozilla.com>
* 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)
prev parent reply other threads:[~2010-11-13 14:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-04 14:23 Jacek Caban
2010-11-10 12:12 ` Jacek Caban
2010-11-13 7:12 ` Anthony Green
2010-11-13 14:26 ` Jacek Caban [this message]
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=4CDE9FDE.4070606@codeweavers.com \
--to=jacek@codeweavers.com \
--cc=green@gmachine.i-did-not-set--mail-host-address--so-tickle-me \
--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).