As mentioned yesterday, asm.S in libtask uses 32-bit syntax of ARM, so it can not be compiled and passed under ARM 64.
So I checked the data and rewrote the assembly code so that it can be compiled and passed under 64 bits. Source code is as follows
#if defined(__linux__) && defined(__arm__) .globl getmcontext getmcontext: str r1, [r0,#4] str r2, [r0,#8] str r3, [r0,#12] str r4, [r0,#16] str r5, [r0,#20] str r6, [r0,#24] str r7, [r0,#28] str r8, [r0,#32] str r9, [r0,#36] str r10, [r0,#40] str r11, [r0,#44] str r12, [r0,#48] str r13, [r0,#52] str r14, [r0,#56] /* store 1 as r0-to-restore */ mov r1, #1 str r1, [r0] /* return 0 */ mov r0, #0 mov pc, lr .globl setmcontext setmcontext: ldr r1, [r0,#4] ldr r2, [r0,#8] ldr r3, [r0,#12] ldr r4, [r0,#16] ldr r5, [r0,#20] ldr r6, [r0,#24] ldr r7, [r0,#28] ldr r8, [r0,#32] ldr r9, [r0,#36] ldr r10, [r0,#40] ldr r11, [r0,#44] ldr r12, [r0,#48] ldr r13, [r0,#52] ldr r14, [r0,#56] ldr r0, [r0] mov pc, lr #elif defined(__linux__) && (defined(__arm64__) || defined(__aarch64__)) .globl getmcontext getmcontext: str x1, [x0,#4] str x2, [x0,#8] str x3, [x0,#12] str x4, [x0,#16] str x5, [x0,#20] str x6, [x0,#24] str x7, [x0,#28] str x8, [x0,#32] str x9, [x0,#36] str x10, [x0,#40] str x11, [x0,#44] str x12, [x0,#48] str x13, [x0,#52] str x14, [x0,#56] /* store 1 as r0-to-restore */ mov x1, #1 str x1, [x0] /* return 0 */ mov x0, #0 /*mov pc, lr */ /*PC Register, Program Counter, records the address of the code currently executed. It is an implicit register that cannot be accessed directly, but can only be accessed implicitly by specific instructions.*/ .globl setmcontext setmcontext: ldr x1, [x0,#4] ldr x2, [x0,#8] ldr x3, [x0,#12] ldr x4, [x0,#16] ldr x5, [x0,#20] ldr x6, [x0,#24] ldr x7, [x0,#28] ldr x8, [x0,#32] ldr x9, [x0,#36] ldr x10, [x0,#40] ldr x11, [x0,#44] ldr x12, [x0,#48] ldr x13, [x0,#52] ldr x14, [x0,#56] ldr x0, [x0] /*mov pc, lr*/ #else #error unknown platform #endif
The conclusion is:
- The registers under ARM 32 bits are r0~r14, while under arm 64 are x0~x14.
- Under arm 64, should it be changed to 8 bytes per offset? I do not know!
- The sentence "mov pc, lr" is commented on because PC registers under ARM 64 cannot be accessed directly.
- Finally, after the above grammar compilation is passed, the symbol getcontext cannot be found when linking executable programs. I don't know how to solve this problem yet!