Struct goblin::elf::section_header::SectionHeader

source ·
pub struct SectionHeader {
    pub sh_name: usize,
    pub sh_type: u32,
    pub sh_flags: u64,
    pub sh_addr: u64,
    pub sh_offset: u64,
    pub sh_size: u64,
    pub sh_link: u32,
    pub sh_info: u32,
    pub sh_addralign: u64,
    pub sh_entsize: u64,
}
Expand description

A unified SectionHeader - convertable to and from 32-bit and 64-bit variants

Fields§

§sh_name: usize

Section name (string tbl index)

§sh_type: u32

Section type

§sh_flags: u64

Section flags

§sh_addr: u64

Section virtual addr at execution

§sh_offset: u64

Section file offset

§sh_size: u64

Section size in bytes

§sh_link: u32

Link to another section

§sh_info: u32

Additional section information

§sh_addralign: u64

Section alignment

§sh_entsize: u64

Entry size if section holds table

Implementations§

source§

impl SectionHeader

source

pub fn size(ctx: Ctx) -> usize

Return the size of the underlying section header, given a Ctx

source

pub fn new() -> Self

source

pub fn file_range(&self) -> Option<Range<usize>>

Returns this section header’s file offset range, if the section occupies space in fhe file.

source

pub fn vm_range(&self) -> Range<usize>

Returns this section header’s virtual memory range

source

pub fn parse( bytes: &[u8], offset: usize, count: usize, ctx: Ctx ) -> Result<Vec<SectionHeader>>

Parse count section headers from bytes at offset, using the given ctx Assuming this is read from the whole file, it will check offset.

source

pub fn parse_from( bytes: &[u8], offset: usize, count: usize, ctx: Ctx ) -> Result<Vec<SectionHeader>>

Parse count section headers from bytes at offset, using the given ctx without performing any offset checking to allow parsing relatively

source

pub fn check_size(&self, size: usize) -> Result<()>

source

pub fn is_relocation(&self) -> bool

source

pub fn is_executable(&self) -> bool

source

pub fn is_writable(&self) -> bool

source

pub fn is_alloc(&self) -> bool

Trait Implementations§

source§

impl Clone for SectionHeader

source§

fn clone(&self) -> SectionHeader

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 Debug for SectionHeader

source§

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

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

impl Default for SectionHeader

source§

fn default() -> SectionHeader

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

impl From<SectionHeader> for SectionHeader

source§

fn from(sh: ElfSectionHeader) -> Self

Converts to this type from the input type.
source§

impl From<SectionHeader> for ElfSectionHeader

source§

fn from(sh: SectionHeader) -> Self

Converts to this type from the input type.
source§

impl From<SectionHeader> for ElfSectionHeader

source§

fn from(sh: SectionHeader) -> Self

Converts to this type from the input type.
source§

impl From<SectionHeader> for SectionHeader

source§

fn from(sh: ElfSectionHeader) -> Self

Converts to this type from the input type.
source§

impl IntoCtx<Ctx> for SectionHeader

source§

fn into_ctx(self, bytes: &mut [u8], _: Ctx)

source§

impl PartialEq for SectionHeader

source§

fn eq(&self, other: &SectionHeader) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SizeWith<Ctx> for SectionHeader

source§

impl<'a> TryFromCtx<'a, Ctx> for SectionHeader

§

type Error = Error

source§

fn try_from_ctx(bytes: &'a [u8], _: Ctx) -> Result<(Self, usize), Self::Error>

source§

impl TryIntoCtx<Ctx> for SectionHeader

§

type Error = Error

source§

fn try_into_ctx(self, bytes: &mut [u8], _: Ctx) -> Result<usize, Self::Error>

source§

impl StructuralPartialEq for SectionHeader

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