diff options
author | comex | 2015-01-24 22:23:27 -0500 |
---|---|---|
committer | comex | 2015-01-24 22:23:27 -0500 |
commit | bd22f1a62adc6a5fc0645484039ba099a3a72e04 (patch) | |
tree | 200acf4e5ebed0862072d45ae4cc1631d6d8ed33 /lib/arm64/jump-patch.h | |
parent | ... (diff) | |
download | substitute-bd22f1a62adc6a5fc0645484039ba099a3a72e04.tar.gz |
it compiles...
Diffstat (limited to '')
-rw-r--r-- | lib/arm64/jump-patch.h | 13 |
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); } |