Struct Section

Source
pub struct Section {
    pub name_offset: u32,
    pub kind: SectionKind,
    pub flags: SectionFlags,
    pub virtual_address: u64,
    pub offset: u64,
    pub size: u64,
    pub link: u32,
    pub info: u32,
    pub align: u64,
    pub entry_len: u64,
}
Expand description

Section.

Dynamic loader maps sections into virtual address space of a program as part of segments. Usually sections are part of segments, however, some section types exist on their own.

Fields§

§name_offset: u32

Offset of the section name in the section that stores section names.

You can find the index of this section via Header::section_names_index.

§kind: SectionKind

Section type.

§flags: SectionFlags

Section flags.

§virtual_address: u64

Virtual address (in-memory offset).

§offset: u64

In-file offset.

§size: u64

Section size.

§link: u32

Optional index of the related section.

§info: u32

Extra information.

Depends on the section type.

§align: u64

Alignment.

Only virtual address has alignment constraints.

§entry_len: u64

The size of the entry in the references table.

Only relevant for sections that reference tables.

Implementations§

Source§

impl Section

Source

pub fn null() -> Self

Create NULL section.

Source§

impl Section

Source

pub fn read_content<R: ElfRead + ElfSeek, T: BlockRead>( &self, reader: &mut R, class: Class, byte_order: ByteOrder, ) -> Result<T, Error>

Read section contents as bytes.

Source

pub fn write_content<W: ElfWrite + ElfSeek, T: BlockWrite + ?Sized>( &self, writer: &mut W, class: Class, byte_order: ByteOrder, content: &T, ) -> Result<(), Error>

Write section contents.

Source

pub fn clear_content<W: ElfWrite + ElfSeek>( &self, writer: &mut W, ) -> Result<(), Error>

Zero out the entry’s content.

Source

pub const fn virtual_address_range(&self) -> Range<u64>

Virtual address range.

Source

pub const fn file_offset_range(&self) -> Range<u64>

In-file location of the segment.

Source

pub fn check( &self, header: &Header, program_header: &ProgramHeader, ) -> Result<(), Error>

Check consistency.

Trait Implementations§

Source§

impl Debug for Section

Source§

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

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

impl Default for Section

Source§

fn default() -> Self

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

impl EntityIo for Section

Source§

fn read<R: ElfRead>( reader: &mut R, class: Class, byte_order: ByteOrder, ) -> Result<Self, Error>

Read the entity from the reader.
Source§

fn write<W: ElfWrite>( &self, writer: &mut W, class: Class, byte_order: ByteOrder, ) -> Result<(), Error>

Write the entity to the writer.

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.