object_rewrite/
lib.rs

1//! A library for rewriting object and executable files.
2//!
3//! Use the [`Rewriter`] struct to read a file, modify it, and write it back.
4//! Modifications can be performed using methods on the [`Rewriter`] struct, or
5//! by passing an [`Options`] struct to the [`Rewriter::modify`] method.
6//!
7//! Currently, only ELF files are supported, and not many modifications are
8//! possible yet.
9//!
10//! # Example
11//! ```no_run
12//! use object_rewrite::{Options, Rewriter};
13//!
14//! fn main() -> Result<(), Box<dyn std::error::Error>> {
15//!   let mut options = Options::default();
16//!   options.delete_symbols.insert(b"main".to_vec());
17//!
18//!   let input = std::fs::read("path/to/input")?;
19//!   let mut rewriter = Rewriter::read(&input)?;
20//!   rewriter.modify(options)?;
21//!   let mut output = std::fs::File::create("path/to/output")?;
22//!   rewriter.write(&mut output)?;
23//!   Ok(())
24//! }
25//! ```
26
27#![warn(missing_docs)]
28#![warn(missing_debug_implementations)]
29
30mod error;
31pub use error::{Error, ErrorKind, Result};
32
33mod rewriter;
34pub use rewriter::{Options, Rewriter};
35
36mod elf;
37pub use elf::ElfOptions;