[][src]Trait dynasmrt::relocations::Relocation

pub trait Relocation {
    type Encoding;
    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; fn start_offset(&self) -> usize { ... }
fn field_offset(&self) -> usize { ... } }

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.

Associated Types

type Encoding

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

Loading content...

Required methods

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

construct this relocation from an encoded representation.

fn from_size(size: RelocationSize) -> Self

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

fn size(&self) -> usize

The size of the slice of bytes affected by this relocation

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.

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

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

fn kind(&self) -> RelocationKind

Specifies what kind of relocation this relocation instance is.

fn page_size() -> usize

Specifies the default page size on this platform.

Loading content...

Provided methods

fn start_offset(&self) -> usize

Returns the offset that this relocation is relative to, backwards with respect to the definition point of this relocation. (i.e. 0 for x64 as relocations are relative to the end of the instruction, and 4 for aarch64 as they are) Defaults to the size of this relocation.

fn field_offset(&self) -> usize

Returns the offset of the start of the bytes containing this relocation, backwards with respect to the definition point of this relocation. Defaults to the size of this relocation.

Loading content...

Implementors

impl Relocation for Aarch64Relocation[src]

type Encoding = (u8,)

impl Relocation for RelocationSize[src]

type Encoding = u8

impl Relocation for X64Relocation[src]

type Encoding = (u8, u8)

impl Relocation for X86Relocation[src]

type Encoding = (u8, u8, u8)

Loading content...