Commit 1d704051b2da207d715351b8613e74437d8e2eb7

Jeremy Huddleston Sequoia 2018-06-17T17:01:50

i386: Fix missing break; in case statement leading to incorrectly returned FFI_BAD_ABI (#437) * i386: Add missing break triggering dead store static analyzer checks. Register calling sequence is being reported as bad ABI instead of working as intended. Found-by: Clang Static Analysis Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org> * Mark ffi arm sysv entry points as private_extern. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org> * x86_64: Add implementation of compact unwind for ffi_call_unix64. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>

diff --git a/src/arm/sysv.S b/src/arm/sysv.S
index 7bda640..a40e327 100644
--- a/src/arm/sysv.S
+++ b/src/arm/sysv.S
@@ -85,6 +85,7 @@
 
 #define ARM_FUNC_START(name)		\
 	.globl CNAME(name);		\
+	.private_extern CNAME(name);	\
 	FFI_HIDDEN(CNAME(name));	\
 	ARM_FUNC_START_LOCAL(name)
 
diff --git a/src/x86/ffi.c b/src/x86/ffi.c
index 021f683..cad32e8 100644
--- a/src/x86/ffi.c
+++ b/src/x86/ffi.c
@@ -545,6 +545,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
     case FFI_REGISTER:
       dest = ffi_closure_REGISTER;
       op = 0x68;  /* pushl imm */
+      break;
     default:
       return FFI_BAD_ABI;
     }
diff --git a/src/x86/unix64.S b/src/x86/unix64.S
index db792c0..d398740 100644
--- a/src/x86/unix64.S
+++ b/src/x86/unix64.S
@@ -517,6 +517,47 @@ L(SFDE5):
 L(EFDE5):
 #ifdef __APPLE__
 	.subsections_via_symbols
+	.section __LD,__compact_unwind
+
+	/* compact unwind for ffi_call_unix64 */
+	.quad    C(ffi_call_unix64)
+	.set     L1,L(UW4)-L(UW0)
+	.long    L1
+	.long    0x04000000 /* use dwarf unwind info */
+	.quad    0
+	.quad    0
+
+	/* compact unwind for ffi_closure_unix64_sse */
+	.quad    C(ffi_closure_unix64_sse)
+	.set     L2,L(UW7)-L(UW5)
+	.long    L2
+	.long    0x04000000 /* use dwarf unwind info */
+	.quad    0
+	.quad    0
+
+	/* compact unwind for ffi_closure_unix64 */
+	.quad    C(ffi_closure_unix64)
+	.set     L3,L(UW11)-L(UW8)
+	.long    L3
+	.long    0x04000000 /* use dwarf unwind info */
+	.quad    0
+	.quad    0
+
+	/* compact unwind for ffi_go_closure_unix64_sse */
+	.quad    C(ffi_go_closure_unix64_sse)
+	.set     L4,L(UW14)-L(UW12)
+	.long    L4
+	.long    0x04000000 /* use dwarf unwind info */
+	.quad    0
+	.quad    0
+
+	/* compact unwind for ffi_go_closure_unix64 */
+	.quad    C(ffi_go_closure_unix64)
+	.set     L5,L(UW17)-L(UW15)
+	.long    L5
+	.long    0x04000000 /* use dwarf unwind info */
+	.quad    0
+	.quad    0
 #endif
 
 #endif /* __x86_64__ */