2012-01-23 30 views
24

我需要了解我正在工作的項目的ELF文件佈局,我注意到這些工具的存在。 爲什麼所有的Linux發行版都包含readelf和objdump?這些工具是否相互補充?我什麼時候更喜歡用另一種?readelf與objdump:爲什麼都需要

回答

35

從binutils的/ readelf.c:

/* The difference between readelf and objdump: 

    Both programs are capabale 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. */ 
+12

約'objdump'不能夠傾倒'曾經是真正的DWARF'調試信息的評論,但自從2005年左右我 –

+1

一直沒有真正的還想補充說明,'readelf'是架構獨立的。爲了正確地「objdump」你的應用程序,你必須從相關的工具鏈中獲得一個合適的'objdump',即ARM二進制文件的ARM'objdump',X86二進制文件的'x86 objdump'等。 –