S源码分析-扫盲源码调试环境搭建(x86_64 )

本文档详细介绍了如何在x86_64架构上搭建Linux 5.8.6内核的源码调试环境。首先,提供了所需的软件下载链接,包括Ubuntu ISO、Linux内核源码、BusyBox和F2FS文件系统。接着,通过解压和配置内核源码,选择必要的内核选项如NVM Express和F2FS支持,并启用调试信息。然后,使用`make-j4bzImage`命令编译内核,并利用QEMU进行模拟运行。最后,给出了编译和调试的命令行示例,以帮助读者理解并实践整个流程。此外,还推荐了一个内核学习资源和相关技术参考链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

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.xzhttps://download.csdn.net/download/tan1666/82501446
busybox-1.32.0.tar_.bz2https://download.csdn.net/download/tan1666/82506515
rootfs.f2fshttps://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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值