5 UNIX / Linux objdump Command Examples

What is objdump?
5 objdump examples
Syntax and Options
Related Commands

What is objdump?

The Linux objdump command is used to display various types of information stored in object files. This command is mostly used while debugging or by the developers who are working on compilation tools.

5 objdump Examples

1. Display file header using -f option

Output consisting of only the file header (ELF header) can be displayed using -f option with this command.

Consider the following example :

$ objdump -f assert

assert: file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000400620

So we see that the file header was produced in the output.

2. Display information related to all the sections using -s option

An object file may consist of various sections. To retrieve information related to all the sections, supply the -s option along with this command.

Consider the following example :

$ objdump -s assert

assert:     file format elf64-x86-64

Contents of section .interp:
 400238 2f6c6962 36342f6c 642d6c69 6e75782d  /lib64/ld-linux-
 400248 7838362d 36342e73 6f2e3200           x86-64.so.2.
Contents of section .note.ABI-tag:
 400254 04000000 10000000 01000000 474e5500  ............GNU.
 400264 00000000 02000000 06000000 0f000000  ................
Contents of section .note.gnu.build-id:
 400274 04000000 14000000 03000000 474e5500  ............GNU.
 400284 80100856 ae7aa679 536a6d82 8401e8cc  ...V.z.ySjm.....
 400294 7e6019d6                             ~`..
Contents of section .hash:
 400298 03000000 0a000000 09000000 08000000  ................
 4002a8 05000000 00000000 00000000 00000000  ................
 4002b8 00000000 03000000 01000000 02000000  ................
 4002c8 06000000 07000000 04000000           ............
Contents of section .gnu.hash:
 4002d8 01000000 01000000 01000000 00000000  ................
 4002e8 00000000 00000000 00000000
...
...
...

So we see that information related to all the sections was produced in the output.

3. Display a particular section using -j option

If we want that the output should consist only of a particular section. Then this can be done using the -j option along with this command.

Consider the following example :

$ objdump -s -j.interp assert

assert:     file format elf64-x86-64

Contents of section .interp:
 400238 2f6c6962 36342f6c 642d6c69 6e75782d  /lib64/ld-linux-
 400248 7838362d 36342e73 6f2e3200           x86-64.so.2.

So we see that details related to the section .interp was produced in the output.

4. Accept the options from file by using @ option

Rather than supplying options through command line, a file can be used to supply options to the objdump command.

Consider the following example :

$ cat options.txt
-s -j.interp assert

$ objdump @options.txt

assert:     file format elf64-x86-64. 

Contents of section .interp:
 400238 2f6c6962 36342f6c 642d6c69 6e75782d  /lib64/ld-linux-
 400248 7838362d 36342e73 6f2e3200           x86-64.so.2.

So we see that objdump command successfully accepted the options from a file and produced a relevant output.

5. Display all the header information using -x option

Information related to all the headers can be retrieved using -x option along with this command.

Consider the following example :

$ objdump -x assert

assert:     file format elf64-x86-64
assert
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000400620

Program Header:
    PHDR off    0x0000000000000040 vaddr 0x0000000000400040 paddr 0x0000000000400040 align 2**3
         filesz 0x00000000000001f8 memsz 0x00000000000001f8 flags r-x
  INTERP off    0x0000000000000238 vaddr 0x0000000000400238 paddr 0x0000000000400238 align 2**0
         filesz 0x000000000000001c memsz 0x000000000000001c flags r--
    LOAD off    0x0000000000000000 vaddr 0x0000000000400000 paddr 0x0000000000400000 align 2**21
         filesz 0x00000000000009d4 memsz 0x00000000000009d4 flags r-x
    LOAD off    0x0000000000000e18 vaddr 0x0000000000600e18 paddr 0x0000000000600e18 align 2**21
         filesz 0x0000000000000238 memsz 0x0000000000000248 flags rw-
 DYNAMIC off    0x0000000000000e40 vaddr 0x0000000000600e40 paddr 0x0000000000600e40 align 2**3
         filesz 0x00000000000001a0 memsz 0x00000000000001a0 flags rw-
    NOTE off    0x0000000000000254 vaddr 0x0000000000400254 paddr 0x0000000000400254 align 2**2
         filesz 0x0000000000000044 memsz 0x0000000000000044 flags r--
EH_FRAME off    0x0000000000000930 vaddr 0x0000000000400930 paddr 0x0000000000400930 align 2**2
         filesz 0x0000000000000024 memsz 0x0000000000000024 flags r--
   STACK off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3
         filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
   RELRO off    0x0000000000000e18 vaddr 0x0000000000600e18 paddr 0x0000000000600e18 align 2**0
         filesz 0x00000000000001e8 memsz 0x00000000000001e8 flags r--

Dynamic Section:
  NEEDED               libc.so.6
  INIT                 0x0000000000400578
  FINI                 0x00000000004008b8
  HASH                 0x0000000000400298
  GNU_HASH             0x00000000004002d8
  STRTAB               0x00000000004003e8
  SYMTAB               0x00000000004002f8
  STRSZ                0x000000000000007e
  SYMENT               0x0000000000000018
  DEBUG                0x0000000000000000
  PLTGOT               0x0000000000600fe8
  PLTRELSZ             0x00000000000000c0
  PLTREL               0x0000000000000007
  JMPREL               0x00000000004004b8
  RELA                 0x00000000004004a0
  RELASZ               0x0000000000000018
  RELAENT              0x0000000000000018
  VERNEED              0x0000000000400480
  VERNEEDNUM           0x0000000000000001
  VERSYM               0x0000000000400466

Version References:
  required from libc.so.6:
    0x09691a75 0x00 02 GLIBC_2.2.5

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .interp       0000001c  0000000000400238  0000000000400238  00000238  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .note.ABI-tag 00000020  0000000000400254  0000000000400254  00000254  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .note.gnu.build-id 00000024  0000000000400274  0000000000400274  00000274  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .hash         0000003c  0000000000400298  0000000000400298  00000298  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .gnu.hash     0000001c  00000000004002d8  00000000004002d8  000002d8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .dynsym       000000f0  00000000004002f8  00000000004002f8  000002f8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .dynstr       0000007e  00000000004003e8  00000000004003e8  000003e8  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .gnu.version  00000014  0000000000400466  0000000000400466  00000466  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 .gnu.version_r 00000020  0000000000400480  0000000000400480  00000480  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .rela.dyn     00000018  00000000004004a0  00000000004004a0  000004a0  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 10 .rela.plt     000000c0  00000000004004b8  00000000004004b8  000004b8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 11 .init         00000018  0000000000400578  0000000000400578  00000578  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 12 .plt          00000090  0000000000400590  0000000000400590  00000590  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 13 .text         00000298  0000000000400620  0000000000400620  00000620  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 14 .fini         0000000e  00000000004008b8  00000000004008b8  000008b8  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 15 .rodata       00000068  00000000004008c8  00000000004008c8  000008c8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 16 .eh_frame_hdr 00000024  0000000000400930  0000000000400930  00000930  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 17 .eh_frame     0000007c  0000000000400958  0000000000400958  00000958  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 18 .ctors        00000010  0000000000600e18  0000000000600e18  00000e18  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 19 .dtors        00000010  0000000000600e28  0000000000600e28  00000e28  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 20 .jcr          00000008  0000000000600e38  0000000000600e38  00000e38  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 21 .dynamic      000001a0  0000000000600e40  0000000000600e40  00000e40  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 22 .got          00000008  0000000000600fe0  0000000000600fe0  00000fe0  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 23 .got.plt      00000058  0000000000600fe8  0000000000600fe8  00000fe8  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 24 .data         00000010  0000000000601040  0000000000601040  00001040  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 25 .bss          00000010  0000000000601050  0000000000601050  00001050  2**3
                  ALLOC
 26 .comment      00000023  0000000000000000  0000000000000000  00001050  2**0
                  CONTENTS, READONLY
 27 .debug_aranges 00000030  0000000000000000  0000000000000000  00001073  2**0
                  CONTENTS, READONLY, DEBUGGING
 28 .debug_pubnames 0000001b  0000000000000000  0000000000000000  000010a3  2**0
                  CONTENTS, READONLY, DEBUGGING
 29 .debug_info   000001a5  0000000000000000  0000000000000000  000010be  2**0
                  CONTENTS, READONLY, DEBUGGING
 30 .debug_abbrev 000000cb  0000000000000000  0000000000000000  00001263  2**0
                  CONTENTS, READONLY, DEBUGGING
 31 .debug_line   0000007b  0000000000000000  0000000000000000  0000132e  2**0
                  CONTENTS, READONLY, DEBUGGING
 32 .debug_str    000001ce  0000000000000000  0000000000000000  000013a9  2**0
                  CONTENTS, READONLY, DEBUGGING
 33 .debug_loc    0000004c  0000000000000000  0000000000000000  00001577  2**0
                  CONTENTS, READONLY, DEBUGGING
SYMBOL TABLE:
0000000000400238 l    d  .interp	0000000000000000              .interp
0000000000400254 l    d  .note.ABI-tag	0000000000000000              .note.ABI-tag
0000000000400274 l    d  .note.gnu.build-id	0000000000000000              .note.gnu.build-id
0000000000400298 l    d  .hash	0000000000000000              .hash
00000000004002d8 l    d  .gnu.hash	0000000000000000              .gnu.hash
00000000004002f8 l    d  .dynsym	0000000000000000              .dynsym
00000000004003e8 l    d  .dynstr	0000000000000000              .dynstr
0000000000400466 l    d  .gnu.version	0000000000000000              .gnu.version
...
...
...

So we see that a detailed information was produced in the output.

Syntax and Options

objdump [options] objfile...
Short Option Long Option Option Description
-a –archive-header If any of the objfile files are archives, display the archive header information (in a format similar to ls -l). Besides the information you could list with ar tv, objdump -a shows the object file format of each archive member.
–adjust-vma=offset When dumping information, first add offset to all the section addresses. This is useful if the section addresses do not correspond to the symbol table, which can happen when putting sections at particular addresses when using a format which can not represent section addresses, such as a.out.
-C –demangle[=style] Decode (demangle) low-level symbol names into user-level names. Besides removing any initial underscore perpended by the system, this makes C++ function names readable. Different compilers have different mangling styles. The optional demangling style argument can be used to choose an appropriate demangling style for your compiler.
-e –debugging-tags Like -g, but the information is generated in a format compatible with ctags tool.
-D –disassemble-all Like -d, but disassemble the contents of all sections, not just those expected to contain instructions. If the target is an ARM architecture this switch also has the effect of forcing the disassembler to decode pieces of data found in code sections as if they were instructions.
-EB, -EL –endian={big|little} Specify the endianness of the object files. This only affects disassembly. This can be useful when disassembling a file format which does not describe endianness information, such as S-records.
-F –file-offsets When disassembling sections, whenever a symbol is displayed, also display the file offset of the region of data that is about to be dumped. If zeros are being skipped, then when disassembly resumes, tell the user how many zeros were skipped and the file offset of the location from where the disassembly resumes. When dumping sections, display the file offset of the location from where the dump starts.
-j name –section=name Display information only for section name.

Related Commands

nm
readelf