Struct dynasmrt::components::PatchLoc
source · pub struct PatchLoc<R: Relocation> {
pub location: AssemblyOffset,
pub field_offset: u8,
pub ref_offset: u8,
pub relocation: R,
pub target_offset: isize,
}
Expand description
An abstraction of a relocation of type R
, located at location
.
Fields§
§location: AssemblyOffset
The AssemblyOffset at which this relocation was emitted
field_offset: u8
The offset, backwards, from location that the actual field to be modified starts at
ref_offset: u8
The offset, backwards, to be subtracted from location to get the address that the relocation should be calculated relative to.
relocation: R
The type of relocation to be emitted.
target_offset: isize
A constant offset added to the destination address of this relocation when it is calculated.
Implementations§
source§impl<R: Relocation> PatchLoc<R>
impl<R: Relocation> PatchLoc<R>
sourcepub fn new(
location: AssemblyOffset,
target_offset: isize,
field_offset: u8,
ref_offset: u8,
relocation: R,
) -> PatchLoc<R>
pub fn new( location: AssemblyOffset, target_offset: isize, field_offset: u8, ref_offset: u8, relocation: R, ) -> PatchLoc<R>
create a new PatchLoc
sourcepub fn range(&self, buf_offset: usize) -> Range<usize>
pub fn range(&self, buf_offset: usize) -> Range<usize>
Returns a range that covers the entire relocation in its assembling buffer
buf_offset
is a value that is subtracted from this range when the buffer you want to slice
with this range is only a part of a bigger buffer.
sourcepub fn value(&self, target: usize, buf_addr: usize) -> isize
pub fn value(&self, target: usize, buf_addr: usize) -> isize
Returns the actual value that should be inserted at the relocation site.
sourcepub fn patch(
&self,
buffer: &mut [u8],
buf_addr: usize,
target: usize,
) -> Result<(), ImpossibleRelocation>
pub fn patch( &self, buffer: &mut [u8], buf_addr: usize, target: usize, ) -> Result<(), ImpossibleRelocation>
Patch buffer
so that this relocation patch will point to target
.
buf_addr
is the address that the assembling buffer will come to reside at when it is assembled.
target
is the offset that this relocation will be targetting.
sourcepub fn adjust(
&self,
buffer: &mut [u8],
adjustment: isize,
) -> Result<(), ImpossibleRelocation>
pub fn adjust( &self, buffer: &mut [u8], adjustment: isize, ) -> Result<(), ImpossibleRelocation>
Patch buffer
so that this relocation will still point to the right location due to a change in the address of the containing buffer.
buffer
is a subsection of a larger buffer, located at offset buf_offset
in this larger buffer.
adjustment
is new_buf_addr - old_buf_addr
.
sourcepub fn needs_adjustment(&self) -> bool
pub fn needs_adjustment(&self) -> bool
Returns if this patch requires adjustment when the address of the buffer it resides in is altered.
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for PatchLoc<R>where
R: Freeze,
impl<R> RefUnwindSafe for PatchLoc<R>where
R: RefUnwindSafe,
impl<R> Send for PatchLoc<R>where
R: Send,
impl<R> Sync for PatchLoc<R>where
R: Sync,
impl<R> Unpin for PatchLoc<R>where
R: Unpin,
impl<R> UnwindSafe for PatchLoc<R>where
R: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)