boot.s文件内容:
.text
.global _start
_start:
ldr sp, =4096
bl main
b .
main文件内容:
#include <stdio.h>
int main(void)
{
printf("123");
return 0;
}
Makefile内容:
test.bin:boot.S main.c
arm-linux-gcc -c boot.S -o boot.o
arm-linux-gcc -c main.c -o main.o
arm-linux-ld -Ttext -0x0 boot.o main.o -L/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/lib \
-L/usr/local/arm/4.3.2/lib/gcc/arm-none-linux-gnueabi/4.3.2 \
-L/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/lib -o test_elf
arm-linux-objcopy -O binary -S test_elf test.bin
arm-linux-objdump -D test_elf > test.dis
make后,报错,信息如下:
arm-linux-gcc -c boot.S -o boot.o
arm-linux-gcc -c main.c -o main.o
arm-linux-ld -Ttext -0x0 boot.o main.o -L/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/lib \
-L/usr/local/arm/4.3.2/lib/gcc/arm-none-linux-gnueabi/4.3.2 \
-L/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/lib -o test_elf
main.o: In function `main':
main.c:(.text+0xc): undefined reference to `printf'
make: *** [test.bin] Error 1
无论怎么指定链接路径,都链接不通过,怎么回事?
|