The m68k fixes were not good enough to work correctly for closures around
functions returning structs of 5 to 15 bytes, inclusive; making me wonder what I had actually tested. Now all the testcase passes, for real. Noticed while working on cleaning these changes to push them upstream. Bump revision.
This commit is contained in:
parent
5be997cf5e
commit
b3d2c78490
@ -1,9 +1,9 @@
|
||||
# $OpenBSD: Makefile,v 1.22 2013/07/14 15:29:32 miod Exp $
|
||||
# $OpenBSD: Makefile,v 1.23 2013/07/15 19:01:56 miod Exp $
|
||||
|
||||
COMMENT= Foreign Function Interface
|
||||
|
||||
DISTNAME= libffi-3.0.9
|
||||
REVISION= 4
|
||||
REVISION= 5
|
||||
SHARED_LIBS += ffi 0.0 # .5.9
|
||||
CATEGORIES= devel
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
$OpenBSD: patch-src_m68k_ffi_c,v 1.1 2013/05/01 10:11:54 miod Exp $
|
||||
$OpenBSD: patch-src_m68k_ffi_c,v 1.2 2013/07/15 19:01:56 miod Exp $
|
||||
|
||||
Match the calling convention used by NetBSD and OpenBSD on m68k/ELF, which
|
||||
differs from Linux/ELF: structs are always passed on the stack, functions
|
||||
@ -8,7 +8,7 @@ Add an OpenBSD-specific function to flush the instruction cache after
|
||||
building closure trampolines.
|
||||
|
||||
--- src/m68k/ffi.c.orig Tue Dec 29 15:22:26 2009
|
||||
+++ src/m68k/ffi.c Wed Apr 24 15:23:09 2013
|
||||
+++ src/m68k/ffi.c Mon Jul 15 18:53:57 2013
|
||||
@@ -9,8 +9,12 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -80,9 +80,27 @@ building closure trampolines.
|
||||
ecif.rvalue = alloca (cif->rtype->size);
|
||||
else
|
||||
ecif.rvalue = rvalue;
|
||||
@@ -266,8 +291,12 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
||||
@@ -257,17 +282,26 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
||||
{
|
||||
FFI_ASSERT (cif->abi == FFI_SYSV);
|
||||
|
||||
- *(unsigned short *)closure->tramp = 0x207c;
|
||||
*(void **)(closure->tramp + 2) = codeloc;
|
||||
- *(unsigned short *)(closure->tramp + 6) = 0x4ef9;
|
||||
+ *(unsigned short *)(closure->tramp + 6) = 0x4ef9; /* jmp ffi_closure_... */
|
||||
if (cif->rtype->type == FFI_TYPE_STRUCT
|
||||
&& !cif->flags)
|
||||
- *(void **)(closure->tramp + 8) = ffi_closure_struct_SYSV;
|
||||
+ {
|
||||
+ *(unsigned short *)closure->tramp = 0x227c; /* moval #codeloc, %a1 */
|
||||
+ *(void **)(closure->tramp + 8) = ffi_closure_struct_SYSV;
|
||||
+ }
|
||||
else
|
||||
*(void **)(closure->tramp + 8) = ffi_closure_SYSV;
|
||||
- *(void **)(closure->tramp + 8) = ffi_closure_SYSV;
|
||||
+ {
|
||||
+ *(unsigned short *)closure->tramp = 0x207c; /* moval #codeloc, %a0 */
|
||||
+ *(void **)(closure->tramp + 8) = ffi_closure_SYSV;
|
||||
+ }
|
||||
|
||||
+#ifdef __OpenBSD__
|
||||
+ ffi_sync_icache(codeloc, FFI_TRAMPOLINE_SIZE);
|
||||
|
@ -1,4 +1,4 @@
|
||||
$OpenBSD: patch-src_m68k_sysv_S,v 1.1 2013/05/01 10:11:54 miod Exp $
|
||||
$OpenBSD: patch-src_m68k_sysv_S,v 1.2 2013/07/15 19:01:56 miod Exp $
|
||||
|
||||
Match the calling convention used by NetBSD and OpenBSD on m68k/ELF, which
|
||||
differs from Linux/ELF: structs are always passed on the stack, functions
|
||||
@ -8,7 +8,7 @@ Add an OpenBSD-specific function to flush the instruction cache after
|
||||
building closure trampolines.
|
||||
|
||||
--- src/m68k/sysv.S.orig Tue Dec 29 15:22:26 2009
|
||||
+++ src/m68k/sysv.S Wed Apr 24 15:23:09 2013
|
||||
+++ src/m68k/sysv.S Mon Jul 15 18:54:57 2013
|
||||
@@ -68,12 +68,21 @@ ffi_call_SYSV:
|
||||
#endif
|
||||
addq.l #8,%sp
|
||||
@ -87,7 +87,23 @@ building closure trampolines.
|
||||
CFI_ENDPROC()
|
||||
|
||||
.size ffi_closure_SYSV,.-ffi_closure_SYSV
|
||||
@@ -228,6 +262,20 @@ ffi_closure_struct_SYSV:
|
||||
@@ -217,8 +251,13 @@ ffi_closure_struct_SYSV:
|
||||
CFI_DEF_CFA(14,8)
|
||||
move.l %sp,-12(%fp)
|
||||
pea 8(%fp)
|
||||
- move.l %a1,-(%sp)
|
||||
- move.l %a0,-(%sp)
|
||||
+#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
+ move.l %a0,-(%sp) /* struct return address */
|
||||
+ move.l %a1,-(%sp) /* closure */
|
||||
+#else
|
||||
+ move.l %a1,-(%sp) /* struct return address */
|
||||
+ move.l %a0,-(%sp) /* closure */
|
||||
+#endif
|
||||
#if !defined __PIC__
|
||||
jsr ffi_closure_SYSV_inner
|
||||
#else
|
||||
@@ -228,6 +267,20 @@ ffi_closure_struct_SYSV:
|
||||
rts
|
||||
CFI_ENDPROC()
|
||||
.size ffi_closure_struct_SYSV,.-ffi_closure_struct_SYSV
|
||||
|
Loading…
x
Reference in New Issue
Block a user