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>
impl<E: EndianParse> FileHeader<E>
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>
impl<E: Clone + EndianParse> Clone for FileHeader<E>
Source§fn clone(&self) -> FileHeader<E>
fn clone(&self) -> FileHeader<E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more