wasm-objdump
Disassemble WebAssembly binary files
TLDR
Display the section headers of a given binary
Display the entire disassembled output of a given binary
Display the details of each section
Display the details of a given section
SYNOPSIS
wasm-objdump [options] <file...>
PARAMETERS
-h, --help
Displays a help message with available options and their usage.
-v, --version
Prints the version information of the wasm-objdump utility.
-s <SECTION>, --section=<SECTION>
Displays only the contents of the specified section. <SECTION> can be a section name (e.g., 'code', 'data', 'name') or a numeric index.
-d, --disassemble
Disassembles only the code section, showing the WebAssembly bytecode as human-readable instructions. This is typically the most frequently used option for code analysis.
-D, --disassemble-all
Disassembles all sections that contain code or other executable content, providing a more comprehensive disassembly than -d.
-x, --full-contents
Displays the full contents of all sections, including raw byte dumps and interpreted data where applicable, offering a complete module overview.
-j, --section-headers
Displays summary information for all sections, including their names, types, sizes, and offsets within the module, similar to readelf -S.
-f, --file-headers
Displays high-level information about the WebAssembly module's header, such as the magic number and version.
-r, --reloc
Displays the relocation entries of the WebAssembly module, if present. Relocations are used to resolve addresses at link-time.
-t, --syms
Displays the symbol table entries, useful for understanding imported and exported functions, global variables, and data segments.
--debug-names
Attempts to display human-readable names for functions, locals, types, and other entities, often sourced from the 'name' custom section or DWARF debug information within the module.
--no-demangle
Prevents the demangling of C++ or Rust style names (e.g., in function signatures), showing them in their raw, mangled form rather than their human-readable equivalents.
DESCRIPTION
wasm-objdump is a command-line utility from the WebAssembly Binary Toolkit (WABT) used to display comprehensive information about WebAssembly (.wasm) modules. It functions similarly to the traditional objdump tool for native binaries, allowing developers and security researchers to inspect the internal structure, sections, and disassembled code of a WebAssembly file. It provides detailed insights into various aspects of a Wasm module, such as its imported/exported functions, global variables, memory layout, and, most importantly, the WebAssembly bytecode instructions themselves. This tool is essential for debugging, reverse engineering, and understanding the compiled output of WebAssembly applications, aiding in performance analysis and security audits by providing a low-level view of the module's contents.
CAVEATS
wasm-objdump is specifically designed for WebAssembly binaries (.wasm files) and cannot be used with native executable formats like ELF, PE, or Mach-O. Its ability to display meaningful debug information (e.g., source code lines, variable names) is entirely dependent on the presence and correct formatting of debug sections within the .wasm module. Without such sections, output may be less human-readable.
USAGE CONTEXT
This command is invaluable for anyone working with WebAssembly at a low level, including compiler developers, security researchers analyzing Wasm code for vulnerabilities, and application developers debugging performance or correctness issues within their compiled Wasm modules. It helps in understanding the exact machine instructions executed by the WebAssembly virtual machine, providing a crucial bridge between high-level source code and the final binary output.
HISTORY
wasm-objdump is an integral part of the WebAssembly Binary Toolkit (WABT), an open-source project developed by members of the WebAssembly community, including key contributors from Google. WABT provides a suite of tools for working with WebAssembly at a low level. wasm-objdump emerged as an essential debugging and analysis utility alongside the rise of WebAssembly as a portable compilation target for the web and various other environments. Its development has focused on providing a robust and detailed view into the WebAssembly binary format, crucial for understanding and optimizing Wasm modules.