2012-01-23 10 views
24

Necesito aprender sobre el diseño de archivos ELF para un proyecto en el que estoy trabajando y noté la existencia de estas herramientas. ¿Por qué todas las distribuciones de Linux incluyen tanto readelf como objdump? ¿Estas herramientas se complementan entre sí? ¿Cuándo preferiría usar uno sobre otro?readelf vs. objdump: por qué ambos son necesarios

Respuesta

35

de 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

El comentario sobre 'objdump' no ser capaz de volcar la información de depuración' DWARF' solía ser cierto, pero no ha sido así desde aproximadamente 2005. Me –

+1

también me gustaría agregar una nota, que 'readelf' es independiente de la arquitectura. Para 'objdump' tu aplicación correctamente, tienes que tener un' objdump' apropiado de una cadena de herramientas relevante, eso es ARM 'objdump' para los binarios ARM, X86' objdump' para los binarios X86, etc. –

Cuestiones relacionadas