objdump

developmentLinux/Unix
The objdump command is one of the most frequently used commands in Linux/Unix-like operating systems. objdump Display information from object files

Quick Reference

Command Name:

objdump

Category:

development

Platform:

Linux/Unix

Basic Usage:

objdump [options] [arguments]

Common Use Cases

    Syntax

    objdump [options] file...

    Options

    Option Description
    -a, --archive-headers Display archive header information
    -b bfdname, --target=bfdname Specify the binary file format
    -d, --disassemble Display assembler contents of executable sections
    -D, --disassemble-all Display assembler contents of all sections
    --disassemble=symbol Display assembler contents from symbol
    -f, --file-headers Display the contents of the overall file header
    -F, --file-offsets Include file offsets when displaying information
    -g, --debugging Display debug information
    -h, --section-headers, --headers Display the contents of the section headers
    -j name, --section=name Only display information for section name
    -l, --line-numbers Include line numbers and filenames in output
    -M options, --disassembler-options=options Pass text options to the disassembler (e.g., intel, att)
    -p, --private-headers Display format-specific file header contents
    -r, --reloc Display the relocation entries in the file
    -R, --dynamic-reloc Display the dynamic relocation entries in the file
    -s, --full-contents Display the full contents of all sections requested
    -S, --source Intermix source code with disassembly
    -t, --syms Display the contents of the symbol table(s)
    -T, --dynamic-syms Display the contents of the dynamic symbol table
    -x, --all-headers Display the contents of all headers
    -z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling

    Examples

    How to Use These Examples

    The examples below show common ways to use the objdump command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    objdump -f executable
    Display the file header information.
    objdump -d executable
    Disassemble executable sections.
    # Advanced Examples Advanced
    objdump -S executable Display source code intermixed with disassembly. objdump -t executable Display the symbol table. objdump -r executable Display the relocation entries. objdump -x executable Display all available header information. objdump -D executable Disassemble all sections, not just executable ones. objdump --disassemble=main executable Disassemble only the main function. objdump -j .text -S executable Disassemble only the .text section with source code. objdump -M intel -d executable Disassemble using Intel syntax instead of AT&T.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The objdump utility is a powerful and versatile tool from the GNU Binutils package, designed to display detailed information about object files. It serves as one of the most comprehensive tools for examining the contents of compiled binaries, making it invaluable for software developers, security researchers, reverse engineers, and system administrators. As a fundamental binary analysis tool, objdump can extract and present a wide range of information from executable files, object files, and libraries. It's particularly useful for understanding how programs are structured at the machine code level, troubleshooting compilation issues, and analyzing binary files without access to the source code. Key features of the objdump command: 1. Disassembly: Perhaps objdump's most frequently used capability is its ability to convert machine code back into human-readable assembly language, allowing developers to examine exactly what instructions a program will execute. This is essential for debugging, optimization, and security analysis. 2. Header Information: The tool can display various headers from object files, providing information about the architecture, entry points, section sizes, and other critical metadata that describes how the binary is structured. 3. Symbol Table Analysis: objdump can list all symbols (function and variable names) defined or referenced in an object file, which is helpful for understanding the API of a library or the overall structure of a program. 4. Section Examination: It allows detailed inspection of specific sections within an object file, such as .text (code), .data (initialized variables), or .rodata (read-only data). 5. Relocation Information: The tool can show relocation entries, which provide information about how references to symbols need to be adjusted when the program is loaded or linked. 6. Source Code Integration: When binaries are compiled with debugging information, objdump can intermix the original source code with the disassembly, making it much easier to understand the relationship between source code and machine instructions. Common use cases for objdump include: - Debugging programs where the source-level debugger isn't providing enough insight - Analyzing binary files to understand their behavior or security implications - Verifying that compiler optimizations are working as expected - Learning about assembly language and machine code - Examining binary differences between versions of a program - Identifying the cause of crashes or unexpected behavior in compiled programs - Reverse engineering libraries or executables for which source code is unavailable - Educational purposes for computer science and software engineering students objdump is highly configurable, offering options to control the format and detail level of its output. It supports multiple architectures and object file formats, making it a versatile tool across different platforms and development environments. While powerful, objdump's output can be complex and requires some knowledge of assembly language and binary formats to interpret effectively. It's often used alongside other tools like nm, readelf, and gdb to provide a complete picture of a binary file's structure and behavior.

    Related Commands

    These commands are frequently used alongside objdump or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the objdump command works in different scenarios.

    $ objdump
    View All Commands