Compile build debug the Linux kernel networking code system environment MenuOS

Compile build debug the Linux kernel networking code system environment MenuOS

The operation command given reference, divided into the following steps:

  1. Installation compile the kernel depends

    sudo apt install build-essential flex bison libssl-dev libelf-dev libncurses-dev

    The installation process may experience slow download speeds and lead to failure, the software can be replaced from another source or network. . .
  2. Download and compile the kernel

    Here had a little problem, that is the official website download speed is too slow .... suggestions directly to the official website, copy the link to the right address, and then use Thunder download, pro-test download speeds up to 6M / s
    Download the kernel

    • Compile the kernel

      make i386_defconfig # accordance with the default kernel configuration file to generate
      the make menuconfig
      the make or make -j #j as the number of CPU cores
      Compile the kernel

After entering these two commands will enter a visual interface for configuring the kernel, as follows:
(1) Enter Select Kernel hacking
(2) Select Compile-time checks and compiler options carriage
(3) Select Compile the kernel with debug info press the spacebar, and then save directly to the default cursor left to save the last exit

  1. Production root file virtual machine
    • Install qemu

      sudo apt install qemu
      qemu-system-i386 -kernel linux-5.0.1/arch/x86/boot/bzImage #qemu加载linux内核

    • 构建MenuOS

      git clone https://github.com/mengning/menu.git
      sudo apt-get install libc6-dev-i386 #安装libc6-dev-i386
      qemu -kernel linux-5.0.1/arch/x86/boot/bzImage -initrd rootfs.img #创建系统镜像 (linux-5.0.1目录下)
      make rootfs #初始化(menu目录下)
      Start MenuOS

  2. 构建gdb调试环境
    • 在qemu中启动gdb server

      qemu -kernel linux-5.0.1/arch/x86/boot/bzImage -initrd rootfs.img -append nokaslr -s -S

    • 建立gdb server和gdb之间的连接
      不要关闭当前正处于黑屏状态的gdb server,打开一个新终端,输入gdb

      cd linux-5.0.1
      file vmlinux #加载符号表
      break start_kernel #在内核函数处设置断点
      target remote:1234 #建立gdb和gdb server之间的连接
      c #回车让qemu上的Linux继续运行
      list #查看之前设置的断点
      Start gdb server
      Server connection gdb and gdb

  3. 将TCP网络程序集成到MenuOS中运行 The results are as follows:
    Experimental results

Guess you like

Origin www.cnblogs.com/sa19225475/p/12018741.html