Struct dynasmrt::VecAssembler
source · [−]pub struct VecAssembler<R: Relocation> { /* private fields */ }
Expand description
An assembler that assembles into a Vec<u8>
, while supporting labels. To support the different types of relocations
it requires a base address of the to be assembled code to be specified.
Implementations
sourceimpl<R: Relocation> VecAssembler<R>
impl<R: Relocation> VecAssembler<R>
sourcepub fn new(baseaddr: usize) -> VecAssembler<R>
pub fn new(baseaddr: usize) -> VecAssembler<R>
Creates a new VecAssembler, with the specified base address.
sourcepub fn new_dynamic_label(&mut self) -> DynamicLabel
pub fn new_dynamic_label(&mut self) -> DynamicLabel
Create a new dynamic label ID
sourcepub fn commit(&mut self) -> Result<(), DynasmError>
pub fn commit(&mut self) -> Result<(), DynasmError>
Resolves any relocations emitted to the assembler before this point. If an impossible relocation was specified before this point, returns them here.
sourcepub fn alter(&mut self) -> UncommittedModifier<'_>
pub fn alter(&mut self) -> UncommittedModifier<'_>
Use an UncommittedModifier
to alter uncommitted code.
This does not allow the user to change labels/relocations.
sourcepub fn labels(&self) -> &LabelRegistry
pub fn labels(&self) -> &LabelRegistry
Provides access to the assemblers internal labels registry
sourcepub fn labels_mut(&mut self) -> &mut LabelRegistry
pub fn labels_mut(&mut self) -> &mut LabelRegistry
Provides mutable access to the assemblers internal labels registry
Trait Implementations
sourceimpl<R: Debug + Relocation> Debug for VecAssembler<R>
impl<R: Debug + Relocation> Debug for VecAssembler<R>
sourceimpl<R: Relocation> DynasmApi for VecAssembler<R>
impl<R: Relocation> DynasmApi for VecAssembler<R>
sourcefn offset(&self) -> AssemblyOffset
fn offset(&self) -> AssemblyOffset
Report the current offset into the assembling target
sourcefn align(&mut self, alignment: usize, with: u8)
fn align(&mut self, alignment: usize, with: u8)
Push filler until the assembling target end is aligned to the given alignment.
sourcefn runtime_error(&self, msg: &'static str) -> !
fn runtime_error(&self, msg: &'static str) -> !
This function is called in when a runtime error has to be generated. It panics.
sourceimpl<R: Relocation> DynasmLabelApi for VecAssembler<R>
impl<R: Relocation> DynasmLabelApi for VecAssembler<R>
type Relocation = R
type Relocation = R
The relocation info type this assembler uses.
sourcefn local_label(&mut self, name: &'static str)
fn local_label(&mut self, name: &'static str)
Record the definition of a local label
sourcefn global_label(&mut self, name: &'static str)
fn global_label(&mut self, name: &'static str)
Record the definition of a global label
sourcefn dynamic_label(&mut self, id: DynamicLabel)
fn dynamic_label(&mut self, id: DynamicLabel)
Record the definition of a dynamic label
sourcefn global_relocation(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: R
)
fn global_relocation(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: R
)
Equivalent of global_reloc, but takes a non-encoded relocation
sourcefn dynamic_relocation(
&mut self,
id: DynamicLabel,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: R
)
fn dynamic_relocation(
&mut self,
id: DynamicLabel,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: R
)
Equivalent of dynamic_reloc, but takes a non-encoded relocation
sourcefn forward_relocation(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: R
)
fn forward_relocation(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: R
)
Equivalent of forward_reloc, but takes a non-encoded relocation
sourcefn backward_relocation(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: R
)
fn backward_relocation(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: R
)
Equivalent of backward_reloc, but takes a non-encoded relocation
sourcefn bare_relocation(
&mut self,
target: usize,
field_offset: u8,
ref_offset: u8,
kind: R
)
fn bare_relocation(
&mut self,
target: usize,
field_offset: u8,
ref_offset: u8,
kind: R
)
Equivalent of bare_reloc, but takes a non-encoded relocation
sourcefn forward_reloc(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: <Self::Relocation as Relocation>::Encoding
)
fn forward_reloc(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: <Self::Relocation as Relocation>::Encoding
)
Record a relocation spot for a forward reference to a local label
sourcefn backward_reloc(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: <Self::Relocation as Relocation>::Encoding
)
fn backward_reloc(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: <Self::Relocation as Relocation>::Encoding
)
Record a relocation spot for a backward reference to a local label
sourcefn global_reloc(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: <Self::Relocation as Relocation>::Encoding
)
fn global_reloc(
&mut self,
name: &'static str,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: <Self::Relocation as Relocation>::Encoding
)
Record a relocation spot for a reference to a global label
sourcefn dynamic_reloc(
&mut self,
id: DynamicLabel,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: <Self::Relocation as Relocation>::Encoding
)
fn dynamic_reloc(
&mut self,
id: DynamicLabel,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
kind: <Self::Relocation as Relocation>::Encoding
)
Record a relocation spot for a reference to a dynamic label
sourcefn bare_reloc(
&mut self,
target: usize,
field_offset: u8,
ref_offset: u8,
kind: <Self::Relocation as Relocation>::Encoding
)
fn bare_reloc(
&mut self,
target: usize,
field_offset: u8,
ref_offset: u8,
kind: <Self::Relocation as Relocation>::Encoding
)
Record a relocation spot to an arbitrary target.
sourceimpl<'a, R: Relocation> Extend<&'a u8> for VecAssembler<R>
impl<'a, R: Relocation> Extend<&'a u8> for VecAssembler<R>
sourcefn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = &'a u8>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = &'a u8>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<R: Relocation> Extend<u8> for VecAssembler<R>
impl<R: Relocation> Extend<u8> for VecAssembler<R>
sourcefn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = u8>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = u8>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations
impl<R> RefUnwindSafe for VecAssembler<R>where
R: RefUnwindSafe,
impl<R> Send for VecAssembler<R>where
R: Send,
impl<R> Sync for VecAssembler<R>where
R: Sync,
impl<R> Unpin for VecAssembler<R>where
R: Unpin,
impl<R> UnwindSafe for VecAssembler<R>where
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more