From 097ccfd6a6b94a3c3b5bfc269a7afd1dc4f7a051 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 10 Dec 2014 13:25:14 -0800 Subject: [PATCH 1/2] x86: Fix some unwind errors --- src/x86/sysv.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/x86/sysv.S b/src/x86/sysv.S index 72cba6cc..ebd16932 100644 --- a/src/x86/sysv.S +++ b/src/x86/sysv.S @@ -108,7 +108,7 @@ ffi_call_i386: movl 12(%ebp), %ecx /* load return type code */ movl %ebx, 8(%ebp) /* preserve %ebx */ - cfi_rel_offset(%ebp, 8) + cfi_rel_offset(%ebx, 8) andl $X86_RET_TYPE_MASK, %ecx #ifdef __PIC__ @@ -600,7 +600,7 @@ C(ffi_closure_raw_THISCALL): subl $raw_closure_T_FS, %esp cfi_adjust_cfa_offset(raw_closure_T_FS) movl %ebx, raw_closure_T_FS-4(%esp) - cfi_offset(%ebx, raw_closure_T_FS-4) + cfi_rel_offset(%ebx, raw_closure_T_FS-4) movl FFI_TRAMPOLINE_SIZE+8(%eax), %edx /* load cl->user_data */ movl %edx, 12(%esp) From 2f652469684d6d2b3e54705294c7e81cffe1341f Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 11 Dec 2014 14:16:00 -0800 Subject: [PATCH 2/2] x86: Handle void arguments as if an empty structure Since libffi currently doesn't allow empty structures, libgo currently maps them to ffi_type_void. Given that we'll abort on this case, handle it gracefully. --- src/x86/ffi64.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c index 650f7bb3..cf6b5a56 100644 --- a/src/x86/ffi64.c +++ b/src/x86/ffi64.c @@ -233,6 +233,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[], signalize memory class, so handle it as special case. */ if (!words) { + case FFI_TYPE_VOID: classes[0] = X86_64_NO_CLASS; return 1; } @@ -611,6 +612,9 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, { switch (classes[j]) { + case X86_64_NO_CLASS: + case X86_64_SSEUP_CLASS: + break; case X86_64_INTEGER_CLASS: case X86_64_INTEGERSI_CLASS: /* Sign-extend integer arguments passed in general