| 1 |
//! Support for reading AIX XCOFF files. |
| 2 |
//! |
| 3 |
//! Traits are used to abstract over the difference between 32-bit and 64-bit XCOFF. |
| 4 |
//! The primary trait for this is [`FileHeader`]. |
| 5 |
//! |
| 6 |
//! ## High level API |
| 7 |
//! |
| 8 |
//! [`XcoffFile`] implements the [`Object`](crate::read::Object) trait for XCOFF files. |
| 9 |
//! [`XcoffFile`] is parameterised by [`FileHeader`] to allow reading both 32-bit and |
| 10 |
//! 64-bit XCOFF. There are type aliases for these parameters ([`XcoffFile32`] and |
| 11 |
//! [`XcoffFile64`]). |
| 12 |
//! |
| 13 |
//! ## Low level API |
| 14 |
//! |
| 15 |
//! The [`FileHeader`] trait can be directly used to parse both [`xcoff::FileHeader32`] |
| 16 |
//! and [`xcoff::FileHeader64`]. |
| 17 |
//! |
| 18 |
//! ### Example for low level API |
| 19 |
//! ```no_run |
| 20 |
//! use object::xcoff; |
| 21 |
//! use object::read::xcoff::{FileHeader, SectionHeader, Symbol}; |
| 22 |
//! use std::error::Error; |
| 23 |
//! use std::fs; |
| 24 |
//! |
| 25 |
//! /// Reads a file and displays the name of each section and symbol. |
| 26 |
//! fn main() -> Result<(), Box<dyn Error>> { |
| 27 |
//! # #[cfg(feature = "std")] { |
| 28 |
//! let data = fs::read("path/to/binary")?; |
| 29 |
//! let mut offset = 0; |
| 30 |
//! let header = xcoff::FileHeader64::parse(&*data, &mut offset)?; |
| 31 |
//! let aux_header = header.aux_header(&*data, &mut offset)?; |
| 32 |
//! let sections = header.sections(&*data, &mut offset)?; |
| 33 |
//! let symbols = header.symbols(&*data)?; |
| 34 |
//! for section in sections.iter() { |
| 35 |
//! println!("{}", String::from_utf8_lossy(section.name())); |
| 36 |
//! } |
| 37 |
//! for (_index, symbol) in symbols.iter() { |
| 38 |
//! println!("{}", String::from_utf8_lossy(symbol.name(symbols.strings())?)); |
| 39 |
//! } |
| 40 |
//! # } |
| 41 |
//! Ok(()) |
| 42 |
//! } |
| 43 |
//! ``` |
| 44 |
#[cfg(doc)] |
| 45 |
use crate::xcoff; |
| 46 |
|
| 47 |
mod file; |
| 48 |
pub use file::*; |
| 49 |
|
| 50 |
mod section; |
| 51 |
pub use section::*; |
| 52 |
|
| 53 |
mod symbol; |
| 54 |
pub use symbol::*; |
| 55 |
|
| 56 |
mod relocation; |
| 57 |
pub use relocation::*; |
| 58 |
|
| 59 |
mod comdat; |
| 60 |
pub use comdat::*; |
| 61 |
|
| 62 |
mod segment; |
| 63 |
pub use segment::*; |