如何将内核调试信息构建为单独的文件? [英] How to build kernel debug info as separate file?

查看:214
本文介绍了如何将内核调试信息构建为单独的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When we share custom built kernel, It is common to give without debug info.

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

Similar to sudo apt-get install linux-image-$(uname -r)-dbgsym, I would like to create separate debug info file for custom built kernel.

此处

Here and here they explained generally. I request to share knowledge on creating separate debug info file for entire linux kernel.

用于示例程序

$ 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

But while trying with vmlinux

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

缺少某些内容???

推荐答案

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

vmlinux is a binary blob. The file you're looking for is vmlinux.bin (which is the elf intermediate).

像魅力一样工作:

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

这篇关于如何将内核调试信息构建为单独的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