How do I best determine if a binary contains STAB

2019-08-10 07: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?

标签: elf dwarf
1条回答
看我几分像从前
2楼-- · 2019-08-10 08:36

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.

查看更多
登录 后发表回答