C ++ Delphi XE6 Code Code on iOS

I created an Android application using Delphi XE6, which requires C code. However, on iOS, I cannot get it to work. I suspect that the problem is related to the condition of the hand / finger, but I'm not sure. On any system, there is no problem calling C code from Pascal. But if the C code calls the reverse Pascal procedure, iOS generates a "bad system call (12)"

Here is the pascal code:

 function testarm(a,b:integer):integer; cdecl; external "testC.o"; Procedure testC; Begin testarm(1,2); end; function BackToPascal(a,b:integer): integer; cdecl; Begin result := a+b; end; ...... exports BackToPascal; 

And here is the C code:

 extern int BackToPascal(int a,int b); extern int testarm(int a,int b) { int i; i = BackToPascal(a,b); return i+1; } 

In android, this is how I compile (it works):

 ..."arm-linux-androideabi-gcc.exe" -c test.c -o test.o -O3 -mfloat-abi=softfp -mfpu=neon -marm -march=armv7-a -mtune=cortex-a8 

On ios:

 xcrun -sdk iphoneos clang -c -arch armv7 test.c -O3 -mfpu=neon -mtune=cortex-a8 -marm -march=armv7-a -mfloat-abi=softfp 

I suspect my xcode settings are incorrect, but I cannot understand why.

When debugging, an error occurs when testC called in testarm when testarm called (on "bl 0x8b8390 Xgobj.BackToPascal (int, int)"). It works fine on Android, however bl does not directly BackToPascal , but the following code:

 75A82D94 12C68FE2 add r12, pc, #18874368 ; 0x1200000 75A82D98 73CA8CE2 add r12, r12, #471040 ; 0x73000 75A82D9C 40F2BCE5 ldr pc, [r12, #576]! ; 0x240 

Which fall into BackToPascal

+66
c ios delphi pascal delphi-xe6
Aug 24 '14 at 5:47
source share
1 answer

The code looks correct, and your call to conference calls, in my opinion, is absolutely correct.

I think that you may have encountered a possible error / rumor in the Apple ARM clang, where calling a static function (which can happen behind the scenes, for example, to convert types) from a static function can damage the stack. You do not do this directly, but external functions can be implemented through a stub that calls an anonymous static function containing the implementation.

You can try to make your outer function a wrapper that instead invokes a non-stationary implementation.

+1
Aug 12 '15 at 16:33
source share
β€” -



All Articles