Skip to main content

Relocation

Struct Relocation 

Source
pub struct Relocation(/* private fields */);
Expand description

A relocation entry

It roughly follows the Relocation struct from the object crate, with some simplifications. Represents a bitfield.

Implementations§

Source§

impl Relocation

Source

pub const OFFSET_BITS: u32 = 16u32

The number of bits offset occupies in the bitfield.

Source

pub const OFFSET_OFFSET: u32 = 0u32

The bitfield start bit of offset.

Source

pub const ENCODING_BITS: u32 = 7u32

The number of bits encoding occupies in the bitfield.

Source

pub const ENCODING_OFFSET: u32 = 16u32

The bitfield start bit of encoding.

Source

pub const RELATIVE_BITS: u32 = 1u32

The number of bits relative occupies in the bitfield.

Source

pub const RELATIVE_OFFSET: u32 = 23u32

The bitfield start bit of relative.

Source

pub const SIZE_BITS: u32 = 8u32

The number of bits size occupies in the bitfield.

Source

pub const SIZE_OFFSET: u32 = 24u32

The bitfield start bit of size.

Source

pub const ADDEND_BITS: u32 = 12u32

The number of bits addend occupies in the bitfield.

Source

pub const ADDEND_OFFSET: u32 = 32u32

The bitfield start bit of addend.

Source

pub const PATCH_KIND_BITS: u32 = 4u32

The number of bits patch_kind occupies in the bitfield.

Source

pub const PATCH_KIND_OFFSET: u32 = 44u32

The bitfield start bit of patch_kind.

Source

pub const PATCH_ID_BITS: u32 = 16u32

The number of bits patch_id occupies in the bitfield.

Source

pub const PATCH_ID_OFFSET: u32 = 48u32

The bitfield start bit of patch_id.

Source

pub const fn new() -> Self

Creates a new bitfield instance.

Source

pub const fn new_without_defaults() -> Self

Creates a new bitfield instance without setting any default values.

Source

pub const fn from_bits(bits: u64) -> Self

Creates a new bitfield instance from the given bits.

Source

pub const fn from_bits_with_defaults(bits: u64) -> Self

Creates a new bitfield instance from the given bits while respecting field default values.

Source

pub const fn into_bits(self) -> u64

Returns the bits of the bitfield.

Source

pub const fn offset(&self) -> u16

Returns bits 0..=15.

Source

pub const fn encoding(&self) -> RelocationEncoding

Returns bits 16..=22.

Source

pub const fn relative(&self) -> bool

Returns bit 23.

Source

pub const fn size(&self) -> u8

Returns bits 24..=31.

Source

pub const fn addend(&self) -> i16

Returns sign-extended bits 32..=43 from the sign-bit 32.

Source

pub const fn patch_kind(&self) -> PatchKind

Returns bits 44..=47.

Source

pub const fn patch_id(&self) -> u16

Returns bits 48..=63.

Source

pub const fn set_offset(&mut self, bits: u16)

Sets bits 0..=15.

Source

pub const fn checked_set_offset( &mut self, bits: u16, ) -> Result<(), &'static str>

Sets bits 0..=15. Returns an error if the value is too big to fit within the field bits.

Source

pub const fn set_encoding(&mut self, bits: RelocationEncoding)

Sets bits 16..=22.

Source

pub const fn checked_set_encoding( &mut self, bits: RelocationEncoding, ) -> Result<(), &'static str>

Sets bits 16..=22. Returns an error if the value is too big to fit within the field bits.

Source

pub const fn set_relative(&mut self, bits: bool)

Sets bit 23.

Source

pub const fn checked_set_relative( &mut self, bits: bool, ) -> Result<(), &'static str>

Sets bit 23. Returns an error if the value is too big to fit within the field bit.

Source

pub const fn set_size(&mut self, bits: u8)

Sets bits 24..=31.

Source

pub const fn checked_set_size(&mut self, bits: u8) -> Result<(), &'static str>

Sets bits 24..=31. Returns an error if the value is too big to fit within the field bits.

Source

pub const fn set_addend(&mut self, bits: i16)

Sets bits 32..=43.

Source

pub const fn checked_set_addend( &mut self, bits: i16, ) -> Result<(), &'static str>

Sets bits 32..=43. Returns an error if the value is too big to fit within the field bits.

Source

pub const fn set_patch_kind(&mut self, bits: PatchKind)

Sets bits 44..=47.

Source

pub const fn checked_set_patch_kind( &mut self, bits: PatchKind, ) -> Result<(), &'static str>

Sets bits 44..=47. Returns an error if the value is too big to fit within the field bits.

Source

pub const fn set_patch_id(&mut self, bits: u16)

Sets bits 48..=63.

Source

pub const fn checked_set_patch_id( &mut self, bits: u16, ) -> Result<(), &'static str>

Sets bits 48..=63. Returns an error if the value is too big to fit within the field bits.

Source

pub fn set_bits(&mut self, bits: u64)

Sets the writable bits of the bitfield.

Source

pub fn set_bits_with_defaults(&mut self, bits: u64)

Sets the writable bits of the bitfield while respecting defaults.

Source

pub fn clear_bits(&mut self)

Clears the writable bits of the bitfield.

Source

pub fn clear_bits_with_defaults(&mut self)

Clears the writable bits of the bitfield.

Source§

impl Relocation

Source

pub fn is_invalid(&self) -> bool

Source

pub fn patch_info(&self) -> Option<PatchInfo>

Source

pub fn supports_value(&self, value: usize) -> bool

Source

pub fn apply_raw(&self, dest: &mut [u8], value: usize)

Trait Implementations§

Source§

impl Clone for Relocation

Source§

fn clone(&self) -> Relocation

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 Relocation

Source§

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

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

impl Default for Relocation

Source§

fn default() -> Self

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

impl From<Relocation> for u64

Source§

fn from(b: Relocation) -> u64

Converts to this type from the input type.
Source§

impl From<u64> for Relocation

Source§

fn from(bits: u64) -> Self

Converts to this type from the input type.
Source§

impl Hash for Relocation

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 PartialEq for Relocation

Source§

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

Source§

impl Eq for Relocation

Source§

impl StructuralPartialEq for Relocation

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