首先为了验证我的工具链,测试我的分发,需要运行以下命令:
objdump -iobjdump命令是用来显示关于目标文件的各种信息或者目标可执行文件构成的gcc工具。其中单纯使用-i选项可以可用的架构和目标结构列表。 输出结果中需要包含
elf32-i386
ELF(Executable and Linkable Format)意思是可执行可链接文件。我们需要对32位i386平台的支持。 然后运行以下命令:
gcc -m32 -print-libgcc-file-name如果输出/usr/lib/gcc/i486-linux-gnu/version/libgcc.a或者/usr/lib/gcc/x86_64-linux-gnu/version/32/libgcc.a代表有libgcc的静态链接库文件,无需自己编译工具链。 接着安装QEMU模拟器
克隆QEMU github repo git clone https://github.com/mit-pdos/6.828-qemu.git qemu对linux而言,需要安装如下的包: libsdl1.2-dev, libtool-bin, libglib2.0-dev, libz-dev, and libpixman-1-dev, 运行以下命令: sudo apt-get update -y #-y represents yes for all queries. sudo apt-get install libsdl1.2-dev #For example. 运行以下安装命令: ./configure --disable-kvm --disable-werror [--prefix=PFX] #In the squere bracket is the operational parameter which specifies the installation path.如果提示bad interpreter: No such file or directory, 一般是因为Linux无法识别出Windows的DOS格式, 需要如下操作修改文件格式:
vi ./configure #Open source file :set ff #check file format in vi :set ff=unix #change file format to unix :wq! #write back and quit vi 运行命令: make && make install安装时踩坑: 请不要使用windows的git bash进行clone,clone下来的文件是dos格式而不是unix格式,会在使用wsl2进行make时遇到文件结束符的错误。
后记: 之前一直不知道linux中*-dev, *-dbg, *-utils的意思区别。查询后得知:
In general, -dev: Contains the library interface (header files) in case you are developing a program that wants to link to it. -dbg: Contains debugging symbols, which usually just used by developers linking against that software or people debugging the software. -utils: (I’m speaking from my Debian experience) Usually provides some additional command line tools. It may expose the user to internal features or just provide a CLI. Having different packages like this is all about removing features and/or accessibility to reduce file size. This allows for faster downloads and less used disk space. Packages with the -dev suffix (debian/ubuntu) or -devel suffix (red hat/centos/fedora) typically contain the files necessary if you are going to be compiling software from source that uses the associated library. They will typically contain C header files (foo.h) and the unversioned shared libraries (libfoo.so). The non-dev package has only the versioned shared libraries (libfoo.so.1.1) that are required by compiled binaries
假如有一个包叫libfoo.安装libfoo包实际是安装的libfoo.so.0.0,但安装libfoo-dev包却是libfoo.so.0和libfoo.so(即另外两个库文件版本的链接)。你同时安装了新库和旧库,这样使用旧版本库的软件和使用新版本库的软件就同时使用。