pub struct Ident {
pub class: Class,
pub byte_order: ByteOrder,
pub abi: ABI,
pub abi_version: u8,
}
Expand description
e_ident. Specifies class, byte order and ABI of the ELF
Fields§
§class: Class
Class, ELF32/ELF64
byte_order: ByteOrder
Byte order
abi: ABI
Identifies the target operating system ABI
abi_version: u8
ABI version, usually 0
Implementations§
Source§impl Ident
impl Ident
Sourcepub fn new(
class: Class,
byte_order: impl Into<ByteOrder>,
abi: impl Into<ABI>,
abi_version: u8,
) -> Self
pub fn new( class: Class, byte_order: impl Into<ByteOrder>, abi: impl Into<ABI>, abi_version: u8, ) -> Self
Constructs a new Ident to write it afterwards
Sourcepub fn write<W: Write>(&self, file: &mut W) -> Result<()>
pub fn write<W: Write>(&self, file: &mut W) -> Result<()>
Write the Ident to a file. It’s done automatically by the ELF::write()
Sourcepub fn read<R: Read>(file: &mut R) -> Result<Self>
pub fn read<R: Read>(file: &mut R) -> Result<Self>
Read the Ident from a file. It’s done automatically by the ELF::read()
.
Can be used with ELF::read_remainder()
to determine ELF class:
use orecc_elf::{ELF, Ident, Class};
let mut file = std::fs::File::open("test.o").unwrap();
let ident = Ident::read(&mut file).unwrap();
if ident.class == Class::ELF64 {
dbg!(ELF::<u64>::read_remainder(&mut file, ident)).unwrap();
} else {
dbg!(ELF::<u32>::read_remainder(&mut file, ident)).unwrap();
}
Trait Implementations§
Source§impl Ord for Ident
impl Ord for Ident
Source§impl PartialOrd for Ident
impl PartialOrd for Ident
impl Eq for Ident
impl StructuralPartialEq for Ident
Auto Trait Implementations§
impl Freeze for Ident
impl RefUnwindSafe for Ident
impl Send for Ident
impl Sync for Ident
impl Unpin for Ident
impl UnwindSafe for Ident
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more