object
A unified, cross-platform Rust interface for reading and writing ELF, Mach-O, PE/COFF, and other object files.
Repository Health
Technical Analysis
The object crate provides a unified interface for working with object and executable files across platforms. It can read relocatable object files and executables in ELF, Mach-O, Windows PE/COFF, Wasm, XCOFF, and Unix archive formats, and can write COFF/ELF/Mach-O/XCOFF relocatable object files as well as ELF/PE executables.
Reading is offered at multiple levels: raw zero-copy struct definitions, low-level APIs over those structs, and a higher-level unified API for common concepts such as sections, symbols, and relocations. On the writing side it exposes low-level format-specific writers, a higher-level ELF builder, and a unified relocatable-object writer. As a core building block of the Rust binary-analysis ecosystem, it powers tooling like debuggers, linkers, and profilers.
What You Get
- A unified read API over ELF, Mach-O, PE/COFF, Wasm, XCOFF, and Unix archives via the Object trait
- Zero-copy raw struct definitions plus low-level accessors for each supported format
- Unified and low-level writers for producing ELF, PE, COFF, Mach-O, and XCOFF files
- A higher-level ELF builder for rewriting and constructing executables
- Optional
no_stdsupport and granular feature flags to control read/write and format support
Common Use Cases
- Building debuggers, disassemblers, and binary-analysis tools that inspect symbols and sections
- Writing linkers, assemblers, or object-file generators that emit native binaries
- Rewriting or patching existing executables and relocatable objects
Under The Hood
Architecture - object is split into a read module with per-format submodules (elf, macho, pe, coff, wasm, xcoff, archive) unified behind the Object, ObjectSection, and ObjectSymbol traits, and a write module with both low-level format writers and higher-level builders; the workspace under crates/ also ships examples like objdump and readobj that exercise the API.
Tech Stack - It is pure Rust with optional dependencies such as flate2, ruzstd, and memchr gated behind Cargo features, supports #![no_std], and lets consumers enable only the formats and read/write directions they need to keep binary size down.
Code Quality - The crate is mature and heavily depended upon (hundreds of millions of downloads), with an extensive tests/ suite, real testfiles/, an xtask build helper, and a maintained CHANGELOG reflecting careful, incremental releases.
API Design - The zero-copy design and trait-based unified API make common tasks concise (parse a file, iterate sections and symbols) while still exposing raw structs for advanced use, with worked examples for both reading and writing.