disassembler
termKept in this browser · My desk
A program that turns machine code back into assembly language, mnemonic by mnemonic; the reading half of reverse engineering, used by malware analysts, vulnerability researchers and anyone checking what a compiler produced.
A disassembler is only as right as its assumptions. On x86, where instructions have no fixed length, starting one byte off produces a different but plausible listing, and the same byte means different things in 32-bit and 64-bit mode. Free tools such as GNU objdump and the NSA's Ghidra made disassembly routine; the law treats it differently by country.
What it is. A disassembler is the assembler run backwards: it takes machine code and prints it as assembly language. David Salomon's Assemblers and Loaders puts it in one line, "in a sense, the opposite of an assembler", one that "translates machine code into a source program in assembler language". What it cannot restore is what the assembler threw away: comments, the programmer's names unless a symbol table survives, the distinction between code and data, and the macros that generated the instructions.
How it works. A disassembler reads bytes, decodes each instruction with the architecture's encoding rules and prints the mnemonic and operands, replacing addresses with symbol names where the file still has them. On fixed-length architectures such as AArch64 and RISC-V it knows where every instruction starts; on x86 it must follow the code. Disassemblers print the canonical mnemonic: GNU's tools print je for the byte 74 that a programmer wrote as jz, both names the Intel manual lists for that opcode.
Two algorithms. Benjamin Schwarz, Saumya Debray and Gregory Andrews of the University of Arizona, in Disassembly of Executable Code Revisited, describe the two classic designs. Linear sweep decodes "everything appearing in sections of the executable that are typically reserved for machine code", the method of GNU objdump; it breaks when data sits in the code, and their example is three NULL bytes inserted for alignment after a jmp, which linear sweep decoded as add instructions because on x86 "a NULL byte can be a valid opcode", throwing off the instructions that followed. Recursive traversal follows the control flow from known entry points and so skips that padding, but indirect jumps, such as position-independent jump tables, hide where control goes. Their warning about existing tools is the important one: they "fail silently", producing incorrect disassemblies "without any indication that the results they are producing are incorrect".
Why it can disagree with itself. Hovav Shacham's 2007 paper compared x86 code to English written without spaces and showed two instructions, f7 c7 07 00 00 00 and 0f 95 45 c3, that decode, one byte later, as a move, an exchange, an increment and a ret. That example is 32-bit code: in 64-bit mode the bytes 40H to 4FH are REX prefixes, not INC and DEC, so the mode must be known as well as the start.
Tools. GNU objdump disassembles from the command line (objdump -d). LLVM's llvm-objdump offers -d, -D or --disassemble-all for every section, and --disassemble-symbols to limit the output to named functions. Inside a running program, the GNU debugger (GDB) uses its disassemble command "to display a range of addresses as machine instructions", and set disassemble-next-line shows the instructions at each stop. Capstone, "a lightweight multi-platform, multi-architecture disassembly framework", is the engine many security tools embed, covering ARM, ARM64, BPF, the Ethereum VM, M68K, MIPS, MOS65XX, PowerPC, RISC-V, SPARC, SystemZ, WebAssembly and x86 in 16, 32 and 64 bits, among others. Ghidra, "a software reverse engineering (SRE) framework created and maintained by the National Security Agency Research Directorate", lists disassembly, assembly, decompilation, graphing and scripting among its capabilities; its public repository dates from 1 March 2019, Coordinated Universal Time (UTC).
The law. In the United States, 17 U.S. Code 1201(f) permits circumventing a protection measure for the sole purpose of the analysis needed for interoperability of an independently created program. The leading case is older: in Sega Enterprises v. Accolade (Ninth Circuit, decided 20 October 1992, amended 6 January 1993), Accolade had disassembled Sega Genesis games to learn the console's interface, and the court held that "where disassembly is the only way to gain access to the ideas and functional elements embodied in a copyrighted computer program and where there is a legitimate reason for seeking such access, disassembly is a fair use of the copyrighted work, as a matter of law", while leaving Sega free to claim infringement in the finished games. Brazil's software law, Lei 9.609/1998, does not mention disassembly; its article 6 lists acts that do not offend the owner's rights, among them partial citation for teaching and integration technically indispensable to the user.
What goes wrong. A listing is an interpretation, not the program: data decoded as code, the wrong processor mode, the wrong starting byte, or deliberately confusing code produces output that looks reasonable and is false. A decompiler built on top inherits every error and adds its own guesses about types and structure. Analysts therefore cross-check: entry points from the file header, symbols, cross-references and, where possible, running the code under a debugger.
Neighbours. The disassembler reverses the assembler, reads machine code through the opcode tables of an instruction set architecture, and is the reading half of reverse engineering, beside the debugger. Brazilian practice says desmontador or, more often, disassembler.
Also known as: disassembly, desmontador, desmontagem, objdump, Ghidra
Sources
- GNU Binutils, objdump: command-line display of object files, including disassembly (read 2026-11-23)
- National Security Agency, Ghidra README: a software reverse engineering (SRE) framework whose capabilities include disassembly, assembly, decompilation, graphing and scripting (read 2026-11-23)
- GitHub API, repository record of NationalSecurityAgency/ghidra: created 2019-03-01 (UTC) (read 2026-11-23)
- Hovav Shacham, The Geometry of Innocent Flesh on the Bone, full version of the ACM CCS 2007 paper (Cornell course copy): gadgets ending in ret, W-xor-X, the English-without-spaces analogy and the f7 c7 07 00 00 00 / 0f 95 45 c3 example (read 2026-11-23)
- Intel SDM 325462-093: 16 general-purpose registers in 64-bit mode (Vol. 1, p. 3-12); 32-bit results zero-extended to 64 bits (p. 3-13); ZF is bit 6 of EFLAGS (p. 3-16); REX prefixes occupy opcodes 40H to 4FH (Vol. 2A, p. 2-8) (read 2026-11-23)
- Legal Information Institute, 17 U.S. Code 1201(f): circumvention for the sole purpose of achieving interoperability of an independently created program (read 2026-11-23)
- Presidência da República, Lei 9.609/1998, art. 6: acts that do not offend the rights of a program's owner, including partial citation for teaching and integration indispensable to the user (read 2026-11-23)
- Compiler Explorer, godbolt.org public API with GNU binutils 2.45: the Learn article's three listings assembled to the hand-computed bytes (read 2026-11-23)
- Benjamin Schwarz, Saumya Debray and Gregory Andrews, University of Arizona, Disassembly of Executable Code Revisited: linear sweep, used by GNU objdump, decodes everything in code sections and misreads embedded data such as alignment bytes, since a NULL byte can be a valid x86 opcode; recursive traversal follows control flow but is hampered by indirect jumps; existing disassemblers fail silently (read 2026-11-23)
- LLVM documentation, llvm-objdump command guide: -d and -D (--disassemble-all) options, --disassemble-symbols to disassemble only named symbols (read 2026-11-23)
- GDB manual, section 9.6, Source and Machine Code: the disassemble command displays a range of addresses as machine instructions; set disassemble-next-line (read 2026-11-23)
- Capstone, home page: a lightweight multi-platform, multi-architecture disassembly framework for binary analysis and reversing, covering ARM, ARM64, BPF, Ethereum VM, M68K, MIPS, MOS65XX, PowerPC, RISC-V, SPARC, SystemZ, WebAssembly and x86 (16, 32, 64) among others (read 2026-11-23)
- United States Court of Appeals, Ninth Circuit, Sega Enterprises Ltd. v. Accolade, Inc., 977 F.2d 1510, No. 92-15655, decided 20 October 1992, amended 6 January 1993 (Law.Resource.Org copy): disassembly as fair use where it is the only way to reach the program's ideas and functional elements and there is a legitimate reason; the Genesis trademark security system (read 2026-11-23)
- David Salomon, Assemblers and Loaders, Ellis Horwood, 1993, section on types of assemblers: a disassembler is in a sense the opposite of an assembler, translating machine code into a source program in assembler language (read 2026-11-23)