Struct wasmtime_cranelift_shared::obj::ModuleTextBuilder
source · pub struct ModuleTextBuilder<'a> { /* private fields */ }
Expand description
A helper structure used to assemble the final text section of an exectuable, plus unwinding information and other related details.
This builder relies on Cranelift-specific internals but assembles into a
generic Object
which will get further appended to in a compiler-agnostic
fashion later.
Implementations§
source§impl<'a> ModuleTextBuilder<'a>
impl<'a> ModuleTextBuilder<'a>
sourcepub fn new(
obj: &'a mut Object<'static>,
compiler: &'a dyn Compiler,
text: Box<dyn TextSectionBuilder>,
) -> Self
pub fn new( obj: &'a mut Object<'static>, compiler: &'a dyn Compiler, text: Box<dyn TextSectionBuilder>, ) -> Self
Creates a new builder for the text section of an executable.
The .text
section will be appended to the specified obj
along with
any unwinding or such information as necessary. The num_funcs
parameter indicates the number of times the append_func
function will
be called. The finish
function will panic if this contract is not met.
sourcepub fn append_func(
&mut self,
name: &str,
body: &[u8],
alignment: u32,
unwind_info: Option<&'a UnwindInfo>,
relocations: &[Relocation],
resolve_reloc_target: impl Fn(FuncIndex) -> usize,
) -> (SymbolId, Range<u64>)
pub fn append_func( &mut self, name: &str, body: &[u8], alignment: u32, unwind_info: Option<&'a UnwindInfo>, relocations: &[Relocation], resolve_reloc_target: impl Fn(FuncIndex) -> usize, ) -> (SymbolId, Range<u64>)
Appends the func
specified named name
to this object.
The resolve_reloc_target
closure is used to resolve a relocation
target to an adjacent function which has already been added or will be
added to this object. The argument is the relocation target specified
within CompiledFunction
and the return value must be an index where
the target will be defined by the n
th call to append_func
.
Returns the symbol associated with the function as well as the range that the function resides within the text section.
sourcepub fn force_veneers(&mut self)
pub fn force_veneers(&mut self)
Forces “veneers” to be used for inter-function calls in the text section which means that in-bounds optimized addresses are never used.
This is only useful for debugging cranelift itself and typically this option is disabled.
sourcepub fn append_padding(&mut self, padding: usize)
pub fn append_padding(&mut self, padding: usize)
Appends the specified amount of bytes of padding into the text section.
This is only useful when fuzzing and/or debugging cranelift itself and
for production scenarios padding
is 0 and this function does nothing.