Use the objdump binutil which displays information from object files to dump the disassembled code from a ELF file to a.s file. Mb-objdump -D output.S.
GNU Binutils
The GNU Binutils are a collection of binary tools. The main ones are:
- ld - the GNU linker.
- as - the GNU assembler.
But they also include:
- Objdump displays information about one or more object files. The options control what particular information to display. This information is mostly useful to programmers who are working on the compilation tools, as opposed to programmers who just want their program to compile and work. Are the object files to be examined.
- The llvm-objdump utility prints the contents of object files and final linked images named on the command line. If no file name is specified, llvm-objdump will attempt to read from a.out. If -is used as a file name, llvm-objdump will process a file on its standard input stream.
- addr2line - Converts addresses into filenames and line numbers.
- ar - A utility for creating, modifying and extracting from archives.
- c++filt - Filter to demangle encoded C++ symbols.
- dlltool - Creates files for building and using DLLs.
- gold - A new, faster, ELF only linker, still in beta test.
- gprof - Displays profiling information.
- nlmconv - Converts object code into an NLM.
- nm - Lists symbols from object files.
- objcopy - Copies and translates object files.
- objdump - Displays information from object files.
- ranlib - Generates an index to the contents of an archive.
- readelf - Displays information from any ELF format object file.
- size - Lists the section sizes of an object or archive file.
- strings - Lists printable strings from files.
- strip - Discards symbols.
- windmc - A Windows compatible message compiler.
- windres - A compiler for Windows resource files.
Most of these programs use BFD, the Binary File Descriptor library, to do low-level manipulation. Many of them also use the opcodes library to assemble and disassemble machine instructions.
The binutils have been ported to most major Unix variants as well as Wintel systems, and their main reason for existence is to give the GNU system (and GNU/Linux) the facility to compile and link programs.
Obtaining binutils
The latest release of GNU binutils is 2.36.1. The various NEWS files (binutils, gas, and ld) have details of what has changed in this release.
See the SOFTWARE page for information on obtaining releases of GNU binutils and other GNU software. The current release can be downloaded from https://ftp.gnu.org/gnu/binutils or, preferably, from a nearby mirror through the generic URL https://ftpmirror.gnu.org/binutils.
If you plan to do active work on GNU binutils, you can access the development source tree by anonymous git:
git clone git://sourceware.org/git/binutils-gdb.git
Alternatively, you can use the gitweb interface, or the source snapshots, available as bzipped tar files via anonymous FTP from ftp://sourceware.org/pub/binutils/snapshots.
Bug reports
There is a bug-tracking system at https://sourceware.org/bugzilla/.
Mailing lists
There are three binutils mailing lists:
- <bug-binutils@gnu.org> (archives)
- For reporting bugs.
- <binutils@sourceware.org> (archives)
- For discussing binutils issues.
- binutils-cvs (archives)
- A read-only mailing list containing the notes from checkins to the binutils git repository. (This list has an odd name for historical reasons.)
You can use this form to subscribe to the binutils@sourceware.org or binutils-cvs@sourceware.org mailing lists:
To subscribe to the bug-binutils@gnu.org mailing list, see the bug-binutils info page.
You may wish to browse the old mail archives of the gas2 and bfd mailing lists. These were the discussion lists for binutils until May 1999. Please do not send mail to them any longer.
Documentation
The documentation for binutils 2.36.1 is available.
A guide to porting the binutils to a new target has been contributed.
Next: elfedit, Previous: dlltool, Up: Top [Contents][Index]
14 readelf
readelf displays information about one or more ELF format objectfiles. The options control what particular information to display.
elffile… are the object files to be examined. 32-bit and64-bit ELF files are supported, as are archives containing ELF files.
This program performs a similar function to objdump but itgoes into more detail and it exists independently of the BFDlibrary, so if there is a bug in BFD then readelf will not beaffected.
The long and short forms of options, shown here as alternatives, areequivalent. At least one option besides ‘-v’ or ‘-H’ must begiven.
-a--allEquivalent to specifying --file-header,--program-headers, --sections, --symbols,--relocs, --dynamic, --notes,--version-info, --arch-specific, --unwind,--section-groups and --histogram.
Note - this option does not enable --use-dynamic itself, soif that option is not present on the command line then dynamic symbolsand dynamic relocs will not be displayed.
-h--file-headerDisplays the information contained in the ELF header at the start of thefile.
-l--program-headers--segmentsDisplays the information contained in the file’s segment headers, if ithas any.
-S--sections--section-headersDisplays the information contained in the file’s section headers, if ithas any.
-g--section-groupsDisplays the information contained in the file’s section groups, if ithas any.
-t--section-detailsDisplays the detailed section information. Implies -S.
-s--symbols--symsDisplays the entries in symbol table section of the file, if it has one.If a symbol has version information associated with it then this isdisplayed as well. The version string is displayed as a suffix to thesymbol name, preceded by an @ character. For example‘foo@VER_1’. If the version is the default version to be usedwhen resolving unversioned references to the symbol then it isdisplayed as a suffix preceded by two @ characters. For example‘foo@@VER_2’.
--dyn-symsDisplays the entries in dynamic symbol table section of the file, if ithas one. The output format is the same as the format used by the--syms option.
--lto-symsDisplays the contents of any LTO symbol tables in the file.
-C--demangle[=style]Decode (demangle) low-level symbol names into user-level names.This makes C++ function names readable. Different compilers havedifferent mangling styles. The optional demangling style argument canbe used to choose an appropriate demangling style for yourcompiler. See c++filt, for more information on demangling.
--no-demangleDo not demangle low-level symbol names. This is the default.
--recurse-limit--no-recurse-limit--recursion-limit--no-recursion-limitEnables or disables a limit on the amount of recursion performedwhilst demangling strings. Since the name mangling formats allow foran infinite level of recursion it is possible to create strings whosedecoding will exhaust the amount of stack space available on the hostmachine, triggering a memory fault. The limit tries to prevent thisfrom happening by restricting recursion to 2048 levels of nesting.
The default is for this limit to be enabled, but disabling it may benecessary in order to demangle truly complicated names. Note howeverthat if the recursion limit is disabled then stack exhaustion ispossible and any bug reports about such an event will be rejected.
-e--headersDisplay all the headers in the file. Equivalent to -h -l -S.
-n--notesDisplays the contents of the NOTE segments and/or sections, if any.
-r--relocsDisplays the contents of the file’s relocation section, if it has one.
-u
--unwindDisplays the contents of the file’s unwind section, if it has one. Onlythe unwind sections for IA64 ELF files, as well as ARM unwind tables(.ARM.exidx / .ARM.extab) are currently supported. Ifsupport is not yet implemented for your architecture you could trydumping the contents of the .eh_frames section using the--debug-dump=frames or --debug-dump=frames-interpoptions.
-d--dynamicDisplays the contents of the file’s dynamic section, if it has one.
-V--version-infoDisplays the contents of the version sections in the file, it theyexist.
-A--arch-specificDisplays architecture-specific information in the file, if thereis any.
-D--use-dynamicWhen displaying symbols, this option makes readelf use thesymbol hash tables in the file’s dynamic section, rather than thesymbol table sections.
When displaying relocations, this option makes readelfdisplay the dynamic relocations rather than the static relocations.
-L--lint--enable-checksDisplays warning messages about possible problems with the file(s)being examined. If used on its own then all of the contents of thefile(s) will be examined. If used with one of the dumping optionsthen the warning messages will only be produced for the things beingdisplayed.
-x <number or name>--hex-dump=<number or name>Displays the contents of the indicated section as a hexadecimal bytes.A number identifies a particular section by index in the section table;any other string identifies all sections with that name in the object file.

