2012-01-23 8 views
24

내가 작업하고있는 프로젝트의 ELF 파일 레이아웃에 대해 알아야하고 이러한 도구가 있음을 눈치 챘습니다. 모든 Linux 배포판에 readelf 및 objdump가 모두 포함되어있는 이유는 무엇입니까? 이 도구들이 서로 보완합니까? 언제 다른 것을 사용하는 것을 선호합니까? 바이너리 유틸리티에서readelf 대 objdump : 둘 다 필요한 이유는 무엇입니까

답변

35

/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

I (때문에), true가되지 않았습니다 'readelf'는 아키텍처 독립적 인 메모를 추가하고 싶습니다. 앱을 적절히 objdump하기 위해서는 ARM 바이너리를위한 ARM objdump, X86 바이너리를위한 X86'objdump '등 적절한 툴체인으로부터 적절한 objdump가 있어야합니다. –