archive.rs |
Archive definitions.
These definitions are independent of read/write support, although we do implement
some traits useful for those. |
2669 |
common.rs |
|
14476 |
elf.rs |
ELF definitions.
These definitions are independent of read/write support, although we do implement
some traits useful for those.
This module is the equivalent of /usr/include/elf.h, and is based heavily on it. |
210042 |
endian.rs |
Types for compile-time and run-time endianness. |
23948 |
lib.rs |
# `object`
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 relocatable object files and some executable files.
## Raw struct definitions
Raw structs are defined for: [ELF](elf), [Mach-O](macho), [PE/COFF](pe),
[XCOFF](xcoff), [archive].
Types and traits for zerocopy support are defined in [pod] and [endian].
## Unified read API
The [read::Object] trait defines the unified interface. This trait is implemented
by [read::File], which allows reading any file format, as well as implementations
for each file format: [ELF](read::elf::ElfFile), [Mach-O](read::macho::MachOFile),
[COFF](read::coff::CoffFile), [PE](read::pe::PeFile), [Wasm](read::wasm::WasmFile),
[XCOFF](read::xcoff::XcoffFile).
## 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/XCOFF relocatable object file 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
```no_run
# #[cfg(feature = "read")]
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>> {
# #[cfg(all(feature = "read", feature = "std"))] {
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(())
}
``` |
3446 |
macho.rs |
Mach-O definitions.
These definitions are independent of read/write support, although we do implement
some traits useful for those.
This module is based heavily on header files from MacOSX11.1.sdk. |
127566 |
pe.rs |
PE/COFF definitions.
These definitions are independent of read/write support, although we do implement
some traits useful for those.
This module is based heavily on "winnt.h" (10.0.17763.0). |
101366 |
pod.rs |
Tools for converting file format structures to and from bytes.
This module should be replaced once rust provides safe transmutes. |
8148 |
read |
|
|
write |
|
|
xcoff.rs |
XCOFF definitions
These definitions are independent of read/write support, although we do implement
some traits useful for those.
This module is the equivalent of /usr/include/xcoff.h, and is based heavily on it. |
27231 |