-R <number or name>--relocated-dump=<number or name>Displays the contents of the indicated section as a hexadecimalbytes. A number identifies a particular section by index in thesection table; any other string identifies all sections with that namein the object file. The contents of the section will be relocatedbefore they are displayed.
-p <number or name>--string-dump=<number or name>Displays the contents of the indicated section as printable strings.A number identifies a particular section by index in the section table;any other string identifies all sections with that name in the object file.

-z--decompressRequests that the section(s) being dumped by x, R orp options are decompressed before being displayed. If thesection(s) are not compressed then they are displayed as is.
-c--archive-indexDisplays the file symbol index information contained in the header partof binary archives. Performs the same function as the tcommand to ar, but without using the BFD library. See ar.
-w[lLiaprmfFsOoRtUuTgAckK]--debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]Displays the contents of the DWARF debug sections in the file, if anyare present. Compressed debug sections are automatically decompressed(temporarily) before they are displayed. If one or more of theoptional letters or words follows the switch then only those type(s)of data will be dumped. The letters and words refer to the followinginformation:
a=abbrevDisplays the contents of the ‘.debug_abbrev’ section.
A=addrDisplays the contents of the ‘.debug_addr’ section.
Objdump -g
cObjdump Example
=cu_indexDisplays the contents of the ‘.debug_cu_index’ and/or‘.debug_tu_index’ sections.
f=framesDisplay the raw contents of a ‘.debug_frame’ section.
F=frame-interpDisplay the interpreted contents of a ‘.debug_frame’ section.
g=gdb_indexDisplays the contents of the ‘.gdb_index’ and/or‘.debug_names’ sections.
i=infoDisplays the contents of the ‘.debug_info’ section. Note: theoutput from this option can also be restricted by the use of the --dwarf-depth and --dwarf-start options.
k=linksDisplays the contents of the ‘.gnu_debuglink’ and/or‘.gnu_debugaltlink’ sections. Also displays any links toseparate dwarf object files (dwo), if they are specified by the DW_AT_GNU_dwo_name or DW_AT_dwo_name attributes in the‘.debug_info’ section.
K=follow-linksDisplay the contents of any selected debug sections that are found inlinked, separate debug info file(s). This can result in multipleversions of the same debug section being displayed if it exists inmore than one file.
In addition, when displaying DWARF attributes, if a form is found thatreferences the separate debug info file, then the referenced contentswill also be displayed.
l=rawlineDisplays the contents of the ‘.debug_line’ section in a rawformat.
L=decodedlineDisplays the interpreted contents of the ‘.debug_line’ section.
m=macroDisplays the contents of the ‘.debug_macro’ and/or‘.debug_macinfo’ sections.
o=locDisplays the contents of the ‘.debug_loc’ and/or‘.debug_loclists’ sections.
O=str-offsetsDisplays the contents of the ‘.debug_str_offsets’ section.
p=pubnamesDisplays the contents of the ‘.debug_pubnames’ and/or‘.debug_gnu_pubnames’ sections.
r=arangesDisplays the contents of the ‘.debug_aranges’ section.
R=RangesDisplays the contents of the ‘.debug_ranges’ and/or‘.debug_rnglists’ sections.
s=strDisplays the contents of the ‘.debug_str’, ‘.debug_line_str’and/or ‘.debug_str_offsets’ sections.
t=pubtypeDisplays the contents of the ‘.debug_pubtypes’ and/or‘.debug_gnu_pubtypes’ sections.
T=trace_arangesDisplays the contents of the ‘.trace_aranges’ section.
u=trace_abbrevDisplays the contents of the ‘.trace_abbrev’ section.
U=trace_infoDisplays the contents of the ‘.trace_info’ section.
Note: displaying the contents of ‘.debug_static_funcs’,‘.debug_static_vars’ and ‘debug_weaknames’ sections is notcurrently supported.
--dwarf-depth=nLimit the dump of the .debug_info section to n children.This is only useful with --debug-dump=info. The default isto print all DIEs; the special value 0 for n will also have thiseffect.
With a non-zero value for n, DIEs at or deeper than nlevels will not be printed. The range for n is zero-based.
--dwarf-start=nPrint only DIEs beginning with the DIE numbered n. This is onlyuseful with --debug-dump=info.
If specified, this option will suppress printing of any headerinformation and all DIEs before the DIE numbered n. Onlysiblings and children of the specified DIE will be printed.
This can be used in conjunction with --dwarf-depth.
--ctf=sectionDisplay the contents of the specified CTF section. CTF sections themselvescontain many subsections, all of which are displayed in order.
--ctf-parent=sectionSpecify the name of another section from which the CTF dictionary can inherittypes. (If none is specified, we assume the CTF dictionary inherits typesfrom the default-named member of the archive contained within this section.)
--ctf-symbols=section--ctf-strings=sectionSpecify the name of another section from which the CTF file can inheritstrings and symbols. By default, the .symtab and its linkedstring table are used.
If either of --ctf-symbols or --ctf-strings is specified, theother must be specified as well.
-I--histogramDisplay a histogram of bucket list lengths when displaying the contentsof the symbol tables.
-v--versionDisplay the version number of readelf.
-W--wideDon’t break output lines to fit into 80 columns. By defaultreadelf breaks section header and segment listing lines for64-bit ELF files, so that they fit into 80 columns. This option causesreadelf to print each section header resp. each segment one asingle line, which is far more readable on terminals wider than 80 columns.
-T--silent-truncationNormally when readelf is displaying a symbol name, and it has totruncate the name to fit into an 80 column display, it will add asuffix of [...] to the name. This command line optiondisables this behaviour, allowing 5 more characters of the name to bedisplayed and restoring the old behaviour of readelf (prior to release2.35).
-H--helpObjdump Disassemble Function
Display the command-line options understood by readelf.
Objdump -o
Next: elfedit, Previous: dlltool, Up: Top [Contents][Index]