原来是.S文件不小心写成了.c文件,导致编译出错。
rlk@rlk:BenOS$ cat src/ldr_test.S
.global ldr_test
ldr_test:
mov x1, 0x80000
mov x3, 16
ldr x0,[x1]
ldr x2,[x1, #8]
ldr x4,[x1, x3]
ldr x5,[x1, x3, lsl #3]
ret
第一个错误:将#改为=号
rlk@rlk:BenOS$ make
mkdir -p build
aarch64-linux-gnu-gcc -DCONFIG_BOARD_PI4B -g -Wall -nostdlib -nostdinc -Iinclude -MMD -c src/ldr_test.c -o build/ldr_test_c.o
src/ldr_test.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
1 | .global ldr_test
| ^
src/ldr_test.c:8:13: error: stray ‘#’ in program
8 | ldr x2,[x1,#8]
| ^
src/ldr_test.c:10:20: error: stray ‘#’ in program
10 | ldr x5,[x1,x3,lsl #3]
| ^
make: *** [Makefile:26: build/ldr_test_c.o] Error 1
rlk@rlk:BenOS$ make
mkdir -p build
aarch64-linux-gnu-gcc -DCONFIG_BOARD_PI4B -g -Wall -nostdlib -nostdinc -Iinclude -MMD -c src/ldr_test.c -o build/ldr_test_c.o
src/ldr_test.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
1 | .global ldr_test
| ^
make: *** [Makefile:26: build/ldr_test_c.o] Error 1