Trait object::read::elf::SectionHeader

source ·
pub trait SectionHeader: Debug + Pod {
    type Elf: FileHeader<SectionHeader = Self, Endian = Self::Endian, Word = Self::Word>;
    type Word: Into<u64>;
    type Endian: Endian;

Show 34 methods // Required methods fn sh_name(&self, endian: Self::Endian) -> u32; fn sh_type(&self, endian: Self::Endian) -> u32; fn sh_flags(&self, endian: Self::Endian) -> Self::Word; fn sh_addr(&self, endian: Self::Endian) -> Self::Word; fn sh_offset(&self, endian: Self::Endian) -> Self::Word; fn sh_size(&self, endian: Self::Endian) -> Self::Word; fn sh_link(&self, endian: Self::Endian) -> u32; fn sh_info(&self, endian: Self::Endian) -> u32; fn sh_addralign(&self, endian: Self::Endian) -> Self::Word; fn sh_entsize(&self, endian: Self::Endian) -> Self::Word; // Provided methods fn name<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, strings: StringTable<'data, R> ) -> Result<&'data [u8]> { ... } fn link(&self, endian: Self::Endian) -> SectionIndex { ... } fn has_info_link(&self, endian: Self::Endian) -> bool { ... } fn info_link(&self, endian: Self::Endian) -> SectionIndex { ... } fn file_range(&self, endian: Self::Endian) -> Option<(u64, u64)> { ... } fn data<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<&'data [u8]> { ... } fn data_as_array<'data, T: Pod, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<&'data [T]> { ... } fn strings<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<StringTable<'data, R>>> { ... } fn symbols<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, sections: &SectionTable<'data, Self::Elf, R>, section_index: SectionIndex ) -> Result<Option<SymbolTable<'data, Self::Elf, R>>> { ... } fn rel<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(&'data [<Self::Elf as FileHeader>::Rel], SectionIndex)>> { ... } fn rela<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(&'data [<Self::Elf as FileHeader>::Rela], SectionIndex)>> { ... } fn dynamic<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(&'data [<Self::Elf as FileHeader>::Dyn], SectionIndex)>> { ... } fn notes<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<NoteIterator<'data, Self::Elf>>> { ... } fn group<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(u32, &'data [U32Bytes<Self::Endian>])>> { ... } fn hash_header<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<&'data HashHeader<Self::Endian>>> { ... } fn hash<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(HashTable<'data, Self::Elf>, SectionIndex)>> { ... } fn gnu_hash_header<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<&'data GnuHashHeader<Self::Endian>>> { ... } fn gnu_hash<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(GnuHashTable<'data, Self::Elf>, SectionIndex)>> { ... } fn gnu_versym<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(&'data [Versym<Self::Endian>], SectionIndex)>> { ... } fn gnu_verdef<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(VerdefIterator<'data, Self::Elf>, SectionIndex)>> { ... } fn gnu_verneed<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(VerneedIterator<'data, Self::Elf>, SectionIndex)>> { ... } fn gnu_attributes<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<AttributesSection<'data, Self::Elf>>> { ... } fn attributes<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<AttributesSection<'data, Self::Elf>> { ... } fn compression<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(&'data <Self::Elf as FileHeader>::CompressionHeader, u64, u64)>> { ... }
}
Expand description

A trait for generic access to elf::SectionHeader32 and elf::SectionHeader64.

Required Associated Types§

source

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

source

type Word: Into<u64>

source

type Endian: Endian

Required Methods§

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

Provided Methods§

source

fn name<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, strings: StringTable<'data, R> ) -> Result<&'data [u8]>

Parse the section name from the string table.

Get the sh_link field as a section index.

This may return a null section index, and does not check for validity.

Return true if the SHF_INFO_LINK flag is set.

Get the sh_info field as a section index.

This does not check the SHF_INFO_LINK flag. This may return a null section index, and does not check for validity.

source

fn file_range(&self, endian: Self::Endian) -> Option<(u64, u64)>

Return the offset and size of the section in the file.

Returns None for sections that have no data in the file.

source

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

Return the section data.

Returns Ok(&[]) if the section has no data. Returns Err for invalid values.

source

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

Return the section data as a slice of the given type.

Allows padding at the end of the data. Returns Ok(&[]) if the section has no data. Returns Err for invalid values, including bad alignment.

source

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

Return the strings in the section.

Returns Ok(None) if the section does not contain strings. Returns Err for invalid values.

source

fn symbols<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, sections: &SectionTable<'data, Self::Elf, R>, section_index: SectionIndex ) -> Result<Option<SymbolTable<'data, Self::Elf, R>>>

Return the symbols in the section.

Also finds the linked string table in sections.

section_index must be the 0-based index of this section, and is used to find the corresponding extended section index table in sections.

Returns Ok(None) if the section does not contain symbols. Returns Err for invalid values.

source

fn rel<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(&'data [<Self::Elf as FileHeader>::Rel], SectionIndex)>>

Return the Elf::Rel entries in the section.

Also returns the linked symbol table index.

Returns Ok(None) if the section does not contain relocations. Returns Err for invalid values.

source

fn rela<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(&'data [<Self::Elf as FileHeader>::Rela], SectionIndex)>>

Return the Elf::Rela entries in the section.

Also returns the linked symbol table index.

Returns Ok(None) if the section does not contain relocations. Returns Err for invalid values.

source

fn dynamic<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(&'data [<Self::Elf as FileHeader>::Dyn], SectionIndex)>>

Return entries in a dynamic section.

Also returns the linked string table index.

Returns Ok(None) if the section type is not SHT_DYNAMIC. Returns Err for invalid values.

source

fn notes<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<NoteIterator<'data, Self::Elf>>>

Return a note iterator for the section data.

Returns Ok(None) if the section does not contain notes. Returns Err for invalid values.

source

fn group<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(u32, &'data [U32Bytes<Self::Endian>])>>

Return the contents of a group section.

The first value is a GRP_* value, and the remaining values are section indices.

Returns Ok(None) if the section does not define a group. Returns Err for invalid values.

source

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

Return the header of a SysV hash section.

Returns Ok(None) if the section does not contain a SysV hash. Returns Err for invalid values.

source

fn hash<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(HashTable<'data, Self::Elf>, SectionIndex)>>

Return the contents of a SysV hash section.

Also returns the linked symbol table index.

Returns Ok(None) if the section does not contain a SysV hash. Returns Err for invalid values.

source

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

Return the header of a GNU hash section.

Returns Ok(None) if the section does not contain a GNU hash. Returns Err for invalid values.

source

fn gnu_hash<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(GnuHashTable<'data, Self::Elf>, SectionIndex)>>

Return the contents of a GNU hash section.

Also returns the linked symbol table index.

Returns Ok(None) if the section does not contain a GNU hash. Returns Err for invalid values.

source

fn gnu_versym<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(&'data [Versym<Self::Endian>], SectionIndex)>>

Return the contents of a SHT_GNU_VERSYM section.

Also returns the linked symbol table index.

Returns Ok(None) if the section type is not SHT_GNU_VERSYM. Returns Err for invalid values.

source

fn gnu_verdef<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(VerdefIterator<'data, Self::Elf>, SectionIndex)>>

Return an iterator for the entries of a SHT_GNU_VERDEF section.

Also returns the linked string table index.

Returns Ok(None) if the section type is not SHT_GNU_VERDEF. Returns Err for invalid values.

source

fn gnu_verneed<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(VerneedIterator<'data, Self::Elf>, SectionIndex)>>

Return an iterator for the entries of a SHT_GNU_VERNEED section.

Also returns the linked string table index.

Returns Ok(None) if the section type is not SHT_GNU_VERNEED. Returns Err for invalid values.

source

fn gnu_attributes<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<AttributesSection<'data, Self::Elf>>>

Return the contents of a SHT_GNU_ATTRIBUTES section.

Returns Ok(None) if the section type is not SHT_GNU_ATTRIBUTES. Returns Err for invalid values.

source

fn attributes<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<AttributesSection<'data, Self::Elf>>

Parse the contents of the section as attributes.

This function does not check whether section type corresponds to a section that contains attributes.

Returns Err for invalid values.

source

fn compression<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R ) -> Result<Option<(&'data <Self::Elf as FileHeader>::CompressionHeader, u64, u64)>>

Parse the compression header if present.

Returns the header, and the offset and size of the compressed section data in the file.

Returns Ok(None) if the section flags do not have SHF_COMPRESSED. Returns Err for invalid values.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Endian: Endian> SectionHeader for SectionHeader32<Endian>

§

type Elf = FileHeader32<Endian>

§

type Word = u32

§

type Endian = Endian

source§

impl<Endian: Endian> SectionHeader for SectionHeader64<Endian>

§

type Word = u64

§

type Endian = Endian

§

type Elf = FileHeader64<Endian>