我如何知道 ELF 目标文件中的调试信息是什么类型?

发布于 2024-11-30 06:07:30 字数 518 浏览 7 评论 0原文

我有一个 ELF 目标文件。我想知道它包含哪种类型的调试信息。 它是用针对 PPC 架构的 Diab 编译器(C 源代码)编译的。我很确定它是用调试符号构建的。

我尝试使用 dwarfdump 提取调试信息,但没有成功,所以我猜调试信息不​​是 DWARF 类型。

$ dwarfdump file.elf
No DWARF information present in file.elf

使用 objdump 显示调试信息显示为空。

$ objdump -g file.elf 
file.elf:     file format elf32-powerpc

难道这个 ELF 文件不包含调试信息,即使 ELF 文件有名为 .debug_sfnames.debug_srcinfo.debug.srcinfo 的部分>?或者调试信息是否以 objdump 无法处理的格式存储?

I have an ELF object file. I want to know which type of debugging info it contains.
It was compiled with the Diab compiler (C source) for the PPC architecture. I'm pretty sure it was built with debugging symbols.

I have tried extracting the debugging info with dwarfdump but I doesn't work so I guess the debugging information is not of type DWARF.

$ dwarfdump file.elf
No DWARF information present in file.elf

Using objdump to show debugging information comes up empty.

$ objdump -g file.elf 
file.elf:     file format elf32-powerpc

Can it be that this ELF file does not contain debugging info even though the ELF file has sections called .debug_sfnames, .debug_srcinfo and .debug.srcinfo? Or is the debugging info stored in a format that objdump can't handle?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟柳画桥 2024-12-07 06:07:30

您可能应该使用 nm

nm 实用程序应显示出现在
目标文件、可执行文件或由文件命名的目标文件库。如果
有效的输入文件 nm 没有可用的符号信息
公用事业公司应报告该事实,但不应将其视为错误
情况。

或者,您可以使用 ldd 等工具来查看二进制文件需要哪些库。

You should probably use the nm

The nm utility shall display symbolic information appearing in the
object file, executable file, or object-file library named by file. If
no symbolic information is available for a valid input file, the nm
utility shall report that fact, but not consider it an error
condition.

Alternatively you can use tools like ldd to see what libraries are required by a binary.

╰◇生如夏花灿烂 2024-12-07 06:07:30

似乎没有人回答过您的实际问题,即:如何以编程方式确定给定 ELF 二进制文件中存在的调试符号的风格。据我所知,ELF 中并没有明确给出这一点;但是,可以通过 ELF 文件中特定节名称的存在来推断。例如:名为“.debug_info”的部分暗示 DWARF2 或更高版本,而“.stab”暗示刺。
快速谷歌搜索“.debug_sfnames”表明 DWARF1。 (我不知道为什么你的“dwarfdump”没有识别出......也许你的 dwarfdump 适用于较新的 DWARF,并转储了向后兼容性?)

It doesn't seem like anyone ever answered your actual question, which is: how to programmatically determine the flavor of debug symbols present in a given ELF binary. As best as I can tell, this isn't given explicitly within ELF; however, it can be inferred by the presence of specific section names within the ELF file. For example: a section named ".debug_info" implies DWARF2 or better, whereas ".stab" implies stabs.
A quick googling of your ".debug_sfnames" suggests DWARF1. (I don't know why your 'dwarfdump' didn't identify that... perhaps your dwarfdump is for newer DWARFs, and dumped backwards compatibility?)

快乐很简单 2024-12-07 06:07:30

在 GNU/Linux 中:

$ readelf --debug-dump=info /absolute/path/to/file | grep "Version" | uniq

返回二进制文件中使用的 DWARF 符号版本。

In GNU/Linux:

$ readelf --debug-dump=info /absolute/path/to/file | grep "Version" | uniq

Returns the DWARF symbols version used in the binary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文