LookupAddress

Enum LookupAddress 

Source
pub enum LookupAddress {
    Relative(u32),
    Svma(u64),
    FileOffset(u64),
}
Expand description

An address that can be looked up in a SymbolMap.

You’ll usually want to use LookupAddress::Relative, i.e. addresses that are relative to some “image base address”. This form works with all types of symbol maps across all platforms.

When testing, be aware that many binaries are laid out in such a way that all three representations of addresses are the same: The image base address is often zero and the sections are often laid out so that each section’s address matches its file offset. So if you misrepresent an address in the wrong form, you might not notice it because it still works until you encounter a more complex binary.

Variants§

§

Relative(u32)

A relative address is relative to the image base address.

What this means depends on the format of the binary:

  • On Windows, a “relative address” is the same as a RVA (“relative virtual address”) in the PE file.
  • On macOS, a “relative address” is relative to the start of the __TEXT segment.
  • On Linux / ELF, a “relative address” is relative to the address of the first LOAD command in the program header table. In other words, it’s relative to the start of the first segment.
  • For Jitdump files, the “relative address” space is a conceptual space in which the code from all JIT_CODE_LOAD records is laid out sequentially, starting at 0. So the relative address of an instruction inside a JIT_CODE_LOAD record is the sum of the code_size fields of all previous JIT_CODE_LOAD records plus the offset of the instruction within the code of this JIT_CODE_LOAD record.

See relative_address_base for more information.

§

Svma(u64)

A “stated virtual memory address”, i.e. a virtual memory address as written down in the binary. In mach-O and ELF, this is the space that section addresses and symbol addresses are in. It’s the type of address you’d pass to the Linux addr2line tool.

This type of lookup address is not supported by symbol maps for PDB files or Breakpad files.

§

FileOffset(u64)

A raw file offset to the point in the binary file where the bytes of the instruction are stored for which symbols should be looked up.

On Linux, if you have an “AVMA” (absolute virtual memory address) and the /proc/<pid>/maps for the process, this is probably the easiest form of address to compute, because the process maps give you the file offsets.

However, if you do this, be aware that the file offset often is not the same as an SVMA, so expect wrong results if you end up using it in places where SVMAs are expected - it might work fine with some binaries and then break with others.

File offsets are not supported by symbol maps for PDB files or Breakpad files.

Trait Implementations§

Source§

impl Clone for LookupAddress

Source§

fn clone(&self) -> LookupAddress

Returns a duplicate 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 LookupAddress

Source§

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

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

impl Hash for LookupAddress

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for LookupAddress

Source§

fn cmp(&self, other: &LookupAddress) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for LookupAddress

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for LookupAddress

Source§

fn partial_cmp(&self, other: &LookupAddress) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for LookupAddress

Source§

impl Eq for LookupAddress

Source§

impl StructuralPartialEq for LookupAddress

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

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

impl<T> ErasedDestructor for T
where T: 'static,