Add hack for ARMv8 BTI instruction disassembly ##anal (#17371)

Co-authored-by: phakeobj <phakeobj@users.noreply.github.com>
This commit is contained in:
phakeobj 2020-07-31 13:08:59 +03:00 committed by GitHub
parent 401162fb09
commit 4c207712bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View File

@ -30,6 +30,37 @@ static char *hack_handle_dp_imm(ut32 insn) {
return NULL;
}
static char *hack_handle_br_exc_sys(ut32 insn) {
char *buf_asm = NULL;
const char *mnemonic = "bti";
const ut8 op0 = (insn >> 29) & 0x7;
const ut16 op1 = (insn >> 12) & 0x3fff;
ut8 op2 = insn & 0x1f;
// Hints
if (op0 == 6 && op1 == 4146 && op2 == 31) {
const ut8 CRm = (insn >> 8) & 0xf;
op2 = (insn >> 5) & 0x7;
if (CRm == 4 && (op2 & 1) == 0) {
switch (op2) {
case 0:
buf_asm = r_str_newf ("%s", mnemonic);
break;
case 2:
buf_asm = r_str_newf ("%s c", mnemonic);
break;
case 4:
buf_asm = r_str_newf ("%s j", mnemonic);
break;
case 6:
buf_asm = r_str_newf ("%s jc", mnemonic);
break;
}
}
}
return buf_asm;
}
static char *hack_handle_dp_reg(ut32 insn) {
char *buf_asm = NULL;
char *mnemonic = NULL;
@ -205,6 +236,12 @@ static int hackyArmAsm(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
// addg, subg
buf_asm = hack_handle_dp_imm (*insn);
break;
// Branches, Exception generating, and System instructions
case 10:
case 11:
// bti
buf_asm = hack_handle_br_exc_sys (*insn);
break;
// Loads and Stores
case 4:
case 6:

View File

@ -288,3 +288,7 @@ d "stgm x0, [x1]" 2000a0d9
d "stz2g sp, [sp], 0x50" ff57e0d9
d "ldgm x10, [x0]" 0a00e0d9
d "stgp x1, x3, [x3], 0x70" 618c8368
d "bti" 1f2403d5
d "bti c" 5f2403d5
d "bti j" 9f2403d5
d "bti jc" df2403d5