objdump 和 r eadelf 的功能很类似,都可以显示 ELF格式文件的各种内容。但肯定是有区别的,原因在 readelf.c 中有提到 :
/* The difference between readelf and objdump:
Both programs are capable of displaying the contents of ELF format files,
so why does the binutils project have two file dumpers ?
The reason is that objdump sees an ELF file through a BFD filter of the
world; if BFD has a bug where, say, it disagrees about a machine constant
in e_flags, then the odds are good that it will remain internally
consistent. The linker sees it the BFD way, objdump sees it the BFD way,
GAS sees it the BFD way. There was need for a tool to go find out what
the file actually says.
This is why the readelf program does not link against the BFD library - it
exists as an independent program to help verify the correct working of BFD.
There is also the case that readelf can provide more information about an
ELF file than is provided by objdump. In particular it can display DWARF
debugging information which (at the moment) objdump cannot. */
一、objdump使用 BFD filter 过滤文件内容,而readelf则没有.
二、还有的情况下readelf会比objdump显示更多的信息。特别是他可以显示DWARF调试信息,而objdump不能。但是BFD filrter 支持DWARF的处理,只需要简单的设置一下。