Skip to content

Commit 51a2800

Browse files
committed
Fix.
1 parent d8c5424 commit 51a2800

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

monoasm/src/jit_memory.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,16 @@ impl JitMemory {
570570
slice.iter().for_each(|b| self.emitb(*b));
571571
}
572572

573+
///
574+
/// Apply patch for the displacement of the jmp instruction in *patch_point*.
575+
///
576+
pub fn apply_jmp_patch(&mut self, patch_point: DestLabel, jmp_dest: DestLabel) {
577+
let patch_point = self.get_label_address(patch_point);
578+
let jmp_dest = self.get_label_address(jmp_dest);
579+
let offset = jmp_dest - patch_point - 5;
580+
unsafe { *(patch_point.as_ptr().add(1) as *mut [u8; 4]) = (offset as i32).to_ne_bytes() };
581+
}
582+
573583
///
574584
/// Apply patch for the displacement of the jmp instruction in *patch_point*.
575585
///

0 commit comments

Comments
 (0)