环境准备
安装ubuntu系统和必要软件
首先安装好虚拟机和ubuntu18.04系统,然后安装必要软件包
sudo apt install -y git libsdl1.2-dev libtool-bin libglib2.0-dev libz-dev libpixman-1-dev build-essential gdb gcc-multilib libfdt-dev python python3
配置qemu
git clone https://github.com/mit-pdos/6.828-qemu.git
cd qemu
# 下载dtc
git submodule update --init dtc
./configure --disable-kvm --disable-werror
# 若没有Error,则代表配置成功。
测试 Compiler Toolchain
cyl@ubuntu:~/qemu$ objdump -i
BFD header file version (GNU Binutils for Ubuntu) 2.30
elf64-x86-64 # 第二行出现elf64-x86-64或elf32-i386.
(header little endian, data little endian)
i386
elf32-i386
(header little endian, data little endian)
i386
elf32-iamcu
(header little endian, data little endian)
iamcu
elf32-x86-64
(header little endian, data little endian)
i386
a.out-i386-linux
(header little endian, data little endian)
i386
cyl@ubuntu:~/qemu$ gcc -m32 -print-libgcc-file-name
/usr/lib/gcc/x86_64-linux-gnu/7/32/libgcc.a
# 输出 /usr/lib/gcc/i486-linux-gnu/version/libgcc.a 或者 /usr/lib/gcc/x86_64-linux-gnu/version/32/libgcc.a