2012-01-23 31 views
24

Tôi cần tìm hiểu về bố cục tệp ELF cho dự án tôi đang làm việc và tôi nhận thấy sự tồn tại của các công cụ này. Tại sao tất cả các bản phân phối Linux bao gồm cả đọc và objdump? Những công cụ này có bổ sung cho nhau không? Khi nào tôi thích sử dụng cái khác?readelf vs. objdump: tại sao cả hai cần

Trả lời

35

từ 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

Các bình luận về 'objdump' không thể đổ' DWARF' thông tin gỡ lỗi sử dụng đến mức khó tin, nhưng vẫn chưa thực sự kể từ khoảng năm 2005. Tôi –

+1

cũng muốn thêm một ghi chú, rằng 'readelf' là kiến ​​trúc độc lập. Để 'objdump' ứng dụng của bạn đúng, bạn phải có một' objdump' đúng từ một chuỗi công cụ có liên quan, đó là ARM 'objdump' cho các tệp nhị phân ARM, X86' objdump' cho các tệp nhị phân X86, v.v. –

Các vấn đề liên quan