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§
source§impl<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_with_capacity(
baseaddr: usize,
ops_capacity: usize,
local_labels: usize,
global_labels: usize,
dynamic_labels: usize,
static_references: usize,
dynamic_references: usize,
) -> VecAssembler<R>
pub fn new_with_capacity( baseaddr: usize, ops_capacity: usize, local_labels: usize, global_labels: usize, dynamic_labels: usize, static_references: usize, dynamic_references: usize, ) -> VecAssembler<R>
Creates a new VecAssembler, with the specified base address.
Preallocates vec_capacity
bytes to the internal vector, and label_capacity
label locations of each type.
Allows the user to specify the initial capacity of the internal datastructures.
ops_capacity
is the amount of bytes preallocated for the assembling buffer.
local_labels
determines the preallocated space for local labels definitions.
global_labels
determines the preallocated space for global labels definitions.
dynamic_labels
determines the preallocated space for dynamic labels definitions.
static_references
determines the preallocated space for references to local/global labels.
dynamic_references
determines the preallocated space for references to dynamic labels.
sourcepub fn reserve_ops(&mut self, additional: usize)
pub fn reserve_ops(&mut self, additional: usize)
Reserve capacity for at least additional
instruction bytes to be inserted
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
sourcepub fn finalize(self) -> Result<Vec<u8>, DynasmError>
pub fn finalize(self) -> Result<Vec<u8>, DynasmError>
Finalizes the VecAssembler
, returning the resulting Vec<u8>
containing all assembled data.
this implicitly commits any relocations beforehand and returns an error if required.
Trait Implementations§
source§impl<R: Debug + Relocation> Debug for VecAssembler<R>
impl<R: Debug + Relocation> Debug for VecAssembler<R>
source§impl<R: Relocation> DynasmApi for VecAssembler<R>
impl<R: Relocation> DynasmApi for VecAssembler<R>
source§fn offset(&self) -> AssemblyOffset
fn offset(&self) -> AssemblyOffset
source§fn align(&mut self, alignment: usize, with: u8)
fn align(&mut self, alignment: usize, with: u8)
source§fn runtime_error(&self, msg: &'static str) -> !
fn runtime_error(&self, msg: &'static str) -> !
source§impl<R: Relocation> DynasmLabelApi for VecAssembler<R>
impl<R: Relocation> DynasmLabelApi for VecAssembler<R>
§type Relocation = R
type Relocation = R
source§fn local_label(&mut self, name: &'static str)
fn local_label(&mut self, name: &'static str)
source§fn global_label(&mut self, name: &'static str)
fn global_label(&mut self, name: &'static str)
source§fn dynamic_label(&mut self, id: DynamicLabel)
fn dynamic_label(&mut self, id: DynamicLabel)
source§fn 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, )
source§fn 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, )
source§fn 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, )
source§fn 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, )
source§fn 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, )
source§fn 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, )
source§fn 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, )
source§fn 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, )
source§fn 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, )
source§fn 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, )
source§impl<'a, R: Relocation> Extend<&'a u8> for VecAssembler<R>
impl<'a, R: Relocation> Extend<&'a u8> for VecAssembler<R>
source§fn 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>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<R: Relocation> Extend<u8> for VecAssembler<R>
impl<R: Relocation> Extend<u8> for VecAssembler<R>
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = u8>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = u8>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)