Expand description
Interface for reading object files.
Unified read API
The Object
trait provides a unified read API for accessing common features of
object files, such as sections and symbols. There is an implementation of this
trait for File
, which allows reading any file format, as well as implementations
for each file format:
ElfFile
, MachOFile
, CoffFile
,
PeFile
, WasmFile
, XcoffFile
.
Low level read API
The submodules for each file format define helpers that operate on the raw structs. These can be used instead of the unified API, or in conjunction with it to access details that are not available via the unified API.
See the submodules for examples of the low level read API.
Naming Convention
Types that form part of the unified API for a file format are prefixed with the name of the file format.
Example for unified read API
use object::{Object, ObjectSection};
use std::error::Error;
use std::fs;
/// Reads a file and displays the name of each section.
fn main() -> Result<(), Box<dyn Error>> {
let data = fs::read("path/to/binary")?;
let file = object::File::parse(&*data)?;
for section in file.sections() {
println!("{}", section.name()?);
}
Ok(())
}
Modules
- Support for archive files.
- Support for reading Windows COFF files.
- Support for reading ELF files.
- Support for reading Mach-O files.
- Support for reading PE files.
Structs
- A newtype for byte slices.
- PDB information from the debug directory in a PE file.
- A COMDAT section group in a
File
. - An iterator for the COMDAT section groups in a
File
. - An iterator for the sections in a
Comdat
. - Data that may be compressed.
- A range in a file that may be compressed.
- An iterator for the dynamic relocation entries in a
File
. - The error type used within the read module.
- An exported symbol.
- An imported symbol.
- An iterator for files that don’t have dynamic relocations.
- A map from addresses to symbol names and object files.
- An
ObjectMap
entry. - A relocation entry.
- A section in a
File
. - The index used to identify a section in a file.
- An iterator for the sections in a
File
. - An iterator for the relocation entries in a
Section
. - A loadable segment in a
File
. - An iterator for the loadable segments in a
File
. - A table of zero-terminated strings.
- An symbol in a
SymbolTable
. - The index used to identify a symbol in a symbol table.
- An iterator for the symbols in a
SymbolTable
. - A map from addresses to symbol information.
- The type used for entries in a
SymbolMap
that maps from addresses to names. - A symbol table in a
File
.
Enums
- A data compression format.
- An object file that can be any supported file format.
- A file format kind.
- An object kind.
- The target referenced by a
Relocation
. - The section where an
ObjectSymbol
is defined.
Traits
- An object file.
- A COMDAT section group in an
Object
. - A section in an
Object
. - A loadable segment in an
Object
. - A symbol table entry in an
Object
. - A symbol table in an
Object
. - A trait for reading references to
Pod
types from a block of data. - An entry in a
SymbolMap
.
Type Aliases
- The native executable file for the target platform.
- The result type used within the read module.