pub struct ModuleTextBuilder<'a> { /* private fields */ }
Expand description
A helper structure used to assemble the final text section of an executable, 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,
compiled_func: &'a CompiledFunction,
resolve_reloc_target: impl Fn(RelocationTarget) -> usize,
) -> (SymbolId, Range<u64>)
pub fn append_func( &mut self, name: &str, compiled_func: &'a CompiledFunction, resolve_reloc_target: impl Fn(RelocationTarget) -> 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.
Auto Trait Implementations§
impl<'a> Freeze for ModuleTextBuilder<'a>
impl<'a> !RefUnwindSafe for ModuleTextBuilder<'a>
impl<'a> !Send for ModuleTextBuilder<'a>
impl<'a> !Sync for ModuleTextBuilder<'a>
impl<'a> Unpin for ModuleTextBuilder<'a>
impl<'a> !UnwindSafe for ModuleTextBuilder<'a>
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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more