Skip to main content

CodeImage

Struct CodeImage 

Source
pub struct CodeImage { /* private fields */ }
Expand description

Immutable native x86_64 bytes and translation metadata.

Implementations§

Source§

impl CodeImage

Source

pub fn bytes(&self) -> &[u8] ⓘ

Returns immutable executable bytes. The first byte is the function entry and the bytes are suitable for a W^X publisher to copy.

Source

pub const fn entry_offset(&self) -> u32

Returns the native entry offset.

Source

pub fn instruction_boundaries(&self) -> &[u32]

Returns source boundaries including the terminal code length.

Source

pub fn instruction_map(&self) -> &[InstructionMap]

Returns source-to-native instruction mappings.

Source

pub fn relocations(&self) -> &[Relocation]

Returns relocations. Direct images always return an empty slice.

Source

pub const fn profile(&self) -> InputProfile

Returns the input ABI profile used by native load emission.

Source

pub fn len(&self) -> usize

Returns the number of translated source instructions.

Source

pub fn is_empty(&self) -> bool

Returns whether the source program is empty.

Source

pub fn image_size(&self) -> usize

Returns the exact native byte length.

Source

pub fn page_aligned_size(&self, page_size: usize) -> Option<usize>

Returns the page-rounded size required by a publisher.

Source

pub fn into_parts( self, ) -> (Vec<u8>, Vec<Relocation>, u32, Vec<u32>, Vec<InstructionMap>)

Returns owned bytes and publisher metadata.

Source

pub fn into_bytes(self) -> Vec<u8> ⓘ

Returns owned native bytes.

Source

pub fn validate(&self) -> Result<(), ImageValidationError>

Independently validates native code, source map, branches and relocations.

Source

pub fn evaluate<I: Input + ?Sized>(&self, input: &I) -> u32

Evaluates a second safe reference model from the immutable source copy.

Trait Implementations§

Source§

impl Debug for CodeImage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.