From: Richard Henderson <rth@twiddle.net>
To: libffi-discuss@sourceware.org
Subject: [PATCH 6/8] x86_64: Fixups for x32
Date: Tue, 28 Oct 2014 18:32:00 -0000 [thread overview]
Message-ID: <1414521094-18403-7-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1414521094-18403-1-git-send-email-rth@twiddle.net>
---
src/x86/ffi64.c | 5 +++--
src/x86/unix64.S | 20 ++++++++++++++++----
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c
index 384a93a..65fb595 100644
--- a/src/x86/ffi64.c
+++ b/src/x86/ffi64.c
@@ -568,6 +568,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
0x0f, 0x1f, 0x00
};
void (*dest)(void);
+ char *tramp = closure->tramp;
if (cif->abi != FFI_UNIX64)
return FFI_BAD_ABI;
@@ -577,8 +578,8 @@ ffi_prep_closure_loc (ffi_closure* closure,
else
dest = ffi_closure_unix64;
- memcpy (closure->tramp, trampoline, sizeof(trampoline));
- *(UINT64 *)(closure->tramp + 16) = (uintptr_t)dest;
+ memcpy (tramp, trampoline, sizeof(trampoline));
+ *(UINT64 *)(tramp + 16) = (uintptr_t)dest;
closure->cif = cif;
closure->fun = fun;
diff --git a/src/x86/unix64.S b/src/x86/unix64.S
index 134cb3d..797b9d9 100644
--- a/src/x86/unix64.S
+++ b/src/x86/unix64.S
@@ -32,7 +32,7 @@
#include <ffi.h>
#include <ffi_cfi.h>
-.text
+ .text
/* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
void *raddr, void (*fnaddr)(void));
@@ -272,9 +272,15 @@ ffi_closure_unix64:
movq %r8, ffi_closure_OFS_G+0x20(%rsp)
movq %r9, ffi_closure_OFS_G+0x28(%rsp)
- movq 24(%r10), %rdi /* Load cif */
- movq 32(%r10), %rsi /* Load fun */
- movq 40(%r10), %rdx /* Load user_data */
+#ifdef __ILP32__
+ movl FFI_TRAMPOLINE_SIZE(%r10), %edi /* Load cif */
+ movl FFI_TRAMPOLINE_SIZE+4(%r10), %esi /* Load fun */
+ movl FFI_TRAMPOLINE_SIZE+8(%r10), %edx /* Load user_data */
+#else
+ movq FFI_TRAMPOLINE_SIZE(%r10), %rdi /* Load cif */
+ movq FFI_TRAMPOLINE_SIZE+8(%r10), %rsi /* Load fun */
+ movq FFI_TRAMPOLINE_SIZE+16(%r10), %rdx /* Load user_data */
+#endif
.Ldo_closure:
leaq ffi_closure_OFS_RVALUE(%rsp), %rcx /* Load rvalue */
movq %rsp, %r8 /* Load reg_args */
@@ -407,9 +413,15 @@ ffi_go_closure_unix64:
movq %r8, ffi_closure_OFS_G+0x20(%rsp)
movq %r9, ffi_closure_OFS_G+0x28(%rsp)
+#ifdef __ILP32__
+ movl 4(%r10), %edi /* Load cif */
+ movl 8(%r10), %esi /* Load fun */
+ movl %r10d, %edx /* Load closure (user_data) */
+#else
movq 8(%r10), %rdi /* Load cif */
movq 16(%r10), %rsi /* Load fun */
movq %r10, %rdx /* Load closure (user_data) */
+#endif
jmp .Ldo_closure
cfi_endproc
--
1.9.3
next prev parent reply other threads:[~2014-10-28 18:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-28 18:32 [PATCH 0/8] Go closures for x86_64 Richard Henderson
2014-10-28 18:32 ` [PATCH 3/8] x86-64: Support go closures Richard Henderson
2014-10-28 18:32 ` [PATCH 7/8] x86_64: Decouple return types from FFI_TYPE constants Richard Henderson
2014-10-28 18:32 ` [PATCH 1/8] Add entry points for interacting with Go Richard Henderson
2014-10-28 18:32 ` [PATCH 8/8] x86_64: Add support for complex types Richard Henderson
2014-10-28 18:32 ` [PATCH 5/8] win64: Remove support from ffi.c Richard Henderson
2014-10-28 18:32 ` Richard Henderson [this message]
2014-10-28 18:32 ` [PATCH 4/8] win64: Rewrite Richard Henderson
2014-10-28 18:32 ` [PATCH 2/8] Add ffi_cfi.h Richard Henderson
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=1414521094-18403-7-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--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).