This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR libffi/34612: libffi doesn't work with -fomit-frame-pointer on ia32


According ia32 psABI, we should pop 4 byte from stack when returning
struct. This patch does it and add tests for -fomit-frame-pointer.
Tested on Linux/ia32.


H.J.
---
2007-12-29  H.J. Lu  <hongjiu.lu@intel.com>

	PR libffi/34612
	* src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when
	returning struct.

	* testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer"
	tests.

--- libffi/src/x86/sysv.S.frame	2007-08-07 14:48:04.000000000 -0700
+++ libffi/src/x86/sysv.S	2007-12-29 06:55:51.000000000 -0800
@@ -210,6 +210,8 @@ ffi_closure_SYSV:
 	je	.Lcls_retldouble
 	cmpl	$FFI_TYPE_SINT64, %eax
 	je	.Lcls_retllong
+	cmpl	$FFI_TYPE_STRUCT, %eax
+	je	.Lcls_retstruct
 .Lcls_epilogue:
 	movl	%ebp, %esp
 	popl	%ebp
@@ -230,6 +232,10 @@ ffi_closure_SYSV:
 	movl	(%ecx), %eax
 	movl	4(%ecx), %edx
 	jmp	.Lcls_epilogue
+.Lcls_retstruct:
+	movl	%ebp, %esp
+	popl	%ebp
+	ret	$4
 .LFE2:
 	.size	ffi_closure_SYSV, .-ffi_closure_SYSV
 
--- libffi/testsuite/libffi.call/call.exp.frame	2006-11-18 06:27:24.000000000 -0800
+++ libffi/testsuite/libffi.call/call.exp	2007-12-29 06:33:36.000000000 -0800
@@ -27,6 +27,7 @@ dg-runtest [lsort [glob -nocomplain $src
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2" ""
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O3" ""
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-Os" ""
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2 -fomit-frame-pointer" ""
 
 dg-finish
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]