构建调试Linux内核网络代码的环境MenuOS系统
下载内核
xz -d linux-5.0.1.tar.xz tara -xvf linux-5.0.1.tar cd linux-5.0.1
下载编译工具
sudo apt install build-essential flex bison libssl-dev libelf-dev libncurses-dev 这一步要分开装,不然无效
配置编译内核
make i386_defconfig
通过QEMU虚拟机加载内核
sudo apt install qemu qemu-system-i386 -kernel linux-5.0.1/arch/x86/boot/bzImage #make i386_defconfig qemu-system-x86_64 -kernel linux-5.0.1/arch/x86_64/boot/bzImage
构造MenuOS
git clone https://github.com/mengning/menu.git cd menu sudo apt-get install libc6-dev-i386 make rootfs cd .. qemu-system-i386 -kernel linux-5.0.1/arch/x86/boot/bzImage -initrd rootfs.img #makei386_defconfig qemu-system-x86_64 -kernel linux-5.0.1/arch/x86_64/boot/bzImage -initrd
构建MenuOS
cd LinuxKernel qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img
qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img -s -S # 关于-s和-S选项的说明: -S freeze CPU at startup (use ’c’ to start execution) -s shorthand for -gdb tcp::1234 若不想使用1234端口,则可以使用-gdb tcp:xxxx来取代-s选项
gdb (gdb)file linux-3.18.6/vmlinux # 在gdb界面中targe remote之前加载符号表 (gdb)target remote:1234 # 建立gdb和gdbserver之间的连接,按c 让qemu上的Linux继续运行 (gdb)break start_kernel # 断点的设置可以在target remote之前,也可以在之后
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20