• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H03-May-2022-36,05424,432

tests/H03-May-2022-1,7631,479

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197074 65

.gitignoreH A D01-Jan-197018 32

.gitmodulesH A D01-Jan-197094 43

CHANGELOG.mdH A D01-Jan-19708.2 KiB274173

Cargo.tomlH A D01-Jan-19702 KiB7767

Cargo.toml.orig-cargoH A D01-Jan-19703.2 KiB9580

LICENSE-APACHEH A D01-Jan-197010.6 KiB202169

LICENSE-MITH A D01-Jan-19701 KiB2622

README.mdH A D01-Jan-19701.7 KiB5137

clippy.tomlH A D01-Jan-197016 21

README.md

1# `object`
2
3The `object` crate provides a unified interface to working with object files
4across platforms. It supports reading object files and executable files,
5and writing COFF/ELF/Mach-O object files and ELF/PE executable files.
6
7For reading files, it provides multiple levels of support:
8
9* raw struct definitions suitable for zero copy access
10* low level APIs for accessing the raw structs ([example](crates/examples/src/readobj/))
11* a higher level unified API for accessing common features of object files, such
12  as sections and symbols ([example](crates/examples/src/objdump.rs))
13
14Supported file formats: ELF, Mach-O, Windows PE/COFF, Wasm, and Unix archive.
15
16## Example for unified read API
17```rust
18use object::{Object, ObjectSection};
19use std::error::Error;
20use std::fs;
21
22/// Reads a file and displays the content of the ".boot" section.
23fn main() -> Result<(), Box<dyn Error>> {
24  let bin_data = fs::read("./multiboot2-binary.elf")?;
25  let obj_file = object::File::parse(&*bin_data)?;
26  if let Some(section) = obj_file.section_by_name(".boot") {
27    println!("{:#x?}", section.data()?);
28  } else {
29    eprintln!("section not available");
30  }
31  Ok(())
32}
33```
34
35See [`crates/examples`](crates/examples) for more examples.
36
37## License
38
39Licensed under either of
40
41  * Apache License, Version 2.0 ([`LICENSE-APACHE`](./LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
42  * MIT license ([`LICENSE-MIT`](./LICENSE-MIT) or https://opensource.org/licenses/MIT)
43
44at your option.
45
46## Contribution
47
48Unless you explicitly state otherwise, any contribution intentionally submitted
49for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
50dual licensed as above, without any additional terms or conditions.
51