Expand description
object
The object
crate provides a unified interface to working with object files
across platforms. It supports reading object files and executable files,
and writing object files and some executable files.
Raw struct definitions
Raw structs are defined for: ELF, Mach-O, PE/COFF, archive. Types and traits for zerocopy support are defined in pod and endian.
Unified read API
The read::Object trait defines the unified interace. This trait is implemented by read::File, which allows reading any file format, as well as implementations for each file format: ELF, Mach-O, COFF, PE, Wasm.
Low level read API
In addition to the unified read API, the various read
modules define helpers that
operate on the raw structs. These also provide traits that abstract over the differences
between 32-bit and 64-bit versions of the file format.
Unified write API
[write::Object] allows building a COFF/ELF/Mach-O object and then writing it out.
Low level executable writers
[write::elf::Writer] and [write::pe::Writer] allow writing executable files.
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");
}
Ok(())
}
Re-exports
Modules
Archive definitions.
ELF definitions.
Types for compile-time and run-time endianness.
Mach-O definitions.
PE/COFF definitions.
Tools for converting file format structures to and from bytes.
Interface for reading object files.
Enums
The size of an address value for an architecture.
A CPU architecture.
A binary file format.
The selection kind for a COMDAT section group.
File flags that are specific to each file format.
Information about how the result of the relocation operation is encoded in the place.
The operation used to calculate the result of the relocation.
Section flags that are specific to each file format.
The kind of a section.
Symbol flags that are specific to each file format.
The kind of a symbol.
A symbol scope.