Trait dynasmrt::relocations::Relocation [−][src]
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;
}
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.
Associated Types
Required methods
fn from_encoding(encoding: Self::Encoding) -> Self
fn from_encoding(encoding: Self::Encoding) -> Self
construct this relocation from an encoded representation.
fn 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.
fn 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.
Read a value from a buffer of size self.size()
in the format of this relocation.
fn kind(&self) -> RelocationKind
fn kind(&self) -> RelocationKind
Specifies what kind of relocation this relocation instance is.