How do I best determine if a binary contains STAB or DWARF debug information?

元气小坏坏 提交于 2019-12-24 14:14:51

问题


When it comes to ELF, two accompanying debugging formats are overwhelmingly popular to others, namely STAB and DWARF. I'd like an easy way to ascertain whether a given binary contains debug information of one form or the other, preferably without having to inspect section names (.stab, etc.).

What are good ways of accomplishing this?


回答1:


When it comes to ELF, two accompanying debugging formats are overwhelmingly popular

The STABS format has not been used by default by any current compilers on ELF platforms for the last 10 years. It's definitely not "overwhelmingly popular".

The way to tell:

readelf -WS ./a.out | egrep '\.(stab |debug)'

You will see .stab section if the binary has STABS. You will see .debug_info, .debug_line, etc. if you have DWARF. You'll see nothing if you don't have debug info at all.

preferably without having to inspect section names

Can't be done without looking at sections: it's the presence or absence of these sections that makes the binary contain or not contain debug info.



来源:https://stackoverflow.com/questions/29297711/how-do-i-best-determine-if-a-binary-contains-stab-or-dwarf-debug-information

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!