[−][src]Struct dynasmrt::x86::Assembler
This struct is an implementation of a dynasm runtime. It supports incremental compilation as well as multithreaded execution with simultaneous compilation. Its implementation ensures that no memory is writeable and executable at the same time.
Methods
impl Assembler
[src]
pub fn new() -> Result<Assembler>
[src]
Create a new Assembler
instance
This function will return an error if it was not
able to map the required executable memory. However, further methods
on the Assembler
will simply panic if an error occurs during memory
remapping as otherwise it would violate the invariants of the assembler.
This behaviour could be improved but currently the underlying memmap crate
does not return the original mappings if a call to mprotect/VirtualProtect
fails so there is no reliable way to error out if a call fails while leaving
the logic of the Assembler
intact.
pub fn new_dynamic_label(&mut self) -> DynamicLabel
[src]
Create a new dynamic label that can be referenced and defined.
pub fn get_dynamic_label_offset(
&self,
label: DynamicLabel
) -> Option<AssemblyOffset>
[src]
&self,
label: DynamicLabel
) -> Option<AssemblyOffset>
Query the offset of a dynamic label.
pub fn alter<F, O>(&mut self, f: F) -> O where
F: FnOnce(&mut AssemblyModifier) -> O,
[src]
F: FnOnce(&mut AssemblyModifier) -> O,
To allow already committed code to be altered, this method allows modification
of the internal ExecutableBuffer directly. When this method is called, all
data will be committed and access to the internal ExecutableBuffer
will be locked.
The passed function will then be called with an AssemblyModifier
as argument.
Using this AssemblyModifier
changes can be made to the committed code.
After this function returns, any labels in these changes will be resolved
and the ExecutableBuffer
will be unlocked again.
pub fn alter_uncommitted(&mut self) -> UncommittedModifier
[src]
Similar to Assembler::alter
, this method allows modification of the yet to be
committed assembing buffer. Note that it is not possible to use labels in this
context, and overriding labels will cause corruption when the assembler tries to
resolve the labels at commit time.
pub fn commit(&mut self)
[src]
Commit the assembled code from a temporary buffer to the executable buffer. This method requires write access to the execution buffer and therefore has to obtain a lock on the datastructure. When this method is called, all labels will be resolved, and the result can no longer be changed.
pub fn finalize(self) -> Result<ExecutableBuffer, Assembler>
[src]
Consumes the assembler to return the internal ExecutableBuffer. This
method will only fail if an Executor
currently holds a lock on the datastructure,
in which case it will return itself.
pub fn reader(&self) -> Executor
[src]
Creates a read-only reference to the internal ExecutableBuffer
that must
be locked to access it. Multiple of such read-only locks can be obtained
at the same time, but as long as they are alive they will block any self.commit()
calls.
Trait Implementations
impl DynasmApi for Assembler
[src]
fn offset(&self) -> AssemblyOffset
[src]
fn push(&mut self, value: u8)
[src]
fn push_i8(&mut self, value: i8)
[src]
fn push_i16(&mut self, value: i16)
[src]
fn push_i32(&mut self, value: i32)
[src]
fn push_i64(&mut self, value: i64)
[src]
fn push_u16(&mut self, value: u16)
[src]
fn push_u32(&mut self, value: u32)
[src]
fn push_u64(&mut self, value: u64)
[src]
fn runtime_error(&self, msg: &'static str) -> !
[src]
impl DynasmLabelApi for Assembler
[src]
type Relocation = (u8, u8, u8)
tuple of encoded (offset, size, kind)
fn align(&mut self, alignment: usize)
[src]
fn global_label(&mut self, name: &'static str)
[src]
fn global_reloc(&mut self, name: &'static str, kind: Self::Relocation)
[src]
fn dynamic_label(&mut self, id: DynamicLabel)
[src]
fn dynamic_reloc(&mut self, id: DynamicLabel, kind: Self::Relocation)
[src]
fn local_label(&mut self, name: &'static str)
[src]
fn forward_reloc(&mut self, name: &'static str, kind: Self::Relocation)
[src]
fn backward_reloc(&mut self, name: &'static str, kind: Self::Relocation)
[src]
fn bare_reloc(&mut self, target: usize, kind: Self::Relocation)
[src]
impl Extend<u8> for Assembler
[src]
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = u8>,
[src]
T: IntoIterator<Item = u8>,
impl<'a> Extend<&'a u8> for Assembler
[src]
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = &'a u8>,
[src]
T: IntoIterator<Item = &'a u8>,
impl Debug for Assembler
[src]
Auto Trait Implementations
impl Sync for Assembler
impl Send for Assembler
impl Unpin for Assembler
impl RefUnwindSafe for Assembler
impl UnwindSafe for Assembler
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,