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§
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 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.