aboutsummaryrefslogtreecommitdiff
path: root/lib/arm64/jump-patch.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arm64/jump-patch.h')
-rw-r--r--lib/arm64/jump-patch.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/arm64/jump-patch.h b/lib/arm64/jump-patch.h
index f0f149f..c42c730 100644
--- a/lib/arm64/jump-patch.h
+++ b/lib/arm64/jump-patch.h
@@ -3,10 +3,11 @@
#define MAX_JUMP_PATCH_SIZE 12
#define MAX_REWRITTEN_SIZE (7 * 2 * 4) /* also conservative */
static inline int jump_patch_size(uintptr_t pc, uintptr_t dpc,
- struct arch_dis_ctx arch) {
+ struct arch_dis_ctx arch,
+ bool force) {
intptr_t diff = (dpc & ~0xfff) - (pc & ~0xfff);
if (!(diff >= -0x100000000 && diff < 0x100000000))
- return -1;
+ return force ? 16 : -1;
else if (pc & 0xfff)
return 8;
else
@@ -15,5 +16,11 @@ static inline int jump_patch_size(uintptr_t pc, uintptr_t dpc,
static inline void make_jump_patch(void **codep, uintptr_t pc, uintptr_t dpc,
struct arch_dis_ctx arch) {
- ADRP_ADD(codep, 12 /* XXX */, pc, dpc);
+ int reg = 12; /* XXX */
+ intptr_t diff = (dpc & ~0xfff) - (pc & ~0xfff);
+ if (!(diff >= -0x100000000 && diff < 0x100000000))
+ MOVi64(codep, reg, dpc);
+ else
+ ADRP_ADD(codep, reg, pc, dpc);
+ BR(codep, reg);
}