pub struct DataDescription {
pub init: Init,
pub function_decls: PrimaryMap<FuncRef, ModuleRelocTarget>,
pub data_decls: PrimaryMap<GlobalValue, ModuleRelocTarget>,
pub function_relocs: Vec<(CodeOffset, FuncRef)>,
pub data_relocs: Vec<(CodeOffset, GlobalValue, Addend)>,
pub custom_segment_section: Option<(String, String)>,
pub align: Option<u64>,
}Expand description
A description of a data object.
Fields§
§init: InitHow the data should be initialized.
function_decls: PrimaryMap<FuncRef, ModuleRelocTarget>External function declarations.
data_decls: PrimaryMap<GlobalValue, ModuleRelocTarget>External data object declarations.
function_relocs: Vec<(CodeOffset, FuncRef)>Function addresses to write at specified offsets.
data_relocs: Vec<(CodeOffset, GlobalValue, Addend)>Data addresses to write at specified offsets.
custom_segment_section: Option<(String, String)>Object file section
align: Option<u64>Alignment in bytes. None means that the default alignment of the respective module should
be used.
Implementations§
source§impl DataDescription
impl DataDescription
sourcepub fn define_zeroinit(&mut self, size: usize)
pub fn define_zeroinit(&mut self, size: usize)
Define a zero-initialized object with the given size.
sourcepub fn define(&mut self, contents: Box<[u8]>)
pub fn define(&mut self, contents: Box<[u8]>)
Define an object initialized with the given contents.
TODO: Can we avoid a Box here?
sourcepub fn set_segment_section(&mut self, seg: &str, sec: &str)
pub fn set_segment_section(&mut self, seg: &str, sec: &str)
Override the segment/section for data, only supported on Object backend
sourcepub fn set_align(&mut self, align: u64)
pub fn set_align(&mut self, align: u64)
Set the alignment for data. The alignment must be a power of two.
sourcepub fn import_function(&mut self, name: ModuleRelocTarget) -> FuncRef
pub fn import_function(&mut self, name: ModuleRelocTarget) -> FuncRef
Declare an external function import.
Users of the Module API generally should call
Module::declare_func_in_data instead, as it takes care of generating
the appropriate ExternalName.
sourcepub fn import_global_value(&mut self, name: ModuleRelocTarget) -> GlobalValue
pub fn import_global_value(&mut self, name: ModuleRelocTarget) -> GlobalValue
Declares a global value import.
TODO: Rename to import_data?
Users of the Module API generally should call
Module::declare_data_in_data instead, as it takes care of generating
the appropriate ExternalName.
sourcepub fn write_function_addr(&mut self, offset: CodeOffset, func: FuncRef)
pub fn write_function_addr(&mut self, offset: CodeOffset, func: FuncRef)
Write the address of func into the data at offset offset.
sourcepub fn write_data_addr(
&mut self,
offset: CodeOffset,
data: GlobalValue,
addend: Addend,
)
pub fn write_data_addr( &mut self, offset: CodeOffset, data: GlobalValue, addend: Addend, )
Write the address of data into the data at offset offset.
sourcepub fn all_relocs<'a>(
&'a self,
pointer_reloc: Reloc,
) -> impl Iterator<Item = ModuleReloc> + 'a
pub fn all_relocs<'a>( &'a self, pointer_reloc: Reloc, ) -> impl Iterator<Item = ModuleReloc> + 'a
An iterator over all relocations of the data object.
Trait Implementations§
source§impl Clone for DataDescription
impl Clone for DataDescription
source§fn clone(&self) -> DataDescription
fn clone(&self) -> DataDescription
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DataDescription
impl RefUnwindSafe for DataDescription
impl Send for DataDescription
impl Sync for DataDescription
impl Unpin for DataDescription
impl UnwindSafe for DataDescription
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)