Skip to main content

LoadedCode

Struct LoadedCode 

Source
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

Source

pub const fn rx(&self) -> *const u8

Start of the code in the read-execute mapping.

Source

pub const fn span(&self) -> &Span

Source

pub const fn span_mut(&mut self) -> &mut Span

The span, for patching the loaded image in place.

Source

pub const fn code_size(&self) -> usize

Size of the code, excluding the GOT that follows it.

Source

pub const fn got_offset(&self) -> usize

Offset of the GOT in the loaded image, after the code.

Source

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.

Source

pub const fn loaded_size(&self) -> usize

Size of the loaded image: the code and the GOT slots after it.

Source

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.

Source

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.

Source

pub fn symbol_by_name(&self, name: &ExternalName) -> Option<*const u8>

Runtime address of a symbol exported with CodeBuffer::bind_symbol.

Source

pub fn symbol(&self, name: &str) -> Option<*const u8>

Like Self::symbol_by_name, for string ExternalName::Symbol exports.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.