Questions about the libffi development process

Russell Keith-Magee russell@keith-magee.com
Sat Apr 25 11:15:00 GMT 2015


(Apologies to Richard - this is a resend; the first version was
silently rejected by the mailing list because of sourceware.org's
anachronistic, broken policies on HTML mail)

On Sat, Apr 25, 2015 at 12:28 AM, Richard Henderson <rth@redhat.com> wrote:
> On 04/23/2015 03:49 PM, Russell Keith-Magee wrote:
>> None at all? There's no release candidate process? No release testing
>> procedures?
>
> I Anthony will have to answer that.
>
>> libtool: compile:  xcrun -sdk iphoneos clang -arch armv7
>> -DHAVE_CONFIG_H -I. -I.. -I. -I../include -Iinclude -I../src -I.
>> -I../include -Iinclude -I../src -miphoneos-version-min=7.0 -MT
>> src/arm/sysv.lo -MD -MP -MF src/arm/.deps/sysv.Tpo -c
>> ../src/arm/sysv.S  -fno-common -DPIC -o src/arm/.libs/sysv.o
>> ../src/arm/sysv.S:111:2: error: .arch directive not valid for Mach-O
>>  .arch armv5t
>
> Any chance you know what is the base architecture for iOS on ARM?

As far as I can make out, they're all ARMv7-A.

The iPhone 5C and 5 both use an Apple A7 Swift [1][2]; The iPhone 4S
and 5th generation iPod Touches use an ARM Cortex-A9 [3][4]; the
iPhone4 is an ARM Cortex-A8 [5]; according to [6].

[1] http://en.wikipedia.org/wiki/IPhone_5C
[2] http://en.wikipedia.org/wiki/IPhone_5
[3] http://en.wikipedia.org/wiki/IPhone_4S
[4] http://en.wikipedia.org/wiki/IPod_Touch_(5th_generation)
[5] http://en.wikipedia.org/wiki/IPhone_4
[6] http://en.wikipedia.org/wiki/List_of_ARM_microarchitectures

>> ../src/arm/sysv.S:128:8: error: invalid operand for instruction
>>  ldcle p11, cr0, [r0] @ vldrle d0, [sp]
>>        ^
>
> Try replacing these with the comment (text after @) and see if it assembles.
>
> The generic "coprocessor load" instructions are used instead of the more
> specific vfp load instructions in order to support armv7hf at run-time while
> not requiring more than arm5t at compile-time.  Something that makes sense for
> ELF, but I guess not for iOS.

With those hints and and some #ifdef __clang__ clauses, I've got the
code compiling. It works for simple function calls (e.g., calls to get
system time), but it fails at runtime with a segfault in
ffi_closure_inner_SYSV when you try to call a function using a
function pointer as an argument (in my test case, a call to the posix
qsort() method to sort a list of integers).

My patch, as it currently stands, is in a branch on Github if anyone
wants to help.

https://github.com/freakboy3742/libffi/tree/t181

Yours,
Russ Magee %-)



More information about the Libffi-discuss mailing list