操作系统:Ubuntu-18.04.5-64bit
虚拟机软件:VMware16
课程主页:MIT6.828(2018)
环境配置 参考
$ objdump -i
$ gcc -m32 -print-libgcc-file-name #测试gcc
上面这条命令是测试gcc的,一般系统是没有gcc的,需要安装
安装gcc , gdb, git, vim
$sudo apt-get install -y build-essential gdb git vim
安装32位的支持库
$sudo apt-get install gcc-multilib
第一个包可能下载不了,可以自己搜索,或是使用下面的链接
https://mirrors.sjtug.sjtu.edu.cn/gnu/gmp/gmp-5.0.2.tar.bz2
为了方便,将以上6个压缩包放在一个文件夹下 ,~/download/mit6.828
文件夹结构
以下的操作都是在
~/download/mit6.828
目录下
安装gmp-5.0.2
$tar xjf gmp-5.0.2.tar.bz2
$cd gmp-5.0.2
$./configure --prefix=/usr/local # 可能的错误:No usable m4 in $PATH or /usr/5bin (see config.log for reasons).
$make
$sudo make install
$cd ..
逐条执行命令,每执行一条后,输出无 error
就可往下执行,后面几个安装包也是一样的
可能的错误是第3个命令,如果报错,执行以下命令,然后再次执行第3行命令
$sudo apt install m4
安装mpfr-3.1.2
$tar xjf mpfr-3.1.2.tar.bz2
$cd mpfr-3.1.2
$./configure --prefix=/usr/local
$make
$sudo make install
$cd ..
安装mpc-0.9
$tar xzf mpc-0.9.tar.gz
$cd mpc-0.9
$./configure --prefix=/usr/local
$make
$sudo make install
$cd ..
安装binutils-2.21.1
$tar xjf binutils-2.21.1.tar.bz2
$cd binutils-2.21.1
$./configure --prefix=/usr/local --target=i386-jos-elf --disable-werror
$make
$sudo make install # This step may require privilege (sudo make install)
$cd ..
#测试
$i386-jos-elf-objdump -i
# 成功安装会输出类似下面的信息
# BFD header file version (GNU Binutils) 2.21.1
# elf32-i386
# (header little endian, data little endian)
# i386...
安装gcc-core-4.6.4
$tar xjf gcc-core-4.6.4.tar.bz2
$cd gcc-4.6.4
$mkdir build
$cd build
$../configure --prefix=/usr/local --target=i386-jos-elf --disable-werror --disable-libssp --disable-libmudflap --with-newlib --without-headers --enable-languages=c MAKEINFO=missing
$make all-gcc
$sudo make install-gcc
$make all-target-libgcc #可能会报错 [configure-target-libgcc] Error 1
$sudo make install-target-libgcc
$cd ../..
#测试
$i386-jos-elf-gcc -v
# 成功安装会输出类似下面的信息
# Using built-in specs.
# COLLECT_GCC=i386-jos-elf-gcc
# COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i386-jos-elf/4.6.4/lto-wrapper
# Target: i386-jos-elf
执行11行命令可能会报错,如果报错,执行以下命令,然后再次执行第11行命令
$export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
安装gdb-7.3.1
$tar xjf gdb-7.3.1.tar.bz2
$cd gdb-7.3.1
$./configure --prefix=/usr/local --target=i386-jos-elf --program-prefix=i386-jos-elf- --disable-werror
$make all #可能的错误 no termcap library found
$sudo make install
$cd ..
可能报错的命令第5个,如果出现错误,执行以下命令,然后再执行该命令
$wget http://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz
$tar -zxv -f termcap-1.3.1.tar.gz
$cd termcap-1.3.1
$ ./configure
$make
$sudo make install
$sudo apt install libsdl1.2-dev libtool-bin libglib2.0-dev libz-dev libpixman-1-dev
$sudo apt install python2
qemu需要用6.828定制的
$git clone https://github.com/mit-pdos/6.828-qemu.git qemu
$./configure --disable-kvm --disable-werror --prefix=/usr/local --target-list="i386-softmmu x86_64-softmmu" --python=python2
$make
$sudo make install
可能的错误:
缺少一个头文件,错误如下
qga/commands-posix.c: In function ‘dev_major_minor’:
qga/commands-posix.c:633:13: error: In the GNU C Library, "major" is defined
by <sys/sysmacros.h>. For historical compatibility, it is
currently defined by <sys/types.h> as well, but we plan to
remove this soon. To use "major", include <sys/sysmacros.h>
directly. If you did not intend to use a system-defined macro
"major", you should undefine it after including <sys/types.h>. [-Werror]
*devmajor = major(st.st_rdev);
^~~~~~~~~~~~~~~~~~~~~~~~~~
解决:在 qga/commands-posix.c文件中的 #include <sys/types.h> 下面增加#include <sys/sysmacros.h>即可
#下载实验源码
$git clone https://pdos.csail.mit.edu/6.828/2018/jos.git lab
$cd lab
$make
$make qemu-nox
测试成功
原文:https://www.cnblogs.com/kinvy/p/15074844.html