aboutsummaryrefslogtreecommitdiff
path: root/lib/dis-arm64.inc.h
diff options
context:
space:
mode:
authorcomex2015-01-12 01:21:43 -0500
committercomex2015-01-12 01:22:20 -0500
commit21277f290a705c6382453f348e4a224cd7695320 (patch)
treeb3eac4e66f7aec0dede880e7405171c413497a68 /lib/dis-arm64.inc.h
parentminor improvements (diff)
downloadsubstitute-21277f290a705c6382453f348e4a224cd7695320.tar.gz
these functions are actually pointless, since it's easier to change the *offset* for actual pc-rel loads (and the rest are accounted for, albeit implicitly in the case of add pc)
i might end up using the stack :/
Diffstat (limited to '')
-rw-r--r--lib/dis-arm64.inc.h28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/dis-arm64.inc.h b/lib/dis-arm64.inc.h
index 19f986a..333ecb1 100644
--- a/lib/dis-arm64.inc.h
+++ b/lib/dis-arm64.inc.h
@@ -1,8 +1,8 @@
static INLINE tdis_ret P(adrlabel_label_unk_Xd_1_ADR)(tdis_ctx ctx, struct bitslice Xd, struct bitslice label) {
- return P(pcrel)(ctx, ctx->pc + sext(bs_get(label, ctx->op), 22), bs_get(Xd, ctx->op), false);
+ return P(pcrel)(ctx, ctx->pc + sext(bs_get(label, ctx->op), 22), bs_get(Xd, ctx->op), PLM_ADR);
}
static INLINE tdis_ret P(adrplabel_label_unk_Xd_1_ADRP)(tdis_ctx ctx, struct bitslice Xd, struct bitslice label) {
- return P(pcrel)(ctx, ctx->pc + (sext(bs_get(label, ctx->op), 22) << 12), bs_get(Xd, ctx->op), false);
+ return P(pcrel)(ctx, ctx->pc + (sext(bs_get(label, ctx->op), 22) << 12), bs_get(Xd, ctx->op), PLM_ADR);
}
static INLINE tdis_ret P(am_b_target_addr_B_1_B)(tdis_ctx ctx, struct bitslice addr) {
return P(branch)(ctx, ctx->pc + sext(bs_get(addr, ctx->op), 26) * 4);
@@ -14,7 +14,23 @@ static INLINE tdis_ret P(am_brcond_target_B_5_Bcc)(tdis_ctx ctx, struct bitslice
return P(branch)(ctx, ctx->pc + sext(bs_get(target, ctx->op), 19) * 4);
}
static INLINE tdis_ret P(am_ldrlit_label_unk_Rt_6_LDRDl)(tdis_ctx ctx, struct bitslice Rt, struct bitslice label) {
- return P(pcrel)(ctx, ctx->pc + sext(bs_get(label, ctx->op), 19) * 4, bs_get(Rt, ctx->op), true);
+ enum pcrel_load_mode mode;
+ if ((ctx->op >> 26) & 1) {
+ switch (ctx->op >> 30) {
+ case 0b00: mode = PLM_U32_SIMD; break;
+ case 0b01: mode = PLM_U64_SIMD; break;
+ case 0b10: mode = PLM_U128_SIMD; break;
+ default: __builtin_abort();
+ }
+ } else {
+ switch (ctx->op >> 30) {
+ case 0b00: mode = PLM_U32; break;
+ case 0b01: mode = PLM_U64; break;
+ case 0b10: mode = PLM_S32; break;
+ default: __builtin_abort();
+ }
+ }
+ return P(pcrel)(ctx, ctx->pc + sext(bs_get(label, ctx->op), 19) * 4, bs_get(Rt, ctx->op), mode);
}
static INLINE tdis_ret P(am_tbrcond_target_B_4_TBNZW)(tdis_ctx ctx, struct bitslice target) {
return P(branch)(ctx, ctx->pc + sext(bs_get(target, ctx->op), 14) * 4);
@@ -23,8 +39,4 @@ static INLINE tdis_ret P(GPR64_Rn_1_RET)(tdis_ctx ctx, UNUSED struct bitslice Rn
return P(ret)(ctx);
}
-static tdis_ret P(dis_arm64)(tdis_ctx ctx) {
- unsigned op = ctx->op;
- #include "../generated/transform-dis-arm64.inc.h"
- __builtin_abort();
-}
+#define GENERATED_HEADER "../generated/transform-dis-arm64.inc.h"