Trait FileHeader

Source
pub trait FileHeader: Debug + Pod {
    type Word: Into<u64>;
    type Sword: Into<i64>;
    type Endian: Endian;
    type ProgramHeader: ProgramHeader<Elf = Self, Endian = Self::Endian, Word = Self::Word>;
    type SectionHeader: SectionHeader<Elf = Self, Endian = Self::Endian, Word = Self::Word>;
    type CompressionHeader: CompressionHeader<Endian = Self::Endian, Word = Self::Word>;
    type NoteHeader: NoteHeader<Endian = Self::Endian>;
    type Dyn: Dyn<Endian = Self::Endian, Word = Self::Word>;
    type Sym: Sym<Endian = Self::Endian, Word = Self::Word>;
    type Rel: Rel<Endian = Self::Endian, Word = Self::Word>;
    type Rela: Rela<Endian = Self::Endian, Word = Self::Word> + From<Self::Rel>;

Show 33 methods // Required methods fn is_type_64(&self) -> bool; fn is_type_64_sized() -> bool where Self: Sized; fn e_ident(&self) -> &Ident; fn e_type(&self, endian: Self::Endian) -> u16; fn e_machine(&self, endian: Self::Endian) -> u16; fn e_version(&self, endian: Self::Endian) -> u32; fn e_entry(&self, endian: Self::Endian) -> Self::Word; fn e_phoff(&self, endian: Self::Endian) -> Self::Word; fn e_shoff(&self, endian: Self::Endian) -> Self::Word; fn e_flags(&self, endian: Self::Endian) -> u32; fn e_ehsize(&self, endian: Self::Endian) -> u16; fn e_phentsize(&self, endian: Self::Endian) -> u16; fn e_phnum(&self, endian: Self::Endian) -> u16; fn e_shentsize(&self, endian: Self::Endian) -> u16; fn e_shnum(&self, endian: Self::Endian) -> u16; fn e_shstrndx(&self, endian: Self::Endian) -> u16; // Provided methods fn parse<'data, R: ReadRef<'data>>(data: R) -> Result<&'data Self> { ... } fn is_supported(&self) -> bool { ... } fn is_class_32(&self) -> bool { ... } fn is_class_64(&self) -> bool { ... } fn is_little_endian(&self) -> bool { ... } fn is_big_endian(&self) -> bool { ... } fn endian(&self) -> Result<Self::Endian> { ... } fn section_0<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<Option<&'data Self::SectionHeader>> { ... } fn phnum<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<usize> { ... } fn shnum<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<usize> { ... } fn shstrndx<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<u32> { ... } fn program_headers<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<&'data [Self::ProgramHeader]> { ... } fn section_headers<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<&'data [Self::SectionHeader]> { ... } fn section_strings_index<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<SectionIndex> { ... } fn section_strings<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, sections: &[Self::SectionHeader], ) -> Result<StringTable<'data, R>> { ... } fn sections<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<SectionTable<'data, Self, R>> { ... } fn is_mips64el(&self, endian: Self::Endian) -> bool { ... }
}
Expand description

A trait for generic access to elf::FileHeader32 and elf::FileHeader64.

Required Associated Types§

Source

type Word: Into<u64>

Source

type Sword: Into<i64>

Source

type Endian: Endian

Source

type ProgramHeader: ProgramHeader<Elf = Self, Endian = Self::Endian, Word = Self::Word>

Source

type SectionHeader: SectionHeader<Elf = Self, Endian = Self::Endian, Word = Self::Word>

Source

type CompressionHeader: CompressionHeader<Endian = Self::Endian, Word = Self::Word>

Source

type NoteHeader: NoteHeader<Endian = Self::Endian>

Source

type Dyn: Dyn<Endian = Self::Endian, Word = Self::Word>

Source

type Sym: Sym<Endian = Self::Endian, Word = Self::Word>

Source

type Rel: Rel<Endian = Self::Endian, Word = Self::Word>

Source

type Rela: Rela<Endian = Self::Endian, Word = Self::Word> + From<Self::Rel>

Required Methods§

Source

fn is_type_64(&self) -> bool

Return true if this type is a 64-bit header.

This is a property of the type, not a value in the header data.

Source

fn is_type_64_sized() -> bool
where Self: Sized,

Return true if this type is a 64-bit header.

This is a property of the type, not a value in the header data.

This is the same as Self::is_type_64, but is non-dispatchable.

Source

fn e_ident(&self) -> &Ident

Source

fn e_type(&self, endian: Self::Endian) -> u16

Source

fn e_machine(&self, endian: Self::Endian) -> u16

Source

fn e_version(&self, endian: Self::Endian) -> u32

Source

fn e_entry(&self, endian: Self::Endian) -> Self::Word

Source

fn e_phoff(&self, endian: Self::Endian) -> Self::Word

Source

fn e_shoff(&self, endian: Self::Endian) -> Self::Word

Source

fn e_flags(&self, endian: Self::Endian) -> u32

Source

fn e_ehsize(&self, endian: Self::Endian) -> u16

Source

fn e_phentsize(&self, endian: Self::Endian) -> u16

Source

fn e_phnum(&self, endian: Self::Endian) -> u16

Source

fn e_shentsize(&self, endian: Self::Endian) -> u16

Source

fn e_shnum(&self, endian: Self::Endian) -> u16

Source

fn e_shstrndx(&self, endian: Self::Endian) -> u16

Provided Methods§

Source

fn parse<'data, R: ReadRef<'data>>(data: R) -> Result<&'data Self>

Read the file header.

Also checks that the ident field in the file header is a supported format.

Source

fn is_supported(&self) -> bool

Check that the ident field in the file header is a supported format.

This checks the magic number, version, class, and endianness.

Source

fn is_class_32(&self) -> bool

Source

fn is_class_64(&self) -> bool

Source

fn is_little_endian(&self) -> bool

Source

fn is_big_endian(&self) -> bool

Source

fn endian(&self) -> Result<Self::Endian>

Source

fn section_0<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<Option<&'data Self::SectionHeader>>

Return the first section header, if present.

Section 0 is a special case because getting the section headers normally requires shnum, but shnum may be in the first section header.

Source

fn phnum<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<usize>

Return the e_phnum field of the header. Handles extended values.

Returns Err for invalid values.

Source

fn shnum<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<usize>

Return the e_shnum field of the header. Handles extended values.

Returns Err for invalid values.

Source

fn shstrndx<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<u32>

Return the e_shstrndx field of the header. Handles extended values.

Returns Err for invalid values (including if the index is 0).

Source

fn program_headers<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<&'data [Self::ProgramHeader]>

Return the slice of program headers.

Returns Ok(&[]) if there are no program headers. Returns Err for invalid values.

Source

fn section_headers<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<&'data [Self::SectionHeader]>

Return the slice of section headers.

Returns Ok(&[]) if there are no section headers. Returns Err for invalid values.

Source

fn section_strings_index<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<SectionIndex>

Get the section index of the section header string table.

Returns Err for invalid values (including if the index is 0).

Source

fn section_strings<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, sections: &[Self::SectionHeader], ) -> Result<StringTable<'data, R>>

Return the string table for the section headers.

Source

fn sections<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<SectionTable<'data, Self, R>>

Return the section table.

Source

fn is_mips64el(&self, endian: Self::Endian) -> bool

Returns whether this is a mips64el elf file.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Endian: Endian> FileHeader for FileHeader32<Endian>

Source§

impl<Endian: Endian> FileHeader for FileHeader64<Endian>