Struct object::read::RelocationMap

source ·
pub struct RelocationMap(/* private fields */);
Expand description

A map from section offsets to relocation information.

This can be used to apply relocations to a value at a given section offset. This is intended for use with DWARF in relocatable object files, and only supports relocations that are used in DWARF.

Returned by ObjectSection::relocation_map.

Implementations§

source§

impl RelocationMap

source

pub fn new<'data, 'file, T>( file: &'file T, section: &T::Section<'file> ) -> Result<Self>
where T: Object<'data>,

Construct a new relocation map for a section.

Fails if any relocation cannot be added to the map. You can manually use add if you need different error handling, such as to list all errors or to ignore them.

source

pub fn add<'data: 'file, 'file, T>( &mut self, file: &'file T, offset: u64, relocation: Relocation ) -> Result<()>
where T: Object<'data>,

Add a single relocation to the map.

source

pub fn relocate(&self, offset: u64, value: u64) -> u64

Relocate a value that was read from the section at the given offset.

Trait Implementations§

source§

impl Debug for RelocationMap

source§

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

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

impl Default for RelocationMap

source§

fn default() -> RelocationMap

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

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

§

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.