LinuxCommandLibrary

opldecode

Disassemble object code into assembly language

SYNOPSIS

opldecode [OPTIONS] [FILENAME...]

PARAMETERS

-b
    Specify the target Binary File Descriptor (BFD) architecture (e.g., i386, arm, mips). This determines the instruction set to decode.

-m
    Specify the machine variant for the chosen architecture (e.g., i386:intel for Intel syntax, arm:v7). This fine-tunes the disassembly process.

-s
    Start disassembling from the specified address. Useful when the input represents a larger memory region and you only want to decode from a certain offset.

-l
    Disassemble only the specified number of bytes from the start address (or beginning of input if -s is not used).

-w
    Display wider output, potentially including more detailed instruction bytes or additional information in the disassembly listing.

-i
    Include instruction address prefix in the output, showing the byte offset of each instruction.

-r
    Treat input as raw bytes. This is often the default behavior, but explicitly ensures no file header parsing is attempted.

-P
    Print instruction prolog. This option is specific to certain architectures (e.g., PowerPC) and affects how instructions are displayed.

-I
    Do not print instruction prolog. The inverse of -P.

-D
    Enable debugging output, providing verbose information about the internal operations of the command. Primarily for development or troubleshooting.

-h, --help
    Display a brief usage message and exit.

-v, --version
    Display the version information for opldecode and exit.

DESCRIPTION

opldecode is a specialized command-line utility used to disassemble raw binary machine code into human-readable assembly language instructions. It reads input typically from standard input or a specified file, interpreting the bytes as executable opcodes for a chosen processor architecture. Unlike more comprehensive tools like objdump, opldecode focuses on raw byte streams and does not parse entire executable formats (e.g., ELF, PE). This makes it particularly useful for analyzing isolated machine code snippets, shellcode, or firmware, where the input is not a structured object file. It is part of the GNU Binutils project and serves as a fundamental example of how the underlying libopcodes library can be utilized for disassembly.

CAVEATS

opldecode is a relatively simple tool compared to objdump. It lacks advanced features like symbol resolution, relocation entry parsing, or comprehensive understanding of object file formats. It requires explicit specification of the target architecture (via -b and often -m) and does not automatically detect it. Its primary use case is for raw byte streams, not compiled executables, and it may not be installed by default on all Linux distributions as a standalone command, sometimes being an internal Binutils test utility.

PIPING RAW BYTES

opldecode is often used by piping raw binary data directly to its standard input. For example, to disassemble the NOP (0x90) and RET (0xC3) instructions on x86-64:
echo -ne "\x90\x90\xc3" | opldecode -b i386 -m i386:intel
This allows for quick analysis of small, arbitrary code sequences without needing to save them to a file.

UNDERLYING LIBRARY

The core disassembly logic utilized by opldecode (and also by objdump) is provided by the libopcodes library, a fundamental component of GNU Binutils. This library abstracts away the complexities of different instruction sets, allowing tools to perform disassembly consistently across various processor architectures.

HISTORY

opldecode is part of the GNU Binutils collection, which has been under continuous development since the late 1980s. It likely originated as a practical demonstration or test utility for the libopcodes library, which is the core engine for disassembling machine instructions across various architectures within Binutils. Its usage has remained niche, primarily for specialized tasks involving raw machine code snippets, as objdump fulfills most general-purpose disassembly needs.

SEE ALSO

objdump(1), readelf(1), gdb(1), as(1)

Copied to clipboard