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§
Required Methods§
sourcefn from_encoding(encoding: Self::Encoding) -> Self
fn from_encoding(encoding: Self::Encoding) -> Self
construct this relocation from an encoded representation.
sourcefn from_size(size: RelocationSize) -> Self
fn from_size(size: RelocationSize) -> Self
construct this relocation from a simple size. This is used to implement relocations in directives and literal pools.
sourcefn write_value(
&self,
buf: &mut [u8],
value: isize,
) -> Result<(), ImpossibleRelocation>
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.
sourcefn read_value(&self, buf: &[u8]) -> isize
fn read_value(&self, buf: &[u8]) -> isize
Read a value from a buffer of size self.size()
in the format of this relocation.
sourcefn kind(&self) -> RelocationKind
fn kind(&self) -> RelocationKind
Specifies what kind of relocation this relocation instance is.
Object Safety§
This trait is not object safe.