[−][src]Trait dynasmrt::relocations::Relocation
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.
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>
&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.
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.
Implementors
impl Relocation for Aarch64Relocation
[src]
type Encoding = (u8,)
fn from_encoding(encoding: Self::Encoding) -> Self
[src]
fn from_size(size: RelocationSize) -> Self
[src]
fn size(&self) -> usize
[src]
fn write_value(
&self,
buf: &mut [u8],
value: isize
) -> Result<(), ImpossibleRelocation>
[src]
&self,
buf: &mut [u8],
value: isize
) -> Result<(), ImpossibleRelocation>
fn read_value(&self, buf: &[u8]) -> isize
[src]
fn kind(&self) -> RelocationKind
[src]
fn page_size() -> usize
[src]
impl Relocation for RelocationSize
[src]
type Encoding = u8
fn from_encoding(encoding: Self::Encoding) -> Self
[src]
fn from_size(size: RelocationSize) -> Self
[src]
fn size(&self) -> usize
[src]
fn write_value(
&self,
buf: &mut [u8],
value: isize
) -> Result<(), ImpossibleRelocation>
[src]
&self,
buf: &mut [u8],
value: isize
) -> Result<(), ImpossibleRelocation>
fn read_value(&self, buf: &[u8]) -> isize
[src]
fn kind(&self) -> RelocationKind
[src]
fn page_size() -> usize
[src]
impl Relocation for X64Relocation
[src]
type Encoding = (u8, u8)
fn from_encoding(encoding: Self::Encoding) -> Self
[src]
fn from_size(size: RelocationSize) -> Self
[src]
fn start_offset(&self) -> usize
[src]
fn field_offset(&self) -> usize
[src]
fn size(&self) -> usize
[src]
fn write_value(
&self,
buf: &mut [u8],
value: isize
) -> Result<(), ImpossibleRelocation>
[src]
&self,
buf: &mut [u8],
value: isize
) -> Result<(), ImpossibleRelocation>
fn read_value(&self, buf: &[u8]) -> isize
[src]
fn kind(&self) -> RelocationKind
[src]
fn page_size() -> usize
[src]
impl Relocation for X86Relocation
[src]
type Encoding = (u8, u8, u8)
fn from_encoding(encoding: Self::Encoding) -> Self
[src]
fn from_size(size: RelocationSize) -> Self
[src]
fn start_offset(&self) -> usize
[src]
fn field_offset(&self) -> usize
[src]
fn size(&self) -> usize
[src]
fn write_value(
&self,
buf: &mut [u8],
value: isize
) -> Result<(), ImpossibleRelocation>
[src]
&self,
buf: &mut [u8],
value: isize
) -> Result<(), ImpossibleRelocation>