Struct goblin::pe::symbol::Symbol

source ·
#[repr(C)]
pub struct Symbol { pub name: [u8; 8], pub value: u32, pub section_number: i16, pub typ: u16, pub storage_class: u8, pub number_of_aux_symbols: u8, }
Expand description

A COFF symbol.

Unwind information for this function can be loaded with ExceptionData::get_unwind_info.

Fields§

§name: [u8; 8]

The name of the symbol.

An array of 8 bytes is used if the name is not more than 8 bytes long. This array is padded with nulls on the right if the name is less than 8 bytes long.

For longer names, the first 4 bytes are all zeros, and the second 4 bytes are an offset into the string table.

§value: u32

The value that is associated with the symbol.

The interpretation of this field depends on section_number and storage_class. A typical meaning is the relocatable address.

§section_number: i16

A one-based index into the section table. Zero and negative values have special meanings.

§typ: u16

A number that represents type.

Microsoft tools set this field to 0x20 (function) or 0x0 (not a function).

§storage_class: u8

An enumerated value that represents storage class.

§number_of_aux_symbols: u8

The number of auxiliary symbol table entries that follow this record.

Each auxiliary record is the same size as a standard symbol-table record (18 bytes), but rather than define a new symbol, the auxiliary record gives additional information on the last symbol defined.

Implementations§

source§

impl Symbol

source

pub fn parse<'a>( bytes: &'a [u8], offset: usize ) -> Result<(Option<&'a str>, Symbol)>

Parse the symbol at the given offset.

If the symbol has an inline name, then also returns a reference to the name’s location in bytes.

source

pub fn name<'a>(&'a self, strtab: &'a Strtab<'_>) -> Result<&'a str>

Returns the symbol name.

This may be a reference to an inline name in the symbol, or to a strtab entry.

source

pub fn name_offset(&self) -> Option<u32>

Return the strtab offset of the symbol name.

Returns None if the name is inline.

source

pub fn set_name_offset(&mut self, offset: u32)

Set the strtab offset of the symbol name.

source

pub fn base_type(&self) -> u16

Return the base type of the symbol.

This type uses the IMAGE_SYM_TYPE_* definitions.

source

pub fn derived_type(&self) -> u16

Return the derived type of the symbol.

This type uses the IMAGE_SYM_DTYPE_* definitions.

source

pub fn is_function_definition(&self) -> bool

Return true for function definitions.

These symbols use AuxFunctionDefinition for auxiliary symbol records.

source

pub fn is_weak_external(&self) -> bool

Return true for weak external symbols.

These symbols use AuxWeakExternal for auxiliary symbol records.

source

pub fn is_file(&self) -> bool

Return true for file symbol records.

The auxiliary records contain the name of the source code file.

source

pub fn is_section_definition(&self) -> bool

Return true for section definitions.

These symbols use AuxSectionDefinition for auxiliary symbol records.

Trait Implementations§

source§

impl Clone for Symbol

source§

fn clone(&self) -> Symbol

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 Symbol

source§

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

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

impl Default for Symbol

source§

fn default() -> Symbol

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

impl FromCtx<Endian> for Symbol

source§

fn from_ctx(src: &[u8], ctx: Endian) -> Self

source§

impl<'a> IntoCtx<Endian> for &'a Symbol

source§

fn into_ctx(self, dst: &mut [u8], ctx: Endian)

source§

impl IntoCtx<Endian> for Symbol

source§

fn into_ctx(self, dst: &mut [u8], ctx: Endian)

source§

impl PartialEq for Symbol

source§

fn eq(&self, other: &Symbol) -> 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<Endian> for Symbol

source§

impl<'a> TryFromCtx<'a, Endian> for Symbol
where Symbol: 'a,

§

type Error = Error

source§

fn try_from_ctx( src: &'a [u8], ctx: Endian ) -> Result<(Self, usize), Self::Error>

source§

impl<'a> TryIntoCtx<Endian> for &'a Symbol

§

type Error = Error

source§

fn try_into_ctx(self, dst: &mut [u8], ctx: Endian) -> Result<usize, Self::Error>

source§

impl TryIntoCtx<Endian> for Symbol

§

type Error = Error

source§

fn try_into_ctx(self, dst: &mut [u8], ctx: Endian) -> Result<usize, Self::Error>

source§

impl Copy for Symbol

source§

impl StructuralPartialEq for Symbol

Auto Trait Implementations§

§

impl Freeze for Symbol

§

impl RefUnwindSafe for Symbol

§

impl Send for Symbol

§

impl Sync for Symbol

§

impl Unpin for Symbol

§

impl UnwindSafe for Symbol

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.