
objdump Command in Linux
The objdump command in Linux displays information about object files. An object file, usually with the .o extension, is a file created during the process of turning source code into a program. It contains the translated machine code for the instructions in your source code but isn't ready to run yet.
The objdump command analyzes and displays the details of object files, executables, and libraries. It helps developers and engineers examine the internals of these binary files, making it useful for debugging, reverse engineering, and understanding how a program works.
Table of Contents
Here is a comprehensive guide to the options available with the objdump command −
- Installation objdump Command
- Syntax of objdump Command
- objdump Command Options
- Examples of objdump Command in Linux
Installation objdump Command in Linux
By default, the objdump tool may not be available in Linux to install it, use the instructions given below −
To install objdump on Ubuntu, Kali Linux, Debian, and other Debian-based distributions, use the following command −
sudo apt install binutils
To install it on Arch Linux, use the command given below −
sudo pacman -S aarch64-linux-gnu-binutils
To install it on CentOS, use −
sudo yum install binutils
To install it on Fedora, use the following command −
sudo dnf install binutils-arc-linux-gnu
To verify the installation, check the version of the objdump command −
objdump --version

Or check the binary path using the which command −
which objdump

Syntax of objdump Command
The syntax of the Linux objdump command is as follows −
objdump [options] [file]
In the above syntax, the [options] field is used to specify options to display information such as disassembly, headers, or symbols. The [file] field is used to specify the files that need to be analyzed.
objdump Command Options
The commonly used options of the objdump command are listed below −
Flags | Options | Description |
---|---|---|
-a | --archive-headers | Displays the archive header of files that are archives |
-f | --file-headers | Displays the file header of the object file |
-h | --section-headers / --headers | Displays section headers, which show the layout of sections such as .text, .data, .bss in the object file |
-d | --disassemble | Disassembles the executable sections of the file, showing assembly instructions |
-D | --disassemble-all | Disassembles all sections, regardless of whether they are executable |
-i | --info | List object formats and architectures supported |
-p | --private-headers | Displays object format specific file header contents |
-r | --reloc | Displays relocation entries for relocatable files |
-s | --full-contents | Display the full contents of all sections requested |
-S | --source | Intermix source code with disassembly |
-t | --syms | Displays the symbol table entries in the file |
-g | --debugging | Displays debugging information, if available |
-x | --all-headers | Displays all available header information |
-Z | --decompress | Decompress section(s) before displaying their contents |
-C | --demangle | Demangles C++ symbols into human-readable form |
-H | --help | Displays all available options for the command |
-v | --version | Displays command version |
Examples of objdump Command in Linux
In this section, the usage of the Linux objdump command will be discussed with examples −
Displaying File Header
To display basic information about the file, such as the architecture and file type, use the -f or --file-headers option with the object file name −
objdump -f code.o

Displaying Format Specific File Header
To display the format-specific file header information, use the -p or --private-headers option with the objdump command −
objdump -p code.o
Displaying Section Headers
To display sections like text, data, bss, rodata use the -h or --headers option −
objdump -h code.o

Displaying All Headers
To display all headers, use the -x or --all-headers option −
objdump -x code.o

Disassembling Code
To disassemble .text section into assembly instructions, use the -d or --disassemble option −
objdump -d code.o

Disassembling All Sections
To disassemble all the sections, use the -D, or --disassemble-all option with the objdump command −
objdump -D code.o
Displaying Full Contents
To display the full contents of all sections of a file with the raw data in hexadecimal form as well, use the -s or --full-contents option −
objdump -s code.o

Displaying Symbol Table
To display the symbol table such as variables, or functions, use the -t or --syms option −
objdump -t code.o

Displaying Relocation Entries
To display the relocation entries, use the -r or --reloc option with the objdump command −
objdump -r code.o

Displaying Debugging Information
To view the debugging information, use the -g or --debugging option −
objdump -g code.o

Displaying the Supported Object Formats
To display supported object formats and architectures, use the -i or --info option −
objdump -i

Displaying Help
The objdump command comes with many optional options as well. To display all the options, use the -H or --help option −
objdump -H
Conclusion
The objdump command in Linux is used for examining object files, executables, and libraries. It provides detailed insights into binary files, helping developers with tasks like debugging and reverse engineering.
With various options, the objdump command can display file headers, disassemble code, show symbol tables, and even reveal debugging information. It is an essential tool for anyone working with low-level programming and system analysis.