1.步驟
- 安裝VMware15并安裝虛擬機 Ubuntu18.04.3
- 安裝git 和python
- 按照tools安裝編譯器工具鏈
- 編譯jos系統(tǒng)并加載
輸入命令: % objdump -i
第二行結(jié)果為elf32-i386
輸入: % gcc -m32 -print-libgcc-file-name
結(jié)果為Command 'gcc' not found, but can be installed with:
安裝gcc % sudo apt-get install -y build-essential gdb
輸入
@ubuntu:~$ gcc -m32 -print-libgcc-file-name
結(jié)果成功
/usr/lib/gcc/x86_64-linux-gnu/7/libgcc.a
下載qemu
git clone https://github.com/mit-pdos/6.828-qemu.git qemu
還可需要安裝libsdl1.2-dev快耿、libtool-bin囊陡、libglib2.0-dev、libz-dev 和 libpixman-1-dev润努。
再輸入:
1 % cd qemu/
2 % ./configure
3.% make
報錯
CC qga/commands-posix.o
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:634:13: error: In the GNU C Library, "minor" 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 "minor", include <sys/sysmacros.h>
directly. If you did not intend to use a system-defined macro
"minor", you should undefine it after including <sys/types.h>. [-Werror]
*devminor = minor(st.st_rdev);
^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
解決方法:
在 qga/commands-posix.c文件中加 #include <sys/sysmacros.h>
再報錯:
block/blkdebug.c: In function ‘blkdebug_refresh_filename’:
block/blkdebug.c:749:31: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4086 [-Werror=format-truncation=]
"blkdebug:%s:%s",
^~
In file included from /usr/include/stdio.h:862:0,
from /home/wzd/qemu/include/qemu-common.h:27,
from block/blkdebug.c:25:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output 11 or more bytes (assuming 4106) into a destination of size 4096
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
/home/wzd/qemu/rules.mak:57: recipe for target 'block/blkdebug.o' failed
解決方法:config-host.mak文件中的-Werror去掉
4. % sudo make install
下載jos源碼
git clone https://pdos.csail.mit.edu/6.828/2018/jos.git lab
% cd lab
% sudo make
報錯:
ld: warning: section `.bss' type changed to PROGBITS
obj/kern/printfmt.o: In function `printnum':
lib/printfmt.c:41: undefined reference to `__udivdi3'
lib/printfmt.c:49: undefined reference to `__umoddi3'
kern/Makefrag:70: recipe for target 'obj/kern/kernel' failed
make: *** [obj/kern/kernel] Error 1
解決方法:
% sudo apt-get install gcc-4.8-multilib
再編譯:
% sudo make
% sudo make qemu
終于成功