Struct 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§

§

impl Freeze for RelocationMap

§

impl RefUnwindSafe for RelocationMap

§

impl Send for RelocationMap

§

impl Sync for RelocationMap

§

impl Unpin for RelocationMap

§

impl UnwindSafe for RelocationMap

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.