Skip to content

Commit

Permalink
Avoid MOVD/MOVQ disassemble mismatch with old/new capstone versions
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Sep 19, 2023
1 parent 971c6e0 commit 399a387
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions ir_disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,12 @@ int ir_disasm(const char *name,
fprintf(f, " %" PRIx64 ":", insn->address);
}
p = insn->op_str;
#if defined(IR_TARGET_X64) && (CS_API_MAJOR < 5)
/* Fix capstone MOVD/MOVQ disassemble mismatch */
if (insn->id == X86_INS_MOVQ && strcmp(insn->mnemonic, "movd") == 0) {
insn->mnemonic[3] = 'q';
}
#endif
if (strlen(p) == 0) {
fprintf(f, "\t%s\n", insn->mnemonic);
continue;
Expand Down
2 changes: 1 addition & 1 deletion tests/x86/conv_004.irt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ x86
}
--EXPECT--
test:
movd %xmm0, %rax
movq %xmm0, %rax
retq
2 changes: 1 addition & 1 deletion tests/x86/conv_010.irt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ x86
}
--EXPECT--
test:
movd %rdi, %xmm0
movq %rdi, %xmm0
retq
2 changes: 1 addition & 1 deletion tests/x86_64/conv_004.irt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ x86_64
}
--EXPECT--
test:
movd %xmm0, %rax
movq %xmm0, %rax
retq
2 changes: 1 addition & 1 deletion tests/x86_64/conv_010.irt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ x86_64
}
--EXPECT--
test:
movd %rdi, %xmm0
movq %rdi, %xmm0
retq

0 comments on commit 399a387

Please sign in to comment.