| attributes.rs |
|
10233 |
| comdat.rs |
|
5858 |
| compression.rs |
|
1442 |
| dynamic.rs |
|
3259 |
| file.rs |
|
31594 |
| hash.rs |
|
8339 |
| mod.rs |
Support for reading ELF files.
Traits are used to abstract over the difference between 32-bit and 64-bit ELF.
The primary trait for this is [`FileHeader`].
## High level API
[`ElfFile`] implements the [`Object`](crate::read::Object) trait for ELF files.
[`ElfFile`] is parameterised by [`FileHeader`] to allow reading both 32-bit and
64-bit ELF. There are type aliases for these parameters ([`ElfFile32`] and
[`ElfFile64`]).
## Low level API
The [`FileHeader`] trait can be directly used to parse both [`elf::FileHeader32`]
and [`elf::FileHeader64`].
### Example for low level API
```no_run
use object::elf;
use object::read::elf::{FileHeader, Sym};
use std::error::Error;
use std::fs;
/// Reads a file and displays the name of each symbol.
fn main() -> Result<(), Box<dyn Error>> {
# #[cfg(feature = "std")] {
let data = fs::read("path/to/binary")?;
let elf = elf::FileHeader64::<object::Endianness>::parse(&*data)?;
let endian = elf.endian()?;
let sections = elf.sections(endian, &*data)?;
let symbols = sections.symbols(endian, &*data, elf::SHT_SYMTAB)?;
for symbol in symbols.iter() {
let name = symbol.name(endian, symbols.strings())?;
println!("{}", String::from_utf8_lossy(name));
}
# }
Ok(())
}
``` |
1854 |
| note.rs |
|
8730 |
| relocation.rs |
|
24722 |
| section.rs |
|
40904 |
| segment.rs |
|
10610 |
| symbol.rs |
|
18831 |
| version.rs |
|
15735 |