pub struct LoadedCode { /* private fields */ }Expand description
Executable memory holding a relocated image, returned by
CodeBufferFinalized::load.
Dropping it does not free the memory: see Span.
Implementations§
Source§impl LoadedCode
impl LoadedCode
pub const fn span(&self) -> &Span
Sourcepub const fn span_mut(&mut self) -> &mut Span
pub const fn span_mut(&mut self) -> &mut Span
The span, for patching the loaded image in place.
Sourcepub const fn got_offset(&self) -> usize
pub const fn got_offset(&self) -> usize
Offset of the GOT in the loaded image, after the code.
Sourcepub fn got_entries(&self) -> &[Option<ExternalName>]
pub fn got_entries(&self) -> &[Option<ExternalName>]
One entry per GOT slot, in slot order: the external symbol the slot
holds, or None for a slot holding an address inside this image.
Sourcepub const fn loaded_size(&self) -> usize
pub const fn loaded_size(&self) -> usize
Size of the loaded image: the code and the GOT slots after it.
Sourcepub fn got_slot(&self, name: &ExternalName) -> Option<*const u8>
pub fn got_slot(&self, name: &ExternalName) -> Option<*const u8>
Address of the GOT slot holding external symbol name, or None when
no far reference to name gave it a slot.
Sourcepub unsafe fn rebind(
&mut self,
jit_allocator: &mut JitAllocator,
name: &ExternalName,
address: *const u8,
) -> Result<(), AsmError>
pub unsafe fn rebind( &mut self, jit_allocator: &mut JitAllocator, name: &ExternalName, address: *const u8, ) -> Result<(), AsmError>
Points every far reference to name at address, by rewriting its
GOT slots. Near references were resolved into the instructions at load
time and keep their target.
§Errors
Returns AsmError::InvalidArgument if address is null or name
has no GOT slot in this image, or an error from
JitAllocator::write.
§Safety
jit_allocator must be the allocator that loaded this image. Code
running concurrently may observe either the old or the new address.
Sourcepub fn symbol_by_name(&self, name: &ExternalName) -> Option<*const u8>
pub fn symbol_by_name(&self, name: &ExternalName) -> Option<*const u8>
Runtime address of a symbol exported with CodeBuffer::bind_symbol.
Sourcepub fn symbol(&self, name: &str) -> Option<*const u8>
pub fn symbol(&self, name: &str) -> Option<*const u8>
Like Self::symbol_by_name, for string ExternalName::Symbol exports.