arm-linux交叉编译配置
通过apt包管理快速配置:
sudo apt-get install gcc-arm-none-eabi
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install g++-arm-linux-gnueabihf
现在的apt包能很方便的支持arm的交叉编译链的配置(arm-cross-compiler-toolchain)
这里是预装一些未来配置的时候很可能会缺的库,不过也可以先不装,体会一下这个百度error的过程
sudo apt-get install libfdt-dev
sudo apt-get install pkg-config
sudo apt-get install libglib2.0-dev
sudo apt-get install libpixman-1-dev
写一个demo
vim hello_world.c
#include<stdio.h>
int main()
{
printf("1");
}
编译与检查
这里的arm-编译命令按你tab出的即可,末尾是gcc即代表gcc编译器,前头是一些编译相关的标志如“gnueabihf”代表了一种浮点运算规则
arm-linux-gnueabihf-gcc hello_world.c -o hello
file hello
hello: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=7feff20a2a2bd760d66a6b1c4a662aab217776be, for GNU/Linux 3.2.0, not stripped
配置qemu
wget https://download.qemu.org/qemu-5.1.0.tar.xz
tar -xvf qemu-5.1.0.tar.xz
cd qemu-5.1.0.tar.xz
sudo ./configure
sudo make
sudo make install
qemu-#tab 此时可获得支持的系统列表
emu-
Completing external command
qemu-aarch64 qemu-system-aarch64
qemu-aarch64_be qemu-system-alpha
qemu-alpha qemu-system-arm
qemu-arm qemu-system-avr
qemu-armeb qemu-system-cris
qemu-cris qemu-system-hppa
qemu-edid qemu-system-i386
qemu-ga qemu-system-lm32
qemu-hppa qemu-system-m68k
qemu-i386 qemu-system-microblaze
qemu-img qemu-system-microblazeel
qemu-io qemu-system-mips
qemu-m68k qemu-system-mips64
qemu-microblaze qemu-system-mips64el
qemu-microblazeel qemu-system-mipsel
qemu-mips qemu-system-moxie
qemu-mips64 qemu-system-nios2
qemu-mips64el qemu-system-or1k
qemu-mipsel qemu-system-ppc
qemu-mipsn32 qemu-system-ppc64
qemu-mipsn32el qemu-system-riscv32
qemu-nbd qemu-system-riscv64
qemu-nios2 qemu-system-rx
qemu-or1k qemu-system-s390x
qemu-ppc qemu-system-sh4
qemu-ppc64 qemu-system-sh4eb
qemu-ppc64abi32 qemu-system-sparc
qemu-ppc64le qemu-system-sparc64
qemu-riscv32 qemu-system-tricore
qemu-riscv64 qemu-system-unicore32
qemu-s390x qemu-system-x86_64
qemu-sh4 qemu-system-xtensa
qemu-sh4eb qemu-system-xtensaeb
qemu-sparc qemu-tilegx
qemu-sparc32plus qemu-x86_64
qemu-sparc64 qemu-xtensa
qemu-storage-daemon qemu-xtensaeb
┌──(kali㉿kali)-[~/Desktop]
└─$ qemu-arm -L /usr/arm-linux-gnueabihf/ hello_world
1