如何知道链接到二进制可执行文件的调试符号文件的名称和/或路径? [英] How to know the name and/or path of the debug symbol file which is linked to a binary executable?

查看:154
本文介绍了如何知道链接到二进制可执行文件的调试符号文件的名称和/或路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何知道链接到二进制可执行文件的调试符号文件的名称和/或路径?

How to know the name and/or path of the debug symbol file which is linked to a binary executable?

假设您这样做:

objcopy --only-keep-debug foo foo.dbg
objcopy --strip-debug foo
objcopy --add-gnu-debuglink=foo.dbg foo

现在foo.dbg具有调试符号,foo仅具有gdb可以使用的指向foo.dbg的链接. 由于gdb可以从foo知道符号文件,因此如果不实际运行gdb怎么知道呢?

Now foo.dbg has debug symbols, foo only has the link to foo.dbg that gdb can use. Since gdb can know the symbol file from foo, how can we know same without actually running gdb?

我观察到,即使我将可执行文件从foo重命名为xyz,gdb仍会从foo.dbg中加载符号,因此它与binaryname.extension不同, 并且扩展名仍然是可选的.

I have observed that even if I rename the executable from foo to xyz still gdb loads symbols from foo.dbg so it is not like binaryname.extension, and extension is optional anyway.

推荐答案

不实际运行gdb怎么知道?

how can we know same without actually running gdb?

这两个命令都将告诉您:

Either of these commands will tell you:

readelf -x.gnu_debuglink foo
objdump -sj.gnu_debuglink foo

objcopy --add-gnu-debuglink只需添加.gnu_debuglink部分,其中包含给定路径以及调试文件的校验和.

The objcopy --add-gnu-debuglink simply adds .gnu_debuglink section containing the given path, and a checksum of the debug file.

更多信息此处.

这篇关于如何知道链接到二进制可执行文件的调试符号文件的名称和/或路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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