Trait dynasmrt::relocations::Relocation

source ·
pub trait Relocation {
    type Encoding;

    // Required methods
    fn from_encoding(encoding: Self::Encoding) -> Self;
    fn from_size(size: RelocationSize) -> Self;
    fn size(&self) -> usize;
    fn write_value(
        &self,
        buf: &mut [u8],
        value: isize,
    ) -> Result<(), ImpossibleRelocation>;
    fn read_value(&self, buf: &[u8]) -> isize;
    fn kind(&self) -> RelocationKind;
    fn page_size() -> usize;
}
Expand description

Used to inform assemblers on how to implement relocations for each architecture. When implementing a new architecture, one simply has to implement this trait for the architecture’s relocation definition.

Required Associated Types§

source

type Encoding

The encoded representation for this relocation that is emitted by the dynasm! macro.

Required Methods§

source

fn from_encoding(encoding: Self::Encoding) -> Self

construct this relocation from an encoded representation.

source

fn from_size(size: RelocationSize) -> Self

construct this relocation from a simple size. This is used to implement relocations in directives and literal pools.

source

fn size(&self) -> usize

The size of the slice of bytes affected by this relocation

source

fn write_value( &self, buf: &mut [u8], value: isize, ) -> Result<(), ImpossibleRelocation>

Write a value into a buffer of size self.size() in the format of this relocation. Any bits not part of the relocation should be preserved.

source

fn read_value(&self, buf: &[u8]) -> isize

Read a value from a buffer of size self.size() in the format of this relocation.

source

fn kind(&self) -> RelocationKind

Specifies what kind of relocation this relocation instance is.

source

fn page_size() -> usize

Specifies the default page size on this platform.

Object Safety§

This trait is not object safe.

Implementors§