Struct cranelift_codegen::binemit::MemoryCodeSink [−][src]
pub struct MemoryCodeSink<'a> { /* fields omitted */ }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.
Methods
impl<'a> MemoryCodeSink<'a>[src]
impl<'a> MemoryCodeSink<'a>pub unsafe fn new<'sink>(
data: *mut u8,
relocs: &'sink mut RelocSink,
traps: &'sink mut TrapSink
) -> MemoryCodeSink<'sink>[src]
pub unsafe fn new<'sink>(
data: *mut u8,
relocs: &'sink mut RelocSink,
traps: &'sink mut TrapSink
) -> MemoryCodeSink<'sink>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.
Trait Implementations
impl<'a> CodeSink for MemoryCodeSink<'a>[src]
impl<'a> CodeSink for MemoryCodeSink<'a>fn offset(&self) -> CodeOffset[src]
fn offset(&self) -> CodeOffsetGet the current position.
fn put1(&mut self, x: u8)[src]
fn put1(&mut self, x: u8)Add 1 byte to the code section.
fn put2(&mut self, x: u16)[src]
fn put2(&mut self, x: u16)Add 2 bytes to the code section.
fn put4(&mut self, x: u32)[src]
fn put4(&mut self, x: u32)Add 4 bytes to the code section.
fn put8(&mut self, x: u64)[src]
fn put8(&mut self, x: u64)Add 8 bytes to the code section.
fn reloc_ebb(&mut self, rel: Reloc, ebb_offset: CodeOffset)[src]
fn reloc_ebb(&mut self, rel: Reloc, ebb_offset: CodeOffset)Add a relocation referencing an EBB at the current offset.
fn reloc_external(&mut self, rel: Reloc, name: &ExternalName, addend: Addend)[src]
fn reloc_external(&mut self, rel: Reloc, name: &ExternalName, addend: Addend)Add a relocation referencing an external symbol plus the addend at the current offset.
fn reloc_jt(&mut self, rel: Reloc, jt: JumpTable)[src]
fn reloc_jt(&mut self, rel: Reloc, jt: JumpTable)Add a relocation referencing a jump table.
fn trap(&mut self, code: TrapCode, srcloc: SourceLoc)[src]
fn trap(&mut self, code: TrapCode, srcloc: SourceLoc)Add trap information for the current offset.
Auto Trait Implementations
impl<'a> !Send for MemoryCodeSink<'a>
impl<'a> !Send for MemoryCodeSink<'a>impl<'a> !Sync for MemoryCodeSink<'a>
impl<'a> !Sync for MemoryCodeSink<'a>