Linux下怎样判断一个binary是否可以debug

本文介绍了一种方法,通过运行特定的命令来判断程序是否使用了调试符号,这对于进行调试非常有用。提供了两个命令示例,一个用于检查包含调试信息的二进制文件,另一个用于检查不包含调试信息的二进制文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考:http://stackoverflow.com/questions/3284112/how-to-check-if-program-was-compiled-with-debug-symbols


用下面的命令即可,如果可以debug,则会显示debug相关的一些信息,否则没有相关信息。

objdump --syms your-binary | grep debug

objdump -t your-binary | grep debug


示例:


检查一个可以debug的binary:

[root@ampcommons02 test]# objdump -t t-debug | grep debug
t-debug:     file format elf64-x86-64
0000000000000000 l    d  .debug_aranges 0000000000000000              .debug_aranges
0000000000000000 l    d  .debug_pubnames        0000000000000000              .debug_pubnames
0000000000000000 l    d  .debug_info    0000000000000000              .debug_info
0000000000000000 l    d  .debug_abbrev  0000000000000000              .debug_abbrev
0000000000000000 l    d  .debug_line    0000000000000000              .debug_line
0000000000000000 l    d  .debug_str     0000000000000000              .debug_str
0000000000000000 l    d  .debug_pubtypes        0000000000000000              .debug_pubtypes
0000000000000000 l    d  .debug_ranges  0000000000000000              .debug_ranges

检查一个不能debug的binary:

[root@ampcommons02 test]# objdump -t t-release | grep debug


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值