From 42192508d9ce69927ce206b32ca518744e47823d Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Sun, 15 Dec 2024 19:11:25 -0800 Subject: [PATCH] Turn opmask_with_dsts()/is_evex_mask condition into an assertion. opmask_with_dsts() covers both Intel and AT&T syntax, non-x86 syntaxes should never have is_evex_mask == true, and DR syntax should never get into this function. --- core/ir/disassemble_shared.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/ir/disassemble_shared.c b/core/ir/disassemble_shared.c index 5083f29082e..da515435c23 100644 --- a/core/ir/disassemble_shared.c +++ b/core/ir/disassemble_shared.c @@ -1035,7 +1035,9 @@ instr_disassemble_opnds_noimplicit(char *buf, size_t bufsz, size_t *sofar DR_PAR */ optype = 0; }); - bool is_evex_mask = optype_is_evex_mask_arch(optype) && opmask_with_dsts(); + bool is_evex_mask = optype_is_evex_mask_arch(optype); + CLIENT_ASSERT(!is_evex_mask || opmask_with_dsts(), + "Anything here with evex mask should be opmask_with_dsts()"); if (!is_evex_mask) { print_to_buffer(buf, bufsz, sofar, ""); printing = opnd_disassemble_noimplicit(buf, bufsz, sofar, dcontext, instr, @@ -1077,7 +1079,9 @@ instr_disassemble_opnds_noimplicit(char *buf, size_t bufsz, size_t *sofar DR_PAR (i == 0 && opnd_is_reg(opnd) && reg_is_fp(opnd_get_reg(opnd)))); }); if (print) { - bool is_evex_mask = optype_is_evex_mask_arch(optype) && opmask_with_dsts(); + bool is_evex_mask = optype_is_evex_mask_arch(optype); + CLIENT_ASSERT(!is_evex_mask || opmask_with_dsts(), + "Anything here with evex mask should be opmask_with_dsts()"); print_to_buffer(buf, bufsz, sofar, is_evex_mask ? " {" : ""); prev = opnd_disassemble_noimplicit(buf, bufsz, sofar, dcontext, instr, optype, opnd, prev && !is_evex_mask, @@ -1092,8 +1096,10 @@ instr_disassemble_opnds_noimplicit(char *buf, size_t bufsz, size_t *sofar DR_PAR CLIENT_ASSERT(IF_X86_ELSE(true, false), "evex mask can only exist for x86."); optype = instr_info_opnd_type(info, !dsts_first(), mask_index); CLIENT_ASSERT(!instr_is_opmask(instr) && opnd_is_reg(opnd) && - reg_is_opmask(opnd_get_reg(opnd)) && opmask_with_dsts(), + reg_is_opmask(opnd_get_reg(opnd)), "evex mask must always be the first source."); + CLIENT_ASSERT(opmask_with_dsts(), + "Anything here with evex mask should be opmask_with_dsts()"); print_to_buffer(buf, bufsz, sofar, " {"); opnd_disassemble_noimplicit(buf, bufsz, sofar, dcontext, instr, optype, opnd, false, multiple_encodings, dsts_first(), &mask_index);