diff options
Diffstat (limited to '')
-rw-r--r-- | lib/arm/misc.h | 2 | ||||
-rw-r--r-- | lib/arm64/assemble.h | 9 | ||||
-rw-r--r-- | lib/arm64/jump-patch.h | 8 |
3 files changed, 9 insertions, 10 deletions
diff --git a/lib/arm/misc.h b/lib/arm/misc.h index 7ce1c05..f8d593e 100644 --- a/lib/arm/misc.h +++ b/lib/arm/misc.h @@ -10,5 +10,3 @@ struct arch_dis_ctx { }; enum { IS_LDRD_STRD = 1 << 16 }; -#define JUMP_PATCH_SIZE 8 -#define MAX_REWRITTEN_SIZE (12 * 4) /* actually should be less */ diff --git a/lib/arm64/assemble.h b/lib/arm64/assemble.h index c20c219..8a98b7b 100644 --- a/lib/arm64/assemble.h +++ b/lib/arm64/assemble.h @@ -4,8 +4,8 @@ static inline void MOVi64(void **codep, int Rd, uint64_t val) { int shift_nybbles = 0; do { int k = shift_nybbles != 0 ? 1 : 0; - op32(codep, 0x69400000 | k << 28 | Rd | (val & 0xffff) << 4 | - shift_nybbles << 20); + op32(codep, 0xd2800000 | k << 29 | Rd | (val & 0xffff) << 5 | + shift_nybbles << 21); shift_nybbles++; val >>= 16; } while(val); @@ -16,6 +16,7 @@ static inline void LDRxi(void **codep, int Rt, int Rn, uint32_t off, int size, opc; bool sign, simd; switch (load_mode) { + case PLM_ADR: return; case PLM_U8: size = 0; sign = false; simd = false; break; case PLM_S8: size = 0; sign = true; simd = false; break; case PLM_U16: size = 1; sign = false; simd = false; break; @@ -41,8 +42,8 @@ static inline void LDRxi(void **codep, int Rt, int Rn, uint32_t off, static inline void ADRP_ADD(void **codep, int reg, uint64_t pc, uint64_t dpc) { uintptr_t diff = (dpc & ~0xfff) - (pc & ~0xfff); /* ADRP reg, dpc */ - op32(codep, 0x90000000 | reg | (diff & 0x3000) << 17 | (diff & 0xffffc000) >> 8); - uint32_t lo = pc & 0xfff; + op32(codep, 0x90000000 | reg | (diff & 0x3000) << 17 | (diff & 0x1ffffc000) >> 9); + uint32_t lo = dpc & 0xfff; if (lo) { /* ADD reg, reg, #lo */ op32(codep, 0x91000000 | reg | reg << 5 | lo << 10); diff --git a/lib/arm64/jump-patch.h b/lib/arm64/jump-patch.h index c42c730..aa818d3 100644 --- a/lib/arm64/jump-patch.h +++ b/lib/arm64/jump-patch.h @@ -3,20 +3,20 @@ #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, + UNUSED struct arch_dis_ctx arch, bool force) { intptr_t diff = (dpc & ~0xfff) - (pc & ~0xfff); if (!(diff >= -0x100000000 && diff < 0x100000000)) return force ? 16 : -1; - else if (pc & 0xfff) + else if (!(dpc & 0xfff)) return 8; else return 12; } static inline void make_jump_patch(void **codep, uintptr_t pc, uintptr_t dpc, - struct arch_dis_ctx arch) { - int reg = 12; /* XXX */ + UNUSED struct arch_dis_ctx arch) { + int reg = 15; intptr_t diff = (dpc & ~0xfff) - (pc & ~0xfff); if (!(diff >= -0x100000000 && diff < 0x100000000)) MOVi64(codep, reg, dpc); |