Struct cranelift_codegen::binemit::MemoryCodeSink
source · pub struct MemoryCodeSink<'a> {
pub code_size: isize,
/* private fields */
}
Expand description
A CodeSink
that writes binary machine code directly into memory.
A MemoryCodeSink
object should be used when emitting a Cranelift IR function into executable
memory. It writes machine code directly to a raw pointer without any bounds checking, so make
sure to allocate enough memory for the whole function. The number of bytes required is returned
by the Context::compile()
function.
Any relocations in the function are forwarded to the RelocSink
trait object.
Note that MemoryCodeSink
writes multi-byte values in the native byte order of the host. This
is not the right thing to do for cross compilation.
Fields§
§code_size: isize
Size of the machine code portion of output
Implementations§
source§impl<'a> MemoryCodeSink<'a>
impl<'a> MemoryCodeSink<'a>
sourcepub unsafe fn new(
data: *mut u8,
relocs: &'a mut dyn RelocSink,
traps: &'a mut dyn TrapSink
) -> Self
pub unsafe fn new(
data: *mut u8,
relocs: &'a mut dyn RelocSink,
traps: &'a mut dyn TrapSink
) -> Self
Create a new memory code sink that writes a function to the memory pointed to by data
.
This function is unsafe since MemoryCodeSink
does not perform bounds checking on the
memory buffer, and it can’t guarantee that the data
pointer is valid.