From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8747 invoked by alias); 28 Oct 2014 18:32:23 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 8629 invoked by uid 89); 28 Oct 2014 18:32:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qc0-f182.google.com Received: from mail-qc0-f182.google.com (HELO mail-qc0-f182.google.com) (209.85.216.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 28 Oct 2014 18:32:20 +0000 Received: by mail-qc0-f182.google.com with SMTP id m20so1056335qcx.13 for ; Tue, 28 Oct 2014 11:32:16 -0700 (PDT) X-Received: by 10.229.172.134 with SMTP id l6mr7828186qcz.8.1414521136350; Tue, 28 Oct 2014 11:32:16 -0700 (PDT) Received: from anchor.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id j1sm1948207qao.38.2014.10.28.11.32.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Oct 2014 11:32:15 -0700 (PDT) From: Richard Henderson To: libffi-discuss@sourceware.org Subject: [PATCH 6/8] x86_64: Fixups for x32 Date: Tue, 28 Oct 2014 18:32:00 -0000 Message-Id: <1414521094-18403-7-git-send-email-rth@twiddle.net> In-Reply-To: <1414521094-18403-1-git-send-email-rth@twiddle.net> References: <1414521094-18403-1-git-send-email-rth@twiddle.net> X-SW-Source: 2014/txt/msg00127.txt.bz2 --- 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 #include -.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