linux - 如何将内核调试信息构建为单独的文件?

标签 linux linux-kernel arm debug-information

当我们共享定制内核时,通常不提供调试信息。

类似于 sudo apt-get install linux-image-$(uname -r)-dbgsym,我想为自定义构建的内核创建单独的调试信息文件。

Herehere他们一般性地解释。我请求分享有关为整个 Linux 内核创建单独的调试信息文件的知识。

示例程序

$ gcc -g calc.c

$ ls -l
 total 16
-rwxrwxr-x 1 jeyaram jeyaram 8424 Apr  8 09:44 a.out
-rw-rw-r-- 1 jeyaram jeyaram  246 Apr  8 09:32 calc.c

$ objcopy --only-keep-debug a.out a.debug
$ gcc calc.c -------------> compiling without debug info (skipped 'strip')
$ ls -l
total 20
-rwxrwxr-x 1 jeyaram jeyaram 4736 Apr  8 09:45 a.debug
-rwxrwxr-x 1 jeyaram jeyaram 7200 Apr  8 09:52 a.out
-rw-rw-r-- 1 jeyaram jeyaram  246 Apr  8 09:32 calc.c

$ objcopy --add-gnu-debuglink=a.debug a.out
$ gdb a.out
GNU gdb (Ubuntu/Linaro 7.4-2012.02-0ubuntu2) 7.4-2012.02
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/jeyaram/JJJ/debug_info_analysis/sample_c_test/a.out...Reading symbols from /home/jeyaram/JJJ/debug_info_analysis/sample_c_test/a.debug...done.
done.

但是在尝试使用 vmlinux 时

$ objcopy --only-keep-debug vmlinux vmlinux.debug
objcopy: Unable to recognise the format of the input file `vmlinux'

遗漏了什么???

最佳答案

vmlinux 是一个二进制 blob。您要查找的文件是 vmlinux.bin(这是 elf 中间件)。

像魅力一样工作:

objcopy --only-keep-debug vmlinux.bin vmlinux.debug

关于linux - 如何将内核调试信息构建为单独的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22910537/

相关文章:

linux - merge - 以特定顺序追加二进制文件的内容

linux - iceprog - 找不到 iCE FTDI USB 设备

php - UTF-8贯穿始终

linux-kernel - 为什么结构化类型通过结构标记而不是类型名来引用?

assembly - x86 的交叉编译 arm 程序集

python - 让 TensorFlow 在 ARM Mac 上使用 GPU

C++ Getline 并不总是在 Linux 中的多个 fork 进程中获取行

linux - 使用新驱动模块交叉编译 Linux Arm 内核

android - 获取Android Linux内核的内核命令行参数

arm - 为什么有些 ARM 指令不使用桶形移位器?