我正在使用 Qemu 学习一些 linux 内核开发/hacking,并想调试 Linux (2.6.34.3) 的启动过程。我已经针对 ARM 多功能平台进行了编译,并且正在使用 Codesourcerys arm-none-eabi 交叉编译器。我使用 Eclipse 作为使用 gdbserver 构建和调试的环境。
所以我设法在 qemu 中成功构建和运行内核,但问题是我在启动过程中没有看到调试器中的任何源代码 (在地址 0),我只能看到反汇编代码。但是,当它在init/main.c(地址超过0xC0000000)切换到虚拟内存时,源代码出现,我可以看到源代码并逐步遍历代码。这是为什么?我从一开始就想要。
有人对如何调试Linux的启动过程有任何提示吗? google 中的所有指南都展示了如何调试内核,但它们都从 start_kernel()(位于 init/main.c 中)而不是从启动过程的开始(在 arch/arm/boot/compressed/head.S )。请有经验的 friend 帮忙,谢谢!
Looked into the System.map in the root folder and there is only symbols for stuff from c0004000 (where the virtual address start). I load vmlinux into gdbserver to get debug information, Maybe thats why theres no source?
最佳答案
Linux 内核使用两步引导处理(这不包括任何引导加载程序,如 u-Boot ...)。您可以更好地理解这一点,尤其是通过查看 2 个 .lds 文件(详见下文)进行链接:
arch/arm/boot/compressed/vmlinux.lds.in
,生成 arch/arm/boot/compressed/vmlinux.lds
.与
arch/arm/boot/compressed
中的其他 .o 文件一起,在这个文件夹中生成了一个 vmlinux。您可以使用
arm-none-eabi-nm -a -n arch/arm/boot/compressed/vmlinux
查看此阶段的符号。所有地址都是物理地址。这些符号不包含在 System.map
arch/arm/kernel/vmlinux.lds
生成(注:路径不同)我希望这能解释为什么您在 Eclipse 中看不到启动源代码。
关于linux-kernel - Qemu arm Linux内核开机调试,无源码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11423784/