Struct object::read::elf::SectionTable

source ·
pub struct SectionTable<'data, Elf: FileHeader, R = &'data [u8]>
where R: ReadRef<'data>,
{ /* private fields */ }
Expand description

The table of section headers in an ELF file.

Also includes the string table used for the section names.

Returned by FileHeader::sections.

Implementations§

source§

impl<'data, Elf: FileHeader, R: ReadRef<'data>> SectionTable<'data, Elf, R>

source

pub fn new( sections: &'data [Elf::SectionHeader], strings: StringTable<'data, R>, ) -> Self

Create a new section table.

source

pub fn iter(&self) -> Iter<'data, Elf::SectionHeader>

Iterate over the section headers.

This includes the null section at index 0, which you will usually need to skip.

source

pub fn enumerate( &self, ) -> impl Iterator<Item = (SectionIndex, &'data Elf::SectionHeader)>

Iterate over the section headers and their indices.

This includes the null section at index 0, which you will usually need to skip.

source

pub fn is_empty(&self) -> bool

Return true if the section table is empty.

source

pub fn len(&self) -> usize

The number of section headers.

source

pub fn section(&self, index: SectionIndex) -> Result<&'data Elf::SectionHeader>

Get the section header at the given index.

Returns an error for the null section at index 0.

source

pub fn section_by_name( &self, endian: Elf::Endian, name: &[u8], ) -> Option<(SectionIndex, &'data Elf::SectionHeader)>

Return the section header with the given name.

Ignores sections with invalid names.

source

pub fn section_name( &self, endian: Elf::Endian, section: &Elf::SectionHeader, ) -> Result<&'data [u8]>

Return the section name for the given section header.

source

pub fn strings( &self, endian: Elf::Endian, data: R, index: SectionIndex, ) -> Result<StringTable<'data, R>>

Return the string table at the given section index.

Returns an empty string table if the index is 0. Returns an error if the section is not a string table.

source

pub fn symbols( &self, endian: Elf::Endian, data: R, sh_type: u32, ) -> Result<SymbolTable<'data, Elf, R>>

Return the symbol table of the given section type.

Returns an empty symbol table if the symbol table does not exist.

source

pub fn symbol_table_by_index( &self, endian: Elf::Endian, data: R, index: SectionIndex, ) -> Result<SymbolTable<'data, Elf, R>>

Return the symbol table at the given section index.

Returns an error if the section is not a symbol table.

source

pub fn relocation_sections( &self, endian: Elf::Endian, symbol_section: SectionIndex, ) -> Result<RelocationSections>

Create a mapping from section index to associated relocation sections.

source

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

Return the contents of a dynamic section.

Also returns the linked string table index.

Returns Ok(None) if there is no SHT_DYNAMIC section. Returns Err for invalid values.

source

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

Return the header of a SysV hash section.

Returns Ok(None) if there is no SysV GNU hash section. Returns Err for invalid values.

source

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

Return the contents of a SysV hash section.

Also returns the linked symbol table index.

Returns Ok(None) if there is no SysV hash section. Returns Err for invalid values.

source

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

Return the header of a GNU hash section.

Returns Ok(None) if there is no GNU hash section. Returns Err for invalid values.

source

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

Return the contents of a GNU hash section.

Also returns the linked symbol table index.

Returns Ok(None) if there is no GNU hash section. Returns Err for invalid values.

source

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

Return the contents of a SHT_GNU_VERSYM section.

Also returns the linked symbol table index.

Returns Ok(None) if there is no SHT_GNU_VERSYM section. Returns Err for invalid values.

source

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

Return the contents of a SHT_GNU_VERDEF section.

Also returns the linked string table index.

Returns Ok(None) if there is no SHT_GNU_VERDEF section. Returns Err for invalid values.

source

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

Return the contents of a SHT_GNU_VERNEED section.

Also returns the linked string table index.

Returns Ok(None) if there is no SHT_GNU_VERNEED section. Returns Err for invalid values.

source

pub fn versions( &self, endian: Elf::Endian, data: R, ) -> Result<Option<VersionTable<'data, Elf>>>

Returns the symbol version table.

Returns Ok(None) if there is no SHT_GNU_VERSYM section. Returns Err for invalid values.

Trait Implementations§

source§

impl<'data, Elf: Clone + FileHeader, R> Clone for SectionTable<'data, Elf, R>
where R: ReadRef<'data> + Clone, Elf::SectionHeader: Clone,

source§

fn clone(&self) -> SectionTable<'data, Elf, R>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'data, Elf: Debug + FileHeader, R> Debug for SectionTable<'data, Elf, R>
where R: ReadRef<'data> + Debug, Elf::SectionHeader: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'data, Elf: FileHeader, R: ReadRef<'data>> Default for SectionTable<'data, Elf, R>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'data, Elf: Copy + FileHeader, R> Copy for SectionTable<'data, Elf, R>
where R: ReadRef<'data> + Copy, Elf::SectionHeader: Copy,

Auto Trait Implementations§

§

impl<'data, Elf, R> Freeze for SectionTable<'data, Elf, R>
where R: Freeze,

§

impl<'data, Elf, R> RefUnwindSafe for SectionTable<'data, Elf, R>

§

impl<'data, Elf, R> Send for SectionTable<'data, Elf, R>
where <Elf as FileHeader>::SectionHeader: Sync, R: Send,

§

impl<'data, Elf, R> Sync for SectionTable<'data, Elf, R>
where <Elf as FileHeader>::SectionHeader: Sync, R: Sync,

§

impl<'data, Elf, R> Unpin for SectionTable<'data, Elf, R>
where R: Unpin,

§

impl<'data, Elf, R> UnwindSafe for SectionTable<'data, Elf, R>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.