pub trait SectionHeader: Debug + Pod {
type Elf: FileHeader<SectionHeader = Self, Endian = Self::Endian, Word = Self::Word>;
type Word: Into<u64>;
type Endian: Endian;
Show 35 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 relr<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<RelrIterator<'data, Self::Elf>>> { ... }
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§
type Elf: FileHeader<SectionHeader = Self, Endian = Self::Endian, Word = Self::Word>
type Word: Into<u64>
type Endian: Endian
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§
Sourcefn name<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
strings: StringTable<'data, R>,
) -> Result<&'data [u8]>
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.
Sourcefn link(&self, endian: Self::Endian) -> SectionIndex
fn link(&self, endian: Self::Endian) -> SectionIndex
Get the sh_link field as a section index.
This may return a null section index, and does not check for validity.
Sourcefn has_info_link(&self, endian: Self::Endian) -> bool
fn has_info_link(&self, endian: Self::Endian) -> bool
Return true if the SHF_INFO_LINK flag is set.
Sourcefn info_link(&self, endian: Self::Endian) -> SectionIndex
fn info_link(&self, endian: Self::Endian) -> SectionIndex
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.
Sourcefn file_range(&self, endian: Self::Endian) -> Option<(u64, u64)>
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.
Sourcefn data<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<&'data [u8]>
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.
Sourcefn data_as_array<'data, T: Pod, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<&'data [T]>
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.
Sourcefn strings<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<StringTable<'data, R>>>
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.
Sourcefn 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 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.
Sourcefn rel<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<(&'data [<Self::Elf as FileHeader>::Rel], SectionIndex)>>
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.
Sourcefn rela<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<(&'data [<Self::Elf as FileHeader>::Rela], SectionIndex)>>
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.
Sourcefn relr<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<RelrIterator<'data, Self::Elf>>>
fn relr<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<Option<RelrIterator<'data, Self::Elf>>>
Return the Elf::Relr entries in the section.
Returns Ok(None) if the section does not contain relative relocations.
Returns Err for invalid values.
Sourcefn dynamic<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<(&'data [<Self::Elf as FileHeader>::Dyn], SectionIndex)>>
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.
Sourcefn notes<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<NoteIterator<'data, Self::Elf>>>
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.
Sourcefn group<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<(u32, &'data [U32Bytes<Self::Endian>])>>
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.
Sourcefn hash_header<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<&'data HashHeader<Self::Endian>>>
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.
Sourcefn hash<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<(HashTable<'data, Self::Elf>, SectionIndex)>>
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.
Sourcefn gnu_hash_header<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<&'data GnuHashHeader<Self::Endian>>>
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.
Sourcefn gnu_hash<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<(GnuHashTable<'data, Self::Elf>, SectionIndex)>>
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.
Sourcefn gnu_versym<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<(&'data [Versym<Self::Endian>], SectionIndex)>>
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.
Sourcefn gnu_verdef<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<(VerdefIterator<'data, Self::Elf>, SectionIndex)>>
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.
Sourcefn gnu_verneed<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<(VerneedIterator<'data, Self::Elf>, SectionIndex)>>
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.
Sourcefn gnu_attributes<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<AttributesSection<'data, Self::Elf>>>
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.
Sourcefn attributes<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<AttributesSection<'data, Self::Elf>>
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.
Sourcefn compression<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<Option<(&'data <Self::Elf as FileHeader>::CompressionHeader, u64, u64)>>
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.
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.