# Readelf

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Readelf
> Markdown URL: https://mediated.wiki/source/Readelf.md
> Source: https://en.wikipedia.org/wiki/Readelf
> Source revision: 1235567810
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{context|date=July 2018}}
'''readelf''' is a program for displaying various information about [object file](/source/object_file)s on [Unix](/source/Unix)-like systems, similar to [objdump](/source/objdump). It is part of the [GNU binutils](/source/GNU_Binutils).

== readelf and objdump ==
{{Tone|date=July 2024|section}}

Both programs are capable of displaying the contents of [ELF](/source/Executable_and_Linking_Format) format files. objdump sees an ELF file through a [BFD](/source/Binary_File_Descriptor_library) filter. If BFD has a bug where 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](/source/objdump). In particular it can display DWARF debugging information which (at the moment) objdump cannot.<ref>{{Cite web|url=https://github.com/bminor/binutils-gdb/blob/master/binutils/readelf.c|title=readelf vs. objdump: why are both needed" on binutils-gdb|last=|first=|date=|website=[GitHub](/source/GitHub)|archive-url=|archive-date=|access-date=}}</ref>

== Example ==
The following command displays the contents of the file's dynamic section (to examine the [shared library](/source/Library_(computing)) dependencies and [rpath](/source/rpath)):<ref>{{Cite web|title=readelf(1) - Linux manual page|url=https://man7.org/linux/man-pages/man1/readelf.1.html|access-date=2021-04-09|website=man7.org}}</ref><syntaxhighlight lang="console">
$ readelf -d <file name>
</syntaxhighlight>

==References==
{{reflist}}

Category:Unix programming tools
Category:GNU Project software

{{unix-stub}}

---
Adapted from the Wikipedia article [Readelf](https://en.wikipedia.org/wiki/Readelf) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Readelf?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
