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 28 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 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)>> { ... }
}
Expand description
A trait for generic access to SectionHeader32
and 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 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 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.