什么是交叉工具链
多个交叉工具的集合
arm-linux-gcc -static hello.c -o hello
# arm-linux-gcc -static hello.c -o hello
# file hello
常用的交叉工具
交叉编译器
arm-linux-gcc
与gcc的语法一致,头文件,库文件等路径不同。
交叉连接器
arm-linux-ld 生成elf格式文件,test.lds为连接器脚本文件。
# arm-linux-ld -Ttest.lds -o test.elf test.o test1.o fun.o
交叉转换器
# arm-linux-readelf -a test.elf
# arm-linux-readelf -d test
使用file命令查看可执行文件在arm还是x86,-a查看是大小端, -d查看libc.so.6库是否正确
交叉ELF文件工具
arm-linux-objcopy
将elf文件转换成二进制文件
# arm-linux-objcopy -O binary test.elf test.bin
交叉反汇编器
arm-linux-objdump,将elf格式文件反汇编成汇编代码
# arm-linux-objdump -D -S test
# arm-linux-objdump -D -S test >dump.log
# arm-linux-gcc -g test.c -o test //带调试编译