aboutsummaryrefslogtreecommitdiff
path: root/lib/arm64
diff options
context:
space:
mode:
authorcomex2015-01-25 01:26:43 -0500
committercomex2015-01-25 01:26:43 -0500
commitd3ea2155062131724c01d7f6727fdf90a4063b4d (patch)
tree6b3d4989b4f7ff9df464c8c18fffce488673274f /lib/arm64
parentfixes (diff)
downloadsubstitute-d3ea2155062131724c01d7f6727fdf90a4063b4d.tar.gz
fixes
Diffstat (limited to 'lib/arm64')
-rw-r--r--lib/arm64/assemble.h9
-rw-r--r--lib/arm64/jump-patch.h8
2 files changed, 9 insertions, 8 deletions
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);