see also : nm - readelf
- Objdump Intel Syntax
- Objdump Command
- Objdump Command
- Objdump Example
- Linux Objdump
- Objdump -o
- Objdump Windows
Synopsis
objdump[-a|--archive-headers]
[-bbfdname|--target=bfdname]
[-C|--demangle[=style]]
[-d|--disassemble]
[-D|--disassemble-all]
[-z|--disassemble-zeroes]
[-EB|-EL|--endian={big| little }]
[-f|--file-headers]
[-F|--file-offsets]
[--file-start-context]
[-g|--debugging]
[-e|--debugging-tags]
[-h|--section-headers|--headers]
[-i|--info]
[-jsection|--section=section]
[-l|--line-numbers]
[-S|--source]
[-mmachine|--architecture=machine]
[-Moptions|--disassembler-options=options]
[-p|--private-headers]
[-Poptions|--private=options]
[-r|--reloc]
[-R|--dynamic-reloc]
[-s|--full-contents]
[-W[lLiaprmfFsoRt]|
--dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index]]
[-G|--stabs]
[-t|--syms]
[-T|--dynamic-syms]
[-x|--all-headers]
[-w|--wide]
[--start-address=address]
[--stop-address=address]
[--prefix-addresses]
[--[no-]show-raw-insn]
[--adjust-vma=offset]
[--special-syms]
[--prefix=prefix]
[--prefix-strip=level]
[--insn-width=width]
[-V|--version]
[-H|--help]
objfile...
add an example, a script, a trick and tips
- See full list on linux.die.net.
- 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 eflags, 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.
- Objdump is a command-line program for displaying various information about object files on Unix-like operating systems.For instance, it can be used as a disassembler to view an executable in assembly form.
examples
$ objdump -f assert assert: file format elf64-x86-64 architecture: i386:x86-64, flags 0x00000112: EXECP, HASSYMS, DPAGED start address 0x400620. So we see that the file header was produced in the output. Display information related to all the sections using -s option. An object file may consist of various sections. You should use otool because objdump is a binutils tool for the ELF binary format on Linux and most other UNIX systems. Otool is the the disassembler for MacOS's Mach-O binary format. Type $ man otool for instructions on use.
description
objdumpdisplays information about one or more object files. Theoptions control what particular information to display. Thisinformation is mostly useful to programmers who are workingon the compilation tools, as opposed to programmers who justwant their program to compile and work.
objfile...are the object files to be examined. When you specifyarchives, objdump shows information on each of themember object files.
options
The long andshort forms of options, shown here as alternatives, areequivalent. At least one option from the list-a,-d,-D,-e,-f,-g,-G,-h,-H,-p,-P,-r,-R,-s,-S,-t,-T,-V,-xmust be given.
-a
--archive-header
If any of the objfilefiles are archives, display the archive header information(in a format similar to ls -l). Besides theinformation you could list with ar tv, objdump-a shows the object file format of each archivemember.
--adjust-vma=offset
When dumping information, firstadd offset to all the section addresses. This isuseful if the section addresses do not correspond to thesymbol table, which can happen when putting sections atparticular addresses when using a format which can notrepresent section addresses, such as a.out.
-bbfdname
--target=bfdname
Specify that the object-codeformat for the object files is bfdname. This optionmay not be necessary; objdump can automaticallyrecognize many formats.
Forexample,
displayssummary information from the section headers(-h) of fu.o, which is explicitlyidentified (-m) as a VAX objectfile in the format produced by Oasys compilers. You can listthe formats available with the -i option.
-C
--demangle[=style]
Decode (demangle)low-level symbol names into user-level names. Besidesremoving any initial underscore prepended by the system,this makes C ++ function names readable.Different compilers have different mangling styles. Theoptional demangling style argument can be used to choose anappropriate demangling style for your compiler.
-g
--debugging
Display debugging information.This attempts to parse STABS andIEEE debugging format information stored inthe file and print it out using a C like syntax. If neitherof these formats are found this option falls back on the-W option to print any DWARFinformation in the file.
-e
--debugging-tags
Like -g, but theinformation is generated in a format compatible with ctagstool.
-d
--disassemble
Display the assembler mnemonicsfor the machine instructions from objfile. Thisoption only disassembles those sections which are expectedto contain instructions.
-D
--disassemble-all
Like -d, butdisassemble the contents of all sections, not just thoseexpected to contain instructions.
If the targetis an ARM architecture this switch also hasthe effect of forcing the disassembler to decode pieces ofdata found in code sections as if they wereinstructions.
--prefix-addresses
When disassembling, print thecomplete address on each line. This is the older disassemblyformat.
-EB
-EL
--endian={big|little}
Specify the endianness of theobject files. This only affects disassembly. This can beuseful when disassembling a file format which does notdescribe endianness information, such asS-records.
-f
--file-headers
Display summary informationfrom the overall header of each of the objfilefiles.
-F
--file-offsets
When disassembling sections,whenever a symbol is displayed, also display the file offsetof the region of data that is about to be dumped. If zeroesare being skipped, then when disassembly resumes, tell theuser how many zeroes were skipped and the file offset of thelocation from where the disassembly resumes. When dumpingsections, display the file offset of the location from wherethe dump starts.
--file-start-context
Specify that when displayinginterlisted source code/disassembly (assumes-S) from a file that has not yet beendisplayed, extend the context to the start of the file.
-h
--section-headers
--headers
Display summary informationfrom the section headers of the object file.
File segmentsmay be relocated to nonstandard addresses, for example byusing the -Ttext, -Tdata, or-Tbss options to ld. However, someobject file formats, such as a.out, do not store thestarting address of the file segments. In those situations,although ld relocates the sections correctly, usingobjdump -h to list the file section headerscannot show the correct addresses. Instead, it shows theusual addresses, which are implicit for the target.
-H
--help
Print a summary of the optionsto objdump and exit.
-i
--info
Display a list showing allarchitectures and object formats available for specificationwith -b or -m.
-jname
--section=name
Display information only forsection name.
-l
--line-numbers
Label the display (usingdebugging information) with the filename and source linenumbers corresponding to the object code or relocs shown.Only useful with -d, -D, or-r.
-mmachine
--architecture=machine
Specify the architecture to usewhen disassembling object files. This can be useful whendisassembling object files which do not describearchitecture information, such as S-records. You canlist the available architectures with the -ioption.
If the targetis an ARM architecture then this switch hasan additional effect. It restricts the disassembly to onlythose instructions supported by the architecture specifiedby machine. If it is necessary to use this switchbecause the input file does not contain any architectureinformation, but it is also desired to disassemble all theinstructions use -marm.
-Moptions
--disassembler-options=options
Pass target specificinformation to the disassembler. Only supported on sometargets. If it is necessary to specify more than onedisassembler option then multiple -M optionscan be used or can be placed together into a comma separatedlist.
If the targetis an ARM architecture then this switch canbe used to select which register name set is used duringdisassembler. Specifying -M reg-names-std (thedefault) will select the register names as used inARM ’s instruction set documentation,but with register 13 called ’sp’, register 14called ’lr’ and register 15 called’pc’. Specifying -M reg-names-apcswill select the name set used by the ARMProcedure Call Standard, whilst specifying -Mreg-names-raw will just use r followed by theregister number.
There are alsotwo variants on the APCS register namingscheme enabled by -M reg-names-atpcs and-M reg-names-special-atpcs which use theARM/Thumb Procedure Call Standard naming conventions.(Either with the normal register names or the specialregister names).
This option canalso be used for ARM architectures to forcethe disassembler to interpret all instructions as Thumbinstructions by using the switch--disassembler-options=force-thumb.This can be useful when attempting to disassemble thumb codeproduced by other compilers.
For the x86,some of the options duplicate functions of the-m switch, but allow finer grained control.Multiple selections from the following may be specified as acomma separated string. x86-64, i386 andi8086 select disassembly for the given architecture.intel and att select between intel syntax modeand AT&T syntax mode.intel-mnemonic and att-mnemonic select betweenintel mnemonic mode and AT&T mnemonicmode. intel-mnemonic implies intel andatt-mnemonic implies att. addr64,addr32, addr16, data32 anddata16 specify the default address size and operandsize. These four options will be overridden ifx86-64, i386 or i8086 appearlater in the option string. Lastly, suffix, when inAT&T mode, instructs the disassembler toprint a mnemonic suffix even when the suffix could beinferred by the operands.
For PowerPC,booke controls the disassembly of BookE instructions.32 and 64 select PowerPC and PowerPC64disassembly, respectively. e300 selects disassemblyfor the e300 family. 440 selects disassembly for thePowerPC 440. ppcps selects disassembly for the pairedsingle instructions of the PPC750CL .
ForMIPS , this option controls the printing ofinstruction mnemonic names and register names indisassembled instructions. Multiple selections from thefollowing may be specified as a comma separated string, andinvalid options are ignored:
'no-aliases'
Print the ’raw’instruction mnemonic instead of some pseudo instructionmnemonic. I.e., print ’daddu’ or’or’ instead of ’move’,’sll’ instead of ’nop’, etc.
'gpr-names=ABI'
Print GPR(general-purpose register) names as appropriate for thespecified ABI . By default,GPR names are selected according to theABI of the binary being disassembled.
'fpr-names=ABI'
Print FPR(floating-point register) names as appropriate for thespecified ABI . By default,FPR numbers are printed rather thannames.
'cp0-names=ARCH'
Print CP0(system control coprocessor; coprocessor 0) register namesas appropriate for the CPU or architecturespecified by ARCH . By default,CP0 register names are selected according tothe architecture and CPU of the binary beingdisassembled.
'hwr-names=ARCH'
Print HWR(hardware register, used by the 'rdhwr'instruction) names as appropriate for the CPUor architecture specified by ARCH . Bydefault, HWR names are selected according tothe architecture and CPU of the binary beingdisassembled.
'reg-names=ABI'
Print GPR andFPR names as appropriate for the selectedABI .
'reg-names=ARCH'
Print CPU-specific registernames ( CP0 register and HWRnames) as appropriate for the selected CPU orarchitecture.
For any of theoptions listed above, ABI orARCH may be specified asnumeric to have numbers printed rather than names,for the selected types of registers. You can list theavailable values of ABI andARCH using the--help option.
ForVAX , you can specify function entryaddresses with -M entry:0xf00ba. You can usethis multiple times to properly disassembleVAX binary files that don’t containsymbol tables (like ROM dumps). In thesecases, the function entry mask would otherwise be decoded asVAX instructions, which would probably leadthe rest of the function being wrongly disassembled.
-p
--private-headers
Print information that isspecific to the object file format. The exact informationprinted depends upon the object file format. For some objectfile formats, no additional information is printed.
-Poptions
--private=options
Print information that isspecific to the object file format. The argumentoptions is a comma separated list that depends on theformat (the lists of options is displayed with thehelp).
ForXCOFF , the available options are:header, aout, sections, syms,relocs, lineno, loader, except,typchk, traceback and toc.
-r
--reloc
Print the relocation entries ofthe file. If used with -d or -D,the relocations are printed interspersed with thedisassembly.
-R
--dynamic-reloc
Print the dynamic relocationentries of the file. This is only meaningful for dynamicobjects, such as certain types of shared libraries. As for-r, if used with -d or-D, the relocations are printed interspersedwith the disassembly.
-s
--full-contents
Display the full contents ofany sections requested. By default all non-empty sectionsare displayed.
-S
--source
Display source code intermixedwith disassembly, if possible. Implies -d.
--prefix=prefix
Specify prefix to add tothe absolute paths when used with -S.
--prefix-strip=level
Indicate how many initialdirectory names to strip off the hardwired absolute paths.It has no effect without--prefix=prefix.
--show-raw-insn
When disassemblinginstructions, print the instruction in hex as well as insymbolic form. This is the default except when--prefix-addresses is used.
--no-show-raw-insn
When disassemblinginstructions, do not print the instruction bytes. This isthe default when --prefix-addressesis used.
--insn-width=width
Display width bytes on asingle line when disassembling instructions.
-W[lLiaprmfFsoRt]
--dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index]
Displays the contents of thedebug sections in the file, if any are present. If one ofthe optional letters or words follows the switch then onlydata found in those specific sections will be dumped.
Note that thereis no single letter option to display the content of tracesections or .gdb_index.
Note: theoutput from the =info option can also be affected bythe options --dwarf-depth, the--dwarf-start and the--dwarf-check.
--dwarf-depth=n
Limit the dump of the'.debug_info' section to nchildren. This is only useful with--dwarf=info. The default is to print allDIEs; the special value 0 for n will also have thiseffect.
With a non-zerovalue for n, DIEs at or deeper than n levelswill not be printed. The range for n iszero-based.
--dwarf-start=n
Print only DIEs beginning withthe DIE numbered n. This is onlyuseful with --dwarf=info.
If specified,this option will suppress printing of any header informationand all DIEs before the DIE numberedn. Only siblings and children of the specifiedDIE will be printed.
This can beused in conjunction with--dwarf-depth.
--dwarf-check
Enable additional checks forconsistency of Dwarf information.
-G
--stabs
Display the full contents ofany sections requested. Display the contents of the .staband .stab.index and .stab.excl sections from anELF file. This is only useful on systems(such as Solaris 2.0) in which '.stab'debugging symbol-table entries are carried in anELF section. In most other file formats,debugging symbol-table entries are interleaved with linkagesymbols, and are visible in the --symsoutput.
--start-address=address
Objdump Intel Syntax
Start displaying data at thespecified address. This affects the output of the-d, -r and -soptions.
--stop-address=address
Stop displaying data at thespecified address. This affects the output of the-d, -r and -soptions.
-t
--syms
Print the symbol table entriesof the file. This is similar to the information provided bythe nm program, although the display format isdifferent. The format of the output depends upon the formatof the file being dumped, but there are two main types. Onelooks like this:
Objdump Command
where thenumber inside the square brackets is the number of the entryin the symbol table, the sec number is the sectionnumber, the fl value are the symbol’s flagbits, the ty number is the symbol’s type, thescl number is the symbol’s storage class andthe nx value is the number of auxilary entriesassociated with the symbol. The last two fields are thesymbol’s value and its name.
The othercommon output format, usually seen with ELFbased files, looks like this:
Here the firstnumber is the symbol’s value (sometimes refered to asits address). The next field is actually a set of charactersand spaces indicating the flag bits that are set on thesymbol. These characters are described below. Next is thesection with which the symbol is associated or *ABS*if the section is absolute (ie not connected with anysection), or *UND* if the section is referenced inthe file being dumped, but not defined there.
After thesection name comes another field, a number, which for commonsymbols is the alignment and for other symbol is the size.Finally the symbol’s name is displayed.
The flagcharacters are divided into 7 groups as follows:
'l'
'g'
Objdump Command
'u'
'!'
The symbol is a local (l), global (g), unique global(u), neither global nor local (a space) or both global andlocal (!). A symbol can be neither local or global for avariety of reasons, e.g., because it is used for debugging,but it is probably an indication of a bug if it is ever bothlocal and global. Unique global symbols are aGNU extension to the standard set ofELF symbol bindings. For such a symbol thedynamic linker will make sure that in the entire processthere is just one symbol with this name and type in use.
'w'
The symbol is weak (w) or strong (a space).
'C'
The symbol denotes a constructor (C) or an ordinarysymbol (a space).
'W'
The symbol is a warning (W) or a normal symbol (aspace). A warning symbol’s name is a message to bedisplayed if the symbol following the warning symbol is everreferenced.
'I'
Objdump Example
'i'
The symbol is an indirect reference to another symbol(I), a function to be evaluated during reloc processing (i)or a normal symbol (a space).
'd'
'D'
The symbol is a debugging symbol (d) or a dynamic symbol(D) or a normal symbol (a space).
'F'
'f'
'O'
The symbol is the name of a function (F) or a file (f)or an object (O) or just a normal symbol (a space).
-T
--dynamic-syms
Print the dynamic symbol tableentries of the file. This is only meaningful for dynamicobjects, such as certain types of shared libraries. This issimilar to the information provided by the nm programwhen given the -D(--dynamic) option.
--special-syms
Linux Objdump
When displaying symbols includethose which the target considers to be special in some wayand which would not normally be of interest to the user.
-V
--version
Print the version number ofobjdump and exit.
-x
--all-headers
Display all available headerinformation, including the symbol table and relocationentries. Using -x is equivalent to specifyingall of -a -f -h -p -r-t.
-w
'C'
The symbol denotes a constructor (C) or an ordinarysymbol (a space).
'W'
The symbol is a warning (W) or a normal symbol (aspace). A warning symbol’s name is a message to bedisplayed if the symbol following the warning symbol is everreferenced.
'I'
Objdump Example
'i'
The symbol is an indirect reference to another symbol(I), a function to be evaluated during reloc processing (i)or a normal symbol (a space).
'd'
'D'
The symbol is a debugging symbol (d) or a dynamic symbol(D) or a normal symbol (a space).
'F'
'f'
'O'
The symbol is the name of a function (F) or a file (f)or an object (O) or just a normal symbol (a space).
-T
--dynamic-syms
Print the dynamic symbol tableentries of the file. This is only meaningful for dynamicobjects, such as certain types of shared libraries. This issimilar to the information provided by the nm programwhen given the -D(--dynamic) option.
--special-syms
Linux Objdump
When displaying symbols includethose which the target considers to be special in some wayand which would not normally be of interest to the user.
-V
--version
Print the version number ofobjdump and exit.
-x
--all-headers
Display all available headerinformation, including the symbol table and relocationentries. Using -x is equivalent to specifyingall of -a -f -h -p -r-t.
-w
--wide
Format some lines for outputdevices that have more than 80 columns. Also do not truncatesymbol names when they are displayed.
-z
--disassemble-zeroes
Normally the disassembly outputwill skip blocks of zeroes. This option directs thedisassembler to disassemble those blocks, just like anyother data.
Objdump -o
@file
Objdump Windows
Read command-line options fromfile. The options read are inserted in place of theoriginal @file option. If file does not exist,or cannot be read, then the option will be treatedliterally, and not removed.
Options infile are separated by whitespace. A whitespacecharacter may be included in an option by surrounding theentire option in either single or double quotes. Anycharacter (including a backslash) may be included byprefixing the character to be included with a backslash. Thefile may itself contain additional @fileoptions; any such options will be processed recursively.
copyright
Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled ' GNU Free Documentation License'.
see also
nm , readelf , and the Info entries forbinutils.
There are many ways to update an embedded system in the field. Images can fly through the air one a time, travel by sneaker or hitch a ride on other passing data. OK, maybe that’s a stretch, but there are certainly a plethora of ways to get those sweet update bytes into a target system. How are those bytes assembled, and what are the tools that do the assembly? This is the problem I needed to solve.
Recall, my system wasn’t a particularly novel one (see the block diagram below). Just a few computers asking each other for an update over some serial busses. I had chosen to bundle the payload firmware images into the binary for the intermediate microcontroller which was to carry out the update process. The additional constraint was that the blending of the three firmware images (one carrier and two payload) needed to happen long after compile time, on a different system with a separate toolchain. There were ultimately two options that fit the bill.