diff options
author | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
commit | 1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch) | |
tree | 7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/object/src/read/elf/mod.rs | |
parent | 5ecd8cf2cba827454317368b68571df0d13d7842 (diff) | |
download | fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip |
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/object/src/read/elf/mod.rs')
-rw-r--r-- | vendor/object/src/read/elf/mod.rs | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/vendor/object/src/read/elf/mod.rs b/vendor/object/src/read/elf/mod.rs new file mode 100644 index 0000000..66931bd --- /dev/null +++ b/vendor/object/src/read/elf/mod.rs @@ -0,0 +1,78 @@ +//! 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(()) +//! } +//! ``` +#[cfg(doc)] +use crate::elf; + +mod file; +pub use file::*; + +mod segment; +pub use segment::*; + +mod section; +pub use section::*; + +mod symbol; +pub use symbol::*; + +mod relocation; +pub use relocation::*; + +mod comdat; +pub use comdat::*; + +mod dynamic; +pub use dynamic::*; + +mod compression; +pub use compression::*; + +mod note; +pub use note::*; + +mod hash; +pub use hash::*; + +mod version; +pub use version::*; + +mod attributes; +pub use attributes::*; |