Struct cranelift_module::DataDescription

source ·
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: Init

How 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

source

pub fn new() -> Self

Allocate a new DataDescription.

source

pub fn clear(&mut self)

Clear all data structures in this DataDescription.

source

pub fn define_zeroinit(&mut self, size: usize)

Define a zero-initialized object with the given size.

source

pub fn define(&mut self, contents: Box<[u8]>)

Define an object initialized with the given contents.

TODO: Can we avoid a Box here?

source

pub fn set_segment_section(&mut self, seg: &str, sec: &str)

Override the segment/section for data, only supported on Object backend

source

pub fn set_align(&mut self, align: u64)

Set the alignment for data. The alignment must be a power of two.

source

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.

source

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.

source

pub fn write_function_addr(&mut self, offset: CodeOffset, func: FuncRef)

Write the address of func into the data at offset offset.

source

pub fn write_data_addr( &mut self, offset: CodeOffset, data: GlobalValue, addend: Addend )

Write the address of data into the data at offset offset.

source

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

source§

fn clone(&self) -> DataDescription

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DataDescription

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.