This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: please, help me with libffi on iOS porting
- From: Andrew Haley <aph at redhat dot com>
- To: Guetcho Guetchev <getcho dot getchev at gmail dot com>
- Cc: "libffi-discuss at sourceware dot org" <libffi-discuss at sourceware dot org>
- Date: Mon, 06 Aug 2012 09:55:27 +0100
- Subject: Re: please, help me with libffi on iOS porting
- References: <32A33156-EC2B-47FF-B3F9-43558704FA6C@gmail.com>
On 08/03/2012 01:01 PM, Guetcho Guetchev wrote:
> Hello guys,
> I am trying to port Glib and Gstreamer for iOS.
> Recently I encountered several issues related to the code alignment.
> First of all I get the following warnings when compiling Glib or whatever library depending on libffi:
>
> ld: warning: ARM function not 4-byte aligned: _ffi_call_SYSV from /Users/user/gstreamer/lib/libffi.a(sysv.o)
> ld: warning: ARM function not 4-byte aligned: .ffi_call_SYSV_end from /Users/user/gstreamer/lib/libffi.a(sysv.o)
> ld: warning: ARM function not 4-byte aligned: _ffi_closure_SYSV from /Users/user/gstreamer/lib/libffi.a(sysv.o)
> ld: warning: ARM function not 4-byte aligned: .Lclosure_epilogue from /Users/user/gstreamer/lib/libffi.a(sysv.o)
> ld: warning: ARM function not 4-byte aligned: .Lretint from /Users/user/gstreamer/lib/libffi.a(sysv.o)
> ld: warning: ARM function not 4-byte aligned: .Lretlonglong from /Users/user/gstreamer/lib/libffi.a(sysv.o)
> ld: warning: ARM function not 4-byte aligned: .ffi_closure_SYSV_end from /Users/user/gstreamer/lib/libffi.a(sysv.o)
> ld: warning: ARM function not 4-byte aligned: _ffi_arm_trampoline from /Users/user/gstreamer/lib/libffi.a(sysv.o)
>
> When I dug into the code I found that on several files (sysV.s and
> trampoline.S along with several patches / fixes that are applied to
> these files ) where the code alignment is set to 1 byte (.align
> 0). However the default alignment for gcc / clang compilers is 4
> bytes. As far as I know for the thumb ARM assembly it is preferable
> to have 4 bytes alignment. So is there a reason the alignment is
> set to 1 byte?
The doc says:
`.align EXPRESSION [, EXPRESSION]'
This is the generic .ALIGN directive. For the ARM however if the
first argument is zero (ie no alignment is needed) the assembler
will behave as if the argument had been 2 (ie pad to the next four
byte boundary). This is for compatibility with ARM's own
assembler.
> But the next issue is worse:
> In ffi_call() I get an assert at line 260:
>
> 247: switch (cif->abi)
> 248: {
> 249: case FFI_SYSV:
> 250: ffi_call_SYSV (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
> 251: break;
> 252:
> 253: case FFI_VFP:
> 254: #ifdef __ARM_EABI__
> 255: ffi_call_VFP (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
> 256: break;
> 257: #endif
> 258:
> 259: default:
> 260: FFI_ASSERT(0);
> 261: break;
> 262: }
> 263: if (small_struct)
> 264: memcpy (rvalue, &temp, cif->rtype->size);
> 265: else if (vfp_struct)
> 266: memcpy (rvalue, ecif.rvalue, cif->rtype->size);
> 267: }
>
>
> the value of cfi->abi is FFI_VFP
So, you're using hard float arg passing, but not EABI? How can this
be? Hard-float requires EABI.
Andrew.