我需要知道二进制文件中是否有调试符号。它是一个生产系统,因此没有像 file
或 objdump
或 gdb
这样的命令。
可以在需要时提供更多信息。
操作系统:Debian
最佳答案
可能您正在寻找像 objdump 这样的工具
假设我们有这样一个小程序
#include <stdio.h>
int main()
{
printf("Hello ");
return 0;
}
现在可以正常编译
gcc example.c -o example
现在让我们使用 objdump 工具检查是否存在调试符号
objdump -h example | grep debug
我们当然找不到任何东西
现在让我们通过使用调试选项进行编译再试一次
gcc -g example.c -o example
objdump -h example | grep debug
26 .debug_aranges 00000030 0000000000000000 0000000000000000 000008b0 2**0
27 .debug_pubnames 0000001b 0000000000000000 0000000000000000 000008e0 2**0
28 .debug_info 0000008b 0000000000000000 0000000000000000 000008fb 2**0
29 .debug_abbrev 0000003f 0000000000000000 0000000000000000 00000986 2**0
30 .debug_line 0000003f 0000000000000000 0000000000000000 000009c5 2**0
31 .debug_str 00000087 0000000000000000 0000000000000000 00000a04 2**0
32 .debug_pubtypes 00000012 0000000000000000 0000000000000000 00000a8b 2**0
man -a objdump可能会有更多帮助
关于c++ - 如果没有文件、objdump 或 gdb,如何知道二进制文件是否包含调试符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17453270/