#elf #mach-o #pe #coff

no-std object

A unified interface for reading and writing object file formats

52 releases (31 breaking)

0.32.1 Sep 3, 2023
0.31.1 May 10, 2023
0.30.3 Jan 23, 2023
0.30.0 Nov 22, 2022
0.1.0 Aug 20, 2016

#4 in Operating systems

Download history 895298/week @ 2023-08-10 975780/week @ 2023-08-17 1108439/week @ 2023-08-24 1007363/week @ 2023-08-31 1095781/week @ 2023-09-07 1082030/week @ 2023-09-14 1078418/week @ 2023-09-21 1055567/week @ 2023-09-28 1121301/week @ 2023-10-05 1110788/week @ 2023-10-12 1138777/week @ 2023-10-19 1149900/week @ 2023-10-26 1183270/week @ 2023-11-02 1181742/week @ 2023-11-09 1186801/week @ 2023-11-16 827232/week @ 2023-11-23

4,582,937 downloads per month
Used in 25,201 crates (126 directly)

Apache-2.0 OR MIT

29K SLoC


The object crate provides a unified interface to working with object files across platforms. It supports reading relocatable object files and executable files, and writing COFF/ELF/Mach-O/XCOFF relocatable object files and ELF/PE executable files.

For reading files, it provides multiple levels of support:

  • raw struct definitions suitable for zero copy access
  • low level APIs for accessing the raw structs (example)
  • a higher level unified API for accessing common features of object files, such as sections and symbols (example)

Supported file formats: ELF, Mach-O, Windows PE/COFF, Wasm, XCOFF, and Unix archive.

Example for unified read API

use object::{Object, ObjectSection};
use std::error::Error;
use std::fs;

/// Reads a file and displays the content of the ".boot" section.
fn main() -> Result<(), Box<dyn Error>> {
  let bin_data = fs::read("./multiboot2-binary.elf")?;
  let obj_file = object::File::parse(&*bin_data)?;
  if let Some(section) = obj_file.section_by_name(".boot") {
    println!("{:#x?}", section.data()?);
  } else {
    eprintln!("section not available");

See crates/examples for more examples.

Minimum Supported Rust Version (MSRV)

Changes to MSRV are considered breaking changes. We are conservative about changing the MSRV, but sometimes are required to due to dependencies. The MSRV is:

  • 1.60.0 for the read feature and its dependencies.
  • 1.65.0 for other features.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~24K SLoC