Search code examples
c++xcodeassemblyboostboost-context

boost::context for arm64?


I am trying to compile boost::context for iOS(armv7, armv7s, arm64):

errors

jump_arm_aapcs_macho_gas.S:52:18: error: ',' expected
    stmia a1, {v1-v8,sp-lr} @ save V1-V8,SP-LR
                 ^
jump_arm_aapcs_macho_gas.S:53:14: error: register expected
    str lr, [a1,#40] @ save LR as PC
             ^
jump_arm_aapcs_macho_gas.S:69:18: error: invalid variant 'use'
    mov a1, a3 @ use third arg as return value after jump
                 ^
jump_arm_aapcs_macho_gas.S:70:39: error: unexpected token at start of statement
                                    @ and as first arg in context function
                                      ^
jump_arm_aapcs_macho_gas.S:71:18: error: ',' expected
    ldmia a2, {v1-v8,sp-pc} @ restore v1-V8,SP-PC
                 ^

jump_arm_aapcs_macho_gas.S

.text
.globl _jump_fcontext
.align 2
_jump_fcontext:
    stmia   a1, {v1-v8,sp-lr}       @ save V1-V8,SP-LR
    str     lr, [a1,#40]            @ save LR as PC

#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
    cmp     a4, #0                  @ test if fpu env should be preserved
    beq     1f

    mov     a4, a1
    add     a4, #52
    vstmia  a4, {d8-d15}            @ save S16-S31

    mov     a4, a2
    add     a4, #52
    vldmia  a4, {d8-d15}            @ restore S16-S31
1:
#endif

    mov     a1, a3                  @ use third arg as return value after jump
                                    @ and as first arg in context function
    ldmia   a2, {v1-v8,sp-pc}       @ restore v1-V8,SP-PC

If I remove arm64, and set the architecture to armv7 only, it compiles, so the code should be fine.

Is there any way to get this to compile for arm64?


Solution

  • ARM64 (AArch64) is pretty different from ARM32 (A32), both in instructions and the register set. The calling conventions (ABI) differs too. You'd need to rewrite the assembler snippets. I would recommend contacting the developer(s) since you don't seem to be familiar with the low-level details to do it yourself.