Struct FileHeader

Source
pub struct FileHeader<E: EndianParse> {
Show 17 fields pub class: Class, pub endianness: E, pub version: u32, pub osabi: u8, pub abiversion: u8, pub e_type: u16, pub e_machine: u16, pub e_entry: u64, pub e_phoff: u64, pub e_shoff: u64, pub e_flags: u32, pub e_ehsize: u16, pub e_phentsize: u16, pub e_phnum: u16, pub e_shentsize: u16, pub e_shnum: u16, pub e_shstrndx: u16,
}
Expand description

Encapsulates the contents of the ELF File Header

The ELF File Header starts off every ELF file and both identifies the file contents and informs how to interpret said contents. This includes the width of certain fields (32-bit vs 64-bit), the data endianness, the file type, and more.

Fields§

§class: Class

32-bit vs 64-bit

§endianness: E§version: u32

elf version

§osabi: u8

OS ABI

§abiversion: u8

Version of the OS ABI

§e_type: u16

ELF file type

§e_machine: u16

Target machine architecture

§e_entry: u64

Virtual address of program entry point This member gives the virtual address to which the system first transfers control, thus starting the process. If the file has no associated entry point, this member holds zero.

Note: Type is Elf32_Addr or Elf64_Addr which are either 4 or 8 bytes. We aren’t trying to zero-copy parse the FileHeader since there’s only one per file and its only ~45 bytes anyway, so we use u64 for the three Elf*_Addr and Elf*_Off fields here.

§e_phoff: u64

This member holds the program header table’s file offset in bytes. If the file has no program header table, this member holds zero.

§e_shoff: u64

This member holds the section header table’s file offset in bytes. If the file has no section header table, this member holds zero.

§e_flags: u32

This member holds processor-specific flags associated with the file. Flag names take the form EF_machine_flag.

§e_ehsize: u16

This member holds the ELF header’s size in bytes.

§e_phentsize: u16

This member holds the size in bytes of one entry in the file’s program header table; all entries are the same size.

§e_phnum: u16

This member holds the number of entries in the program header table. Thus the product of e_phentsize and e_phnum gives the table’s size in bytes. If a file has no program header table, e_phnum holds the value zero.

§e_shentsize: u16

This member holds a section header’s size in bytes. A section header is one entry in the section header table; all entries are the same size.

§e_shnum: u16

This member holds the number of entries in the section header table. Thus the product of e_shentsize and e_shnum gives the section header table’s size in bytes. If a file has no section header table, e_shnum holds the value zero.

If the number of sections is greater than or equal to SHN_LORESERVE (0xff00), this member has the value zero and the actual number of section header table entries is contained in the sh_size field of the section header at index 0. (Otherwise, the sh_size member of the initial entry contains 0.)

§e_shstrndx: u16

This member holds the section header table index of the entry associated with the section name string table. If the file has no section name string table, this member holds the value SHN_UNDEF.

If the section name string table section index is greater than or equal to SHN_LORESERVE (0xff00), this member has the value SHN_XINDEX (0xffff) and the actual index of the section name string table section is contained in the sh_link field of the section header at index 0. (Otherwise, the sh_link member of the initial entry contains 0.)

Implementations§

Source§

impl<E: EndianParse> FileHeader<E>

Source

pub fn parse_tail( ident: (E, Class, u8, u8), data: &[u8], ) -> Result<FileHeader<E>, ParseError>

Trait Implementations§

Source§

impl<E: Clone + EndianParse> Clone for FileHeader<E>

Source§

fn clone(&self) -> FileHeader<E>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E: Debug + EndianParse> Debug for FileHeader<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: PartialEq + EndianParse> PartialEq for FileHeader<E>

Source§

fn eq(&self, other: &FileHeader<E>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<E: Copy + EndianParse> Copy for FileHeader<E>

Source§

impl<E: Eq + EndianParse> Eq for FileHeader<E>

Source§

impl<E: EndianParse> StructuralPartialEq for FileHeader<E>

Auto Trait Implementations§

§

impl<E> Freeze for FileHeader<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for FileHeader<E>
where E: RefUnwindSafe,

§

impl<E> Send for FileHeader<E>
where E: Send,

§

impl<E> Sync for FileHeader<E>
where E: Sync,

§

impl<E> Unpin for FileHeader<E>
where E: Unpin,

§

impl<E> UnwindSafe for FileHeader<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.