我需要在文件asm_add.s中通过asm调用xcode6.1中的函数,并将文件类型设置为" llvm assembly":
.section __TEXT,__text,regular,pure_instructions
.align 4
.arm
.globl _asm_add
_asm_add:
sub sp, #0x1c
add r0, r1
add sp, #0x1c
bl r14
我在文件case_arm_pcs.c中调用它,如下所示:
int asm_add(int a, int b);
void caller()
{
int a = 1;
int b = 2;
int c = asm_add(a, b);
printf("%d", c);
}
但是当我构建它时,遇到了链接错误:
Undefined symbols for architecture armv7:
"_asm_add", referenced from:
_caller in case_arm_pcs.o
(maybe you meant: __Z8_asm_addi)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我想这是编译器的原因,但我不太了解详情以及如何重新安排它。