1. S源码分析-扫盲源码调试环境搭建(x86_64)
1. 1 所需软件
软件 | 链接位置 |
---|---|
ubuntu-20.04.3-desktop-amd64.iso | 链接:https://pan.baidu.com/s/13KxqAkmOTDp6apglr_f_4w 提取码:star |
linux-5.8.6.tar.xz | https://download.csdn.net/download/tan1666/82501446 |
busybox-1.32.0.tar_.bz2 | https://download.csdn.net/download/tan1666/82506515 |
rootfs.f2fs | https://download.csdn.net/download/tan1666/82559775 |
1. 2 编译x86
- 解压 linux-5.8.6.tar.xz,并将文件系统rootfs.f2fs 拷贝到linux-5.8.6中。执行如下脚本命令。
tar -xvf linux-5.8.6.tar.xz
make x86_64_defconfig
make menuconfig
#配置如下
Processor type and features --->
[ ] Randomize the address of the kernel image (KASLR) 不要选
Drevice Drivers --->
NVME Support
<*> NVM Express block device
[*] NVMe multipath support
[*] NVMe hardware monitoring
<*> NVM Express over Fabrics FC host driver
<*> NVM Express over Fabrics TCP host driver
File systems --->
<*> F2FS filesystem support
[*] F2FS Status Information (NEW)
[*] F2FS extended attributes (NEW)
[*] F2FS Access Control Lists (NEW)
Kernel hacking --->
Compile-time checks and compiler options --->
[*] Compile the kernel with debug info
[*] Provide GDB scripts for kernel debugging
make -j4 bzImage
qemu-system-x86_64 -kernel arch/x86_64/boot/bzImage -drive file=rootfs.f2fs,if=ide,format=raw -nographic -append "root=/dev/sda console=ttyS0"
target remote :1234
-
执行结果
-
后期运行命令
编译:
cd /home/tan/x86/linux-5.8.6;make -j8 bzImage
调试:
cd /home/tan/x86/linux-5.8.6;killall qemu-system-x86_64;qemu-system-x86_64 -kernel arch/x86_64/boot/bzImage -drive file=rootfs.f2fs,if=ide,format=raw -nographic -append "root=/dev/sda console=ttyS0" -S -s& killall gdb;gdb --tui vmlinux
2. 总结
将文件系统拷贝到linux内核源码目录下, 执行上面命令后可得到最后结果。
内核学习推荐: https://ke.qq.com/course/4032547?flowToken=1042213
2.1 技术参考
参考资料1:https://blog.csdn.net/geshifei/article/details/119869405