Skip to main content

Patch

Struct Patch 

Source
pub struct Patch {
    pub before: u32,
    pub pad: Opcode,
    pub after: Option<Inst>,
}
Expand description

Where the room a patcher was promised at the top of a function is.

What -fpatchable-function-entry= asks for. The room is a run of the shortest instruction that does nothing, and the point of it is that something else is written over it once the program is running, so what has to survive to the writers is where it starts and how much of it there is.

Two halves, because the room can be on either side of the function’s own label and the two sides reach the writers differently. What is after the label is in the instruction stream like anything else, so it is named by the first instruction of it. What is in front of the label is not in the stream at all, since the stream starts at the label, so it is a count the writer lays down itself, out of the one opcode kept here for it.

The address the room is recorded under is its start, which is the front of the half in front of the label in a function that has one and the front of the other half otherwise. The two halves are not always next to each other: a function that also opens with a landing pad has the pad between them, because the pad has to be the first thing after the label and the room does not.

Fields§

§before: u32

How many bytes go in front of the function’s own label.

§pad: Opcode

What one of those is written as, which is the instruction that does nothing.

Kept because they are the only instructions in a finished function that are not in a block, so there is nowhere else for a writer to read the opcode off. The ones after the label are in the stream and this is the opcode they carry too.

§after: Option<Inst>

The first instruction of the room after the label, or None in a function whose room is all in front of it.

Trait Implementations§

Source§

impl Clone for Patch

Source§

fn clone(&self) -> Patch

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Patch

Source§

impl Debug for Patch

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Patch

Source§

impl PartialEq for Patch

Source§

fn eq(&self, other: &Patch) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Patch

Auto Trait Implementations§

§

impl Freeze for Patch

§

impl RefUnwindSafe for Patch

§

impl Send for Patch

§

impl Sync for Patch

§

impl Unpin for Patch

§

impl UnsafeUnpin for Patch

§

impl UnwindSafe for Patch

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.