136 this->architecture = architecture;
138 this->symbolicEngine = symbolicEngine;
139 this->taintEngine = taintEngine;
141 if (architecture ==
nullptr)
144 if (this->symbolicEngine ==
nullptr)
147 if (this->taintEngine ==
nullptr)
155 case ID_INS_ADD: this->add_s(inst);
break;
156 case ID_INS_ADDI: this->addi_s(inst);
break;
157 case ID_INS_ADDIW: this->addiw_s(inst);
break;
158 case ID_INS_ADDW: this->addw_s(inst);
break;
159 case ID_INS_AND: this->and_s(inst);
break;
160 case ID_INS_ANDI: this->and_s(inst);
break;
161 case ID_INS_AUIPC: this->auipc_s(inst);
break;
162 case ID_INS_BEQ: this->beq_s(inst);
break;
163 case ID_INS_BGE: this->bge_s(inst);
break;
164 case ID_INS_BGEU: this->bgeu_s(inst);
break;
165 case ID_INS_BLT: this->blt_s(inst);
break;
166 case ID_INS_BLTU: this->bltu_s(inst);
break;
167 case ID_INS_BNE: this->bne_s(inst);
break;
169 case ID_INS_C_ADD: this->c_add_s(inst);
break;
170 case ID_INS_C_ADDI: this->c_add_s(inst);
break;
171 case ID_INS_C_ADDI16SP: this->c_addi16sp_s(inst);
break;
172 case ID_INS_C_ADDI4SPN: this->c_addi4spn_s(inst);
break;
173 case ID_INS_C_ADDIW: this->c_addw_s(inst);
break;
174 case ID_INS_C_ADDW: this->c_addw_s(inst);
break;
175 case ID_INS_C_AND: this->c_and_s(inst);
break;
176 case ID_INS_C_ANDI: this->c_and_s(inst);
break;
177 case ID_INS_C_BEQZ: this->c_beqz_s(inst);
break;
178 case ID_INS_C_BNEZ: this->c_bnez_s(inst);
break;
179 case ID_INS_C_J: this->jal_j_s(inst);
break;
180 case ID_INS_C_JAL: this->c_jal_s(inst);
break;
181 case ID_INS_C_JALR: this->c_jalr_s(inst);
break;
182 case ID_INS_C_JR: this->jalr_no_link_s(inst);
break;
183 case ID_INS_C_LD: this->c_ld_s(inst);
break;
184 case ID_INS_C_LDSP: this->c_ldsp_s(inst);
break;
185 case ID_INS_C_LI: this->c_li_s(inst);
break;
186 case ID_INS_C_LW: this->c_lw_s(inst);
break;
187 case ID_INS_C_LWSP: this->c_lwsp_s(inst);
break;
188 case ID_INS_C_LUI: this->lui_s(inst);
break;
189 case ID_INS_C_MV: this->c_mv_s(inst);
break;
190 case ID_INS_C_NOP: this->c_nop_s(inst);
break;
191 case ID_INS_C_OR: this->c_or_s(inst);
break;
192 case ID_INS_C_SD: this->c_sd_s(inst);
break;
193 case ID_INS_C_SDSP: this->c_sdsp_s(inst);
break;
194 case ID_INS_C_SLLI: this->c_slli_s(inst);
break;
195 case ID_INS_C_SRAI: this->c_srai_s(inst);
break;
196 case ID_INS_C_SRLI: this->c_srli_s(inst);
break;
197 case ID_INS_C_SUB: this->c_sub_s(inst);
break;
198 case ID_INS_C_SUBW: this->c_subw_s(inst);
break;
199 case ID_INS_C_SW: this->c_sw_s(inst);
break;
200 case ID_INS_C_SWSP: this->c_swsp_s(inst);
break;
201 case ID_INS_C_XOR: this->c_xor_s(inst);
break;
203 case ID_INS_DIV: this->div_s(inst);
break;
204 case ID_INS_DIVU: this->divu_s(inst);
break;
205 case ID_INS_DIVUW: this->divuw_s(inst);
break;
206 case ID_INS_DIVW: this->divw_s(inst);
break;
207 case ID_INS_JAL: this->jal_s(inst);
break;
208 case ID_INS_JALR: this->jalr_s(inst);
break;
209 case ID_INS_LB: this->lb_s(inst);
break;
210 case ID_INS_LBU: this->lbu_s(inst);
break;
211 case ID_INS_LD: this->ld_s(inst);
break;
212 case ID_INS_LH: this->lh_s(inst);
break;
213 case ID_INS_LHU: this->lhu_s(inst);
break;
214 case ID_INS_LUI: this->lui_s(inst);
break;
215 case ID_INS_LW: this->lw_s(inst);
break;
216 case ID_INS_LWU: this->lwu_s(inst);
break;
217 case ID_INS_MUL: this->mul_s(inst);
break;
218 case ID_INS_MULH: this->mulh_s(inst);
break;
219 case ID_INS_MULHSU: this->mulhsu_s(inst);
break;
220 case ID_INS_MULHU: this->mulhu_s(inst);
break;
221 case ID_INS_MULW: this->mulw_s(inst);
break;
222 case ID_INS_OR: this->or_s(inst);
break;
223 case ID_INS_ORI: this->or_s(inst);
break;
224 case ID_INS_REM: this->rem_s(inst);
break;
225 case ID_INS_REMU: this->remu_s(inst);
break;
226 case ID_INS_REMUW: this->remuw_s(inst);
break;
227 case ID_INS_REMW: this->remw_s(inst);
break;
228 case ID_INS_SB: this->sb_s(inst);
break;
229 case ID_INS_SD: this->sd_s(inst);
break;
230 case ID_INS_SH: this->sh_s(inst);
break;
231 case ID_INS_SLL: this->sll_s(inst);
break;
232 case ID_INS_SLLI: this->sll_s(inst);
break;
233 case ID_INS_SLLIW: this->sllw_s(inst);
break;
234 case ID_INS_SLLW: this->sllw_s(inst);
break;
235 case ID_INS_SLT: this->slt_s(inst);
break;
236 case ID_INS_SLTI: this->slt_s(inst);
break;
237 case ID_INS_SLTIU: this->sltu_s(inst);
break;
238 case ID_INS_SLTU: this->sltu_s(inst);
break;
239 case ID_INS_SRA: this->sra_s(inst);
break;
240 case ID_INS_SRAI: this->sra_s(inst);
break;
241 case ID_INS_SRAIW: this->sraw_s(inst);
break;
242 case ID_INS_SRAW: this->sraw_s(inst);
break;
243 case ID_INS_SRL: this->srl_s(inst);
break;
244 case ID_INS_SRLI: this->srl_s(inst);
break;
245 case ID_INS_SRLIW: this->srlw_s(inst);
break;
246 case ID_INS_SRLW: this->srlw_s(inst);
break;
247 case ID_INS_SUB: this->sub_s(inst);
break;
248 case ID_INS_SUBW: this->subw_s(inst);
break;
249 case ID_INS_SW: this->sw_s(inst);
break;
250 case ID_INS_XOR: this->xor_s(inst);
break;
251 case ID_INS_XORI: this->xori_s(inst);
break;
257 return this->exception;
266 auto node = this->astCtxt->bv(inst.
getNextAddress(), pc_op.getBitSize());
286 auto node = this->astCtxt->bvadd(op1, op2);
292 expr->isTainted = this->taintEngine->
taintUnion(src1, src2);
295 this->controlFlow_s(inst);
305 case 0: this->controlFlow_s(inst);
return;
306 case 2: addi_mv_s(inst);
return;
307 default: add_s(inst);
return;
326 this->controlFlow_s(inst);
333 auto size = dst.getBitSize();
337 auto node = this->astCtxt->sx(32, this->astCtxt->extract(31, 0, op1));
341 node = this->astCtxt->sx(32, this->astCtxt->extract(31, 0, this->astCtxt->bvadd(op1, op2)));
348 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1));
351 this->controlFlow_s(inst);
365 auto node = this->astCtxt->sx(32, this->astCtxt->bvadd(
366 this->astCtxt->extract(31, 0, op1),
367 this->astCtxt->extract(31, 0, op2)
374 expr->isTainted = this->taintEngine->
taintUnion(src1, src2);
377 this->controlFlow_s(inst);
391 auto node = this->astCtxt->bvand(op1, op2);
397 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
400 this->controlFlow_s(inst);
415 auto node = this->astCtxt->concat(this->astCtxt->extract(19, 0, imm), this->astCtxt->bv(0, 12));
416 if (dst.getBitSize() == 64) {
417 node = this->astCtxt->sx(32, node);
419 node = this->astCtxt->bvadd(node, pc_ast);
425 expr->isTainted = this->taintEngine->
isTainted(pc);
428 this->controlFlow_s(inst);
439 auto size = src1.getBitSize();
444 auto op2 = this->astCtxt->bv(0, size);
454 auto node = this->astCtxt->ite(this->astCtxt->equal(op1, op2),
455 this->astCtxt->bvadd(pc_ast, op3),
463 if (op1->evaluate() == op2->evaluate())
467 expr->isTainted = this->taintEngine->
taintUnion(pc, src1);
468 expr->isTainted = this->taintEngine->
taintUnion(pc, src2);
483 auto size = src1.getBitSize();
488 auto op2 = this->astCtxt->bv(0, size);
493 auto node = this->astCtxt->bvsge(op1, op2);
496 if (mnem[1] ==
'l') {
497 node = this->astCtxt->bvsle(op1, op2);
498 taken = (
long long)(op1->evaluate()) <= 0;
501 taken = (
long long)(op1->evaluate()) >= 0;
508 node = this->astCtxt->bvsge(op1, op2);
509 taken = (
long long)(op1->evaluate() - op2->evaluate()) >= 0;
513 node = this->astCtxt->ite(node,
514 this->astCtxt->bvadd(pc_ast, op3),
525 expr->isTainted = this->taintEngine->
taintUnion(pc, src1);
526 expr->isTainted = this->taintEngine->
taintUnion(pc, src2);
546 auto node = this->astCtxt->ite(this->astCtxt->bvuge(op1, op2),
547 this->astCtxt->bvadd(pc_ast, op3),
555 if (op1->evaluate() >= op2->evaluate())
559 expr->isTainted = this->taintEngine->
taintUnion(pc, src1);
560 expr->isTainted = this->taintEngine->
taintUnion(pc, src2);
575 auto size = src1.getBitSize();
580 auto op2 = this->astCtxt->bv(0, size);
585 auto node = this->astCtxt->bvslt(op1, op2);
588 if (mnem[1] ==
'g') {
589 node = this->astCtxt->bvsgt(op1, op2);
590 taken = (
long long)(op1->evaluate()) > 0;
593 taken = (
long long)(op1->evaluate()) < 0;
600 node = this->astCtxt->bvslt(op1, op2);
601 taken = (
long long)(op1->evaluate() - op2->evaluate()) < 0;
605 node = this->astCtxt->ite(node,
606 this->astCtxt->bvadd(pc_ast, op3),
618 expr->isTainted = this->taintEngine->
taintUnion(pc, src1);
619 expr->isTainted = this->taintEngine->
taintUnion(pc, src2);
639 auto node = this->astCtxt->ite(this->astCtxt->bvult(op1, op2),
640 this->astCtxt->bvadd(pc_ast, op3),
648 if (op2->evaluate() > op1->evaluate())
652 expr->isTainted = this->taintEngine->
taintUnion(pc, src1);
653 expr->isTainted = this->taintEngine->
taintUnion(pc, src2);
667 auto size = src1.getBitSize();
672 auto op2 = this->astCtxt->bv(0, size);
682 auto node = this->astCtxt->ite(this->astCtxt->equal(op1, op2),
684 this->astCtxt->bvadd(pc_ast, op3)
691 if (op1->evaluate() - op2->evaluate())
695 expr->isTainted = this->taintEngine->
taintUnion(pc, src1);
696 expr->isTainted = this->taintEngine->
taintUnion(pc, src2);
713 auto node = this->astCtxt->bvadd(op1, op2);
719 expr->isTainted = this->taintEngine->
taintUnion(dst, src);
722 this->controlFlow_s(inst);
735 auto node = this->astCtxt->bvadd(op1, op2);
741 expr->isTainted = this->taintEngine->
isTainted(sp);
744 this->controlFlow_s(inst);
758 auto node = this->astCtxt->bvadd(op1, op2);
764 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src));
767 this->controlFlow_s(inst);
780 auto node = this->astCtxt->sx(32, this->astCtxt->bvadd(
781 this->astCtxt->extract(31, 0, op1),
782 this->astCtxt->extract(31, 0, op2)
789 expr->isTainted = this->taintEngine->
taintUnion(dst, src);
792 this->controlFlow_s(inst);
805 auto node = this->astCtxt->bvand(op1, op2);
811 expr->isTainted = this->taintEngine->
taintUnion(dst, src);
814 this->controlFlow_s(inst);
822 auto size = src1.getBitSize();
827 auto op2 = this->astCtxt->bv(0, size);
831 auto node = this->astCtxt->ite(this->astCtxt->equal(op1, op2),
832 this->astCtxt->bvadd(pc_ast, op3),
840 if (op1->evaluate() == 0)
844 expr->isTainted = this->taintEngine->
taintUnion(pc, src1);
855 auto size = src1.getBitSize();
860 auto op2 = this->astCtxt->bv(0, size);
864 auto node = this->astCtxt->ite(this->astCtxt->equal(op1, op2),
866 this->astCtxt->bvadd(pc_ast, op3)
873 if (op1->evaluate() != 0)
877 expr->isTainted = this->taintEngine->
taintUnion(pc, src1);
890 auto size = pc.getBitSize();
892 auto ra = this->architecture->
getRegister(triton::arch::ID_REG_RV32_X1);
900 auto node = this->astCtxt->bv(inst.
getNextAddress(), pc.getBitSize());
901 auto node_pc = this->astCtxt->bvadd(pc_ast, imm);
908 expr->isTainted = this->taintEngine->
isTainted(pc);
909 expr_pc->isTainted = this->taintEngine->
isTainted(pc);
922 auto size = pc.getBitSize();
926 triton::arch::ID_REG_RV64_X1 :
927 triton::arch::ID_REG_RV32_X1
933 auto op_src = this->symbolicEngine->
getOperandAst(inst, src);
936 auto node_dst = this->astCtxt->bv(inst.
getNextAddress(), pc.getBitSize());
937 auto node_pc = this->astCtxt->bvand(
939 this->astCtxt->bvshl(this->astCtxt->bv(-1, size), this->astCtxt->bv(1, size))
947 expr->isTainted = this->taintEngine->
isTainted(pc);
948 expr_pc->isTainted = this->taintEngine->
setTaint(pc, this->taintEngine->
isTainted(src));
970 this->symbolicEngine->
initLeaAst(mem_op.getMemory());
973 auto node = this->symbolicEngine->
getOperandAst(inst, mem_op);
982 this->controlFlow_s(inst);
1000 this->symbolicEngine->
initLeaAst(mem_op.getMemory());
1003 auto node = this->symbolicEngine->
getOperandAst(inst, mem_op);
1012 this->controlFlow_s(inst);
1027 expr->isTainted = this->taintEngine->
setTaint(dst,
false);
1030 this->controlFlow_s(inst);
1049 this->symbolicEngine->
initLeaAst(mem_op.getMemory());
1052 auto node = this->symbolicEngine->
getOperandAst(inst, mem_op);
1053 if (dst.getBitSize() == 64) {
1054 node = this->astCtxt->sx(32, node);
1064 this->controlFlow_s(inst);
1082 this->symbolicEngine->
initLeaAst(mem_op.getMemory());
1085 auto node = this->symbolicEngine->
getOperandAst(inst, mem_op);
1086 if (dst.getBitSize() == 64) {
1087 node = this->astCtxt->sx(32, node);
1097 this->controlFlow_s(inst);
1115 this->controlFlow_s(inst);
1121 this->controlFlow_s(inst);
1134 auto node = this->astCtxt->bvor(op1, op2);
1140 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(dst) | this->taintEngine->isTainted(src));
1143 this->controlFlow_s(inst);
1162 this->symbolicEngine->
initLeaAst(mem_op.getMemory());
1174 this->controlFlow_s(inst);
1192 this->symbolicEngine->
initLeaAst(mem_op.getMemory());
1204 this->controlFlow_s(inst);
1211 auto size = src.getBitSize();
1215 auto op2 = this->astCtxt->bvand(
1217 dst.getBitSize() == 64 ? this->astCtxt->bv(0x3f, size) : this->astCtxt->bv(0x1f, size)
1221 auto node = this->astCtxt->bvshl(op1, op2);
1227 expr->isTainted = this->taintEngine->
taintUnion(dst, src);
1230 this->controlFlow_s(inst);
1237 auto size = src.getBitSize();
1241 auto op2 = this->astCtxt->bvand(
1243 dst.getBitSize() == 64 ? this->astCtxt->bv(0x3f, size) : this->astCtxt->bv(0x1f, size)
1247 auto node = this->astCtxt->bvashr(op1, op2);
1253 expr->isTainted = this->taintEngine->
taintUnion(dst, src);
1256 this->controlFlow_s(inst);
1263 auto size = src.getBitSize();
1267 auto op2 = this->astCtxt->bvand(
1269 dst.getBitSize() == 64 ? this->astCtxt->bv(0x3f, size) : this->astCtxt->bv(0x1f, size)
1273 auto node = this->astCtxt->bvlshr(op1, op2);
1279 expr->isTainted = this->taintEngine->
taintUnion(dst, src);
1282 this->controlFlow_s(inst);
1295 auto node = this->astCtxt->bvsub(op1, op2);
1301 expr->isTainted = this->taintEngine->
taintUnion(dst, src);
1304 this->controlFlow_s(inst);
1313 auto op1 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, dst));
1314 auto op2 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src));
1317 auto node = this->astCtxt->sx(32, this->astCtxt->bvsub(op1, op2));
1323 expr->isTainted = this->taintEngine->
taintUnion(dst, src);
1326 this->controlFlow_s(inst);
1345 this->symbolicEngine->
initLeaAst(mem_op.getMemory());
1349 if (src.getBitSize() == 64) {
1350 node = this->astCtxt->extract(31, 0, node);
1360 this->controlFlow_s(inst);
1378 this->symbolicEngine->
initLeaAst(mem_op.getMemory());
1382 if (src.getBitSize() == 64) {
1383 node = this->astCtxt->extract(31, 0, node);
1393 this->controlFlow_s(inst);
1406 auto node = this->astCtxt->bvxor(op1, op2);
1412 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(dst) | this->taintEngine->isTainted(src));
1415 this->controlFlow_s(inst);
1429 auto node = this->astCtxt->ite(
1430 this->astCtxt->equal(op2, this->astCtxt->bv(0, op2->getBitvectorSize())),
1431 this->astCtxt->bv(-1, dst.getBitSize()),
1432 this->astCtxt->bvsdiv(op1, op2)
1439 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
1442 this->controlFlow_s(inst);
1456 auto node = this->astCtxt->ite(
1457 this->astCtxt->equal(op2, this->astCtxt->bv(0, op2->getBitvectorSize())),
1458 this->astCtxt->bv(-1, dst.getBitSize()),
1459 this->astCtxt->bvudiv(op1, op2)
1466 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
1469 this->controlFlow_s(inst);
1479 auto op1 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src1));
1480 auto op2 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src2));
1483 auto node = this->astCtxt->ite(
1484 this->astCtxt->equal(op2, this->astCtxt->bv(0, op2->getBitvectorSize())),
1485 this->astCtxt->bv(-1, dst.getBitSize()),
1486 this->astCtxt->sx(32, this->astCtxt->bvudiv(op1, op2))
1493 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
1496 this->controlFlow_s(inst);
1506 auto op1 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src1));
1507 auto op2 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src2));
1510 auto node = this->astCtxt->ite(
1511 this->astCtxt->equal(op2, this->astCtxt->bv(0, op2->getBitvectorSize())),
1512 this->astCtxt->bv(-1, dst.getBitSize()),
1513 this->astCtxt->sx(32, this->astCtxt->bvsdiv(op1, op2))
1520 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
1523 this->controlFlow_s(inst);
1532 if (mnem[1] ==
' ') {
1538 auto size = pc.getBitSize();
1542 triton::arch::ID_REG_RV64_X1 :
1543 triton::arch::ID_REG_RV32_X1
1559 auto node_pc = this->astCtxt->bvadd(pc_ast, imm);
1566 expr->isTainted = this->taintEngine->
setTaint(reg, this->taintEngine->
isTainted(pc));
1567 expr_pc->isTainted = this->taintEngine->
setTaint(pc, this->taintEngine->
isTainted(pc));
1577 auto size = pc.getBitSize();
1584 auto node_pc = this->astCtxt->bvadd(pc_ast, imm);
1590 expr_pc->isTainted = this->taintEngine->
isTainted(pc);
1606 if (mnem[2] !=
'l') { jalr_no_link_s(inst);
return; }
1609 auto size = pc.getBitSize();
1612 triton::arch::ID_REG_RV64_X1 :
1613 triton::arch::ID_REG_RV32_X1
1621 auto node_pc = this->symbolicEngine->
getOperandAst(inst, src);
1631 node_pc = this->astCtxt->bvadd(op1, op2);
1633 node_pc = this->astCtxt->bvand(
1635 this->astCtxt->bvshl(this->astCtxt->bv(-1, size), this->astCtxt->bv(1, size))
1643 expr->isTainted = this->taintEngine->
isTainted(pc);
1644 expr_pc->isTainted = this->taintEngine->
setTaint(pc, this->taintEngine->
isTainted(src));
1653 auto size = pc.getBitSize();
1656 triton::arch::ID_REG_RV64_X1 :
1657 triton::arch::ID_REG_RV32_X1
1666 node = this->astCtxt->bvand(
1668 this->astCtxt->bvshl(this->astCtxt->bv(-1, size), this->astCtxt->bv(1, size))
1675 expr->isTainted = this->taintEngine->
setTaint(pc, this->taintEngine->
isTainted(src));
1686 auto size = dst.getBitSize();
1690 node = this->astCtxt->sx(size - 8, node);
1699 this->controlFlow_s(inst);
1707 auto size = dst.getBitSize();
1711 node = this->astCtxt->zx(size - 8, node);
1720 this->controlFlow_s(inst);
1739 this->controlFlow_s(inst);
1747 auto size = dst.getBitSize();
1751 node = this->astCtxt->sx(size - 16, node);
1760 this->controlFlow_s(inst);
1768 auto size = dst.getBitSize();
1772 node = this->astCtxt->zx(size - 16, node);
1781 this->controlFlow_s(inst);
1789 auto size = dst.getBitSize();
1795 auto node = this->astCtxt->bvshl(
1796 this->astCtxt->sx(size - 20, this->astCtxt->extract(19, 0, imm)),
1797 this->astCtxt->bv(12, size)
1804 expr->isTainted = this->taintEngine->
setTaint(dst,
false);
1807 this->controlFlow_s(inst);
1818 if (dst.getBitSize() == 64) {
1819 node = this->astCtxt->sx(32, node);
1829 this->controlFlow_s(inst);
1837 auto size = dst.getBitSize();
1841 node = this->astCtxt->zx(32, node);
1850 this->controlFlow_s(inst);
1864 auto node = this->astCtxt->bvmul(op1, op2);
1870 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
1873 this->controlFlow_s(inst);
1881 auto size = src2.getBitSize();
1884 auto op1 = this->astCtxt->sx(size, this->symbolicEngine->
getOperandAst(inst, src1));
1885 auto op2 = this->astCtxt->sx(size, this->symbolicEngine->
getOperandAst(inst, src2));
1888 auto node = this->astCtxt->extract(size * 2 - 1, size, this->astCtxt->bvmul(op1, op2));
1894 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
1897 this->controlFlow_s(inst);
1905 auto size = src2.getBitSize();
1908 auto op1 = this->astCtxt->sx(size, this->symbolicEngine->
getOperandAst(inst, src1));
1909 auto op2 = this->astCtxt->zx(size, this->symbolicEngine->
getOperandAst(inst, src2));
1912 auto node = this->astCtxt->extract(size * 2 - 1, size, this->astCtxt->bvmul(op1, op2));
1918 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
1921 this->controlFlow_s(inst);
1929 auto size = src2.getBitSize();
1932 auto op1 = this->astCtxt->zx(size, this->symbolicEngine->
getOperandAst(inst, src1));
1933 auto op2 = this->astCtxt->zx(size, this->symbolicEngine->
getOperandAst(inst, src2));
1936 auto node = this->astCtxt->extract(size * 2 - 1, size, this->astCtxt->bvmul(op1, op2));
1942 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
1945 this->controlFlow_s(inst);
1955 auto op1 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src1));
1956 auto op2 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src2));
1959 auto node = this->astCtxt->sx(32, this->astCtxt->bvmul(op1, op2));
1965 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
1968 this->controlFlow_s(inst);
1982 auto node = this->astCtxt->bvor(op1, op2);
1988 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
1991 this->controlFlow_s(inst);
1999 auto size = dst.getBitSize();
2006 auto node = this->astCtxt->ite(
2007 this->astCtxt->equal(op2, this->astCtxt->bv(0, op2->getBitvectorSize())),
2010 this->astCtxt->land(
2011 this->astCtxt->equal(op1, this->astCtxt->bv(-1, size)),
2012 this->astCtxt->equal(op2, this->astCtxt->bv((1 << (size - 1)), size))
2014 this->astCtxt->bv(0, size),
2015 this->astCtxt->bvsrem(op1, op2)
2023 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
2026 this->controlFlow_s(inst);
2040 auto node = this->astCtxt->ite(
2041 this->astCtxt->equal(op2, this->astCtxt->bv(0, op2->getBitvectorSize())),
2043 this->astCtxt->bvurem(op1, op2)
2050 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
2053 this->controlFlow_s(inst);
2063 auto op1 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src1));
2064 auto op2 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src2));
2067 auto node = this->astCtxt->ite(
2068 this->astCtxt->equal(op2, this->astCtxt->bv(0, op2->getBitvectorSize())),
2069 this->astCtxt->sx(32, op1),
2070 this->astCtxt->sx(32, this->astCtxt->bvurem(op1, op2))
2077 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
2080 this->controlFlow_s(inst);
2090 auto op1 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src1));
2091 auto op2 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src2));
2094 uint32_t ov_value = 0x80000000;
2095 auto node = this->astCtxt->ite(
2096 this->astCtxt->equal(op2, this->astCtxt->bv(0, op2->getBitvectorSize())),
2097 this->astCtxt->sx(32, op1),
2099 this->astCtxt->land(
2100 this->astCtxt->equal(op1, this->astCtxt->bv(ov_value, 32)),
2101 this->astCtxt->equal(op2, this->astCtxt->bv(-1, 32))
2103 this->astCtxt->bv(0, dst.getBitSize()),
2104 this->astCtxt->sx(32, this->astCtxt->bvsrem(op1, op2))
2112 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
2115 this->controlFlow_s(inst);
2126 node = this->astCtxt->extract(7, 0, node);
2135 this->controlFlow_s(inst);
2154 this->controlFlow_s(inst);
2165 node = this->astCtxt->extract(15, 0, node);
2174 this->controlFlow_s(inst);
2182 auto size = src2.getBitSize();
2185 auto bits = size == 64 ? 0x3f : 0x1f;
2187 auto op2 = this->astCtxt->bvand(
2189 this->astCtxt->bv(bits, size)
2193 auto node = this->astCtxt->bvshl(op1, op2);
2199 expr->isTainted = this->taintEngine->
taintUnion(src1, src2);
2202 this->controlFlow_s(inst);
2210 auto size = src2.getBitSize();
2214 auto op2 = this->astCtxt->bvand(
2216 this->astCtxt->bv(0x1f, size)
2220 auto node = this->astCtxt->sx(32,
2221 this->astCtxt->bvshl(this->astCtxt->extract(31, 0, op1),
2222 this->astCtxt->extract(31, 0, op2)));
2228 expr->isTainted = this->taintEngine->
taintUnion(src1, src2);
2231 this->controlFlow_s(inst);
2241 if (mnem[3] ==
'z') {
2242 if (mnem[1] ==
'l') { slt_sltz_s(inst); }
else { slt_sgtz_s(inst); }
2252 auto size = dst.getBitSize();
2256 auto zero = this->astCtxt->bv(0, size);
2259 auto node = this->astCtxt->ite(this->astCtxt->bvsgt(op1, zero),
2260 this->astCtxt->bv(1, size),
2268 if ((
long long)op1->evaluate() > 0)
2272 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src));
2275 this->controlFlow_s(inst);
2282 auto size = dst.getBitSize();
2286 auto zero = this->astCtxt->bv(0, size);
2289 auto node = this->astCtxt->ite(this->astCtxt->bvslt(op1, zero),
2290 this->astCtxt->bv(1, size),
2298 if ((
long long)op1->evaluate() < 0)
2302 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src));
2305 this->controlFlow_s(inst);
2313 auto size = dst.getBitSize();
2320 auto node = this->astCtxt->ite(this->astCtxt->bvslt(op1, op2),
2321 this->astCtxt->bv(1, size),
2322 this->astCtxt->bv(0, size)
2329 if ((
long long)(op2->evaluate() - op1->evaluate()) > 0)
2333 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
2336 this->controlFlow_s(inst);
2343 auto size = dst.getBitSize();
2347 auto zero = this->astCtxt->bv(0, size);
2350 auto node = this->astCtxt->ite(this->astCtxt->equal(op1, zero),
2351 this->astCtxt->bv(1, size),
2359 if (op1->evaluate() == 0)
2363 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src));
2366 this->controlFlow_s(inst);
2376 if (mnem[1] ==
'e') {
2380 if (mnem[1] ==
'n') {
2388 auto size = dst.getBitSize();
2395 auto node = this->astCtxt->ite(this->astCtxt->bvult(op1, op2),
2396 this->astCtxt->bv(1, size),
2397 this->astCtxt->bv(0, size)
2404 if (op2->evaluate() > op1->evaluate())
2408 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
2411 this->controlFlow_s(inst);
2418 auto size = dst.getBitSize();
2422 auto zero = this->astCtxt->bv(0, size);
2425 auto node = this->astCtxt->ite(this->astCtxt->equal(op1, zero),
2427 this->astCtxt->bv(1, size)
2434 if (op1->evaluate() != 0)
2438 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src));
2441 this->controlFlow_s(inst);
2449 auto size = src2.getBitSize();
2452 auto bits = size == 64 ? 0x3f : 0x1f;
2454 auto op2 = this->astCtxt->bvand(
2456 this->astCtxt->bv(bits, size)
2460 auto node = this->astCtxt->bvashr(op1, op2);
2466 expr->isTainted = this->taintEngine->
taintUnion(src1, src2);
2469 this->controlFlow_s(inst);
2477 auto size = src2.getBitSize();
2481 auto op2 = this->astCtxt->bvand(
2483 this->astCtxt->bv(0x1f, size)
2487 auto node = this->astCtxt->sx(32,
2488 this->astCtxt->bvashr(this->astCtxt->extract(31, 0, op1),
2489 this->astCtxt->extract(31, 0, op2)));
2495 expr->isTainted = this->taintEngine->
taintUnion(src1, src2);
2498 this->controlFlow_s(inst);
2506 auto size = src2.getBitSize();
2509 auto bits = size == 64 ? 0x3f : 0x1f;
2511 auto op2 = this->astCtxt->bvand(
2513 this->astCtxt->bv(bits, size)
2517 auto node = this->astCtxt->bvlshr(op1, op2);
2523 expr->isTainted = this->taintEngine->
taintUnion(src1, src2);
2526 this->controlFlow_s(inst);
2534 auto size = src2.getBitSize();
2538 auto op2 = this->astCtxt->bvand(
2540 this->astCtxt->bv(0x1f, size)
2544 auto node = this->astCtxt->sx(32,
2545 this->astCtxt->bvlshr(this->astCtxt->extract(31, 0, op1),
2546 this->astCtxt->extract(31, 0, op2)));
2552 expr->isTainted = this->taintEngine->
taintUnion(src1, src2);
2555 this->controlFlow_s(inst);
2562 auto size = dst.getBitSize();
2563 bool fix_taint =
false;
2567 auto node = this->astCtxt->bvneg(op1);
2571 node = this->astCtxt->bvsub(op1, op2);
2572 fix_taint = this->taintEngine->
isTainted(src2);
2579 expr->isTainted = this->taintEngine->
isTainted(src1) || fix_taint;
2582 this->controlFlow_s(inst);
2589 auto size = dst.getBitSize();
2590 bool fix_taint =
false;
2593 auto op1 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src1));
2594 auto node = this->astCtxt->sx(32, this->astCtxt->bvneg(op1));
2597 auto op2 = this->astCtxt->extract(31, 0, this->symbolicEngine->
getOperandAst(inst, src2));
2598 node = this->astCtxt->sx(32, this->astCtxt->bvsub(op1, op2));
2599 fix_taint = this->taintEngine->
isTainted(src2);
2606 expr->isTainted = this->taintEngine->
isTainted(src1) || fix_taint;
2609 this->controlFlow_s(inst);
2620 if (src.getBitSize() == 64) {
2621 node = this->astCtxt->extract(31, 0, node);
2631 this->controlFlow_s(inst);
2645 auto node = this->astCtxt->bvxor(op1, op2);
2651 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1) | this->taintEngine->isTainted(src2));
2654 this->controlFlow_s(inst);
2664 auto node = this->astCtxt->bvnot(op1);
2669 node = this->astCtxt->bvxor(op1, op2);
2676 expr->isTainted = this->taintEngine->
setTaint(dst, this->taintEngine->
isTainted(src1));
2679 this->controlFlow_s(inst);
The abstract architecture class.
TRITON_EXPORT const triton::arch::Register & getRegister(triton::arch::register_e id) const
Returns register from id.
TRITON_EXPORT const triton::arch::Register & getStackPointer(void) const
Returns the stack pointer register.
TRITON_EXPORT const triton::arch::Register & getProgramCounter(void) const
Returns the program counter register.
TRITON_EXPORT void setBits(triton::uint32 high, triton::uint32 low)
Sets the bits (high, low) position.
This class is used to represent an instruction.
TRITON_EXPORT void setConditionTaken(bool flag)
Sets flag to define if the condition is taken or not.
TRITON_EXPORT triton::uint32 getType(void) const
Returns the type of the instruction.
std::vector< triton::arch::OperandWrapper > operands
A list of operands.
TRITON_EXPORT std::string getDisassembly(void) const
Returns the disassembly of the instruction.
TRITON_EXPORT triton::uint64 getNextAddress(void) const
Returns the next address of the instruction.
This class is used to represent a memory access.
TRITON_EXPORT void setDisplacement(const triton::arch::Immediate &displacement)
LEA - Sets the displacement operand.
TRITON_EXPORT void setBaseRegister(const triton::arch::Register &base)
LEA - Sets the base register operand.
This class is used as operand wrapper.
This class is used when an instruction has a register operand.
TRITON_EXPORT riscvSemantics(triton::arch::Architecture *architecture, triton::engines::symbolic::SymbolicEngine *symbolicEngine, triton::engines::taint::TaintEngine *taintEngine, const triton::modes::SharedModes &modes, const triton::ast::SharedAstContext &astCtxt)
Constructor.
TRITON_EXPORT triton::arch::exception_e buildSemantics(triton::arch::Instruction &inst)
Builds the semantics of the instruction. Returns triton::arch::NO_FAULT if succeed.
TRITON_EXPORT void pushPathConstraint(const triton::arch::Instruction &inst, const triton::engines::symbolic::SharedSymbolicExpression &expr)
Pushs constraints of a branch instruction to the path predicate.
The symbolic engine class.
TRITON_EXPORT const SharedSymbolicExpression & createSymbolicRegisterExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const triton::arch::Register ®, const std::string &comment="")
Returns the new symbolic register expression expression and links this expression to the instruction.
TRITON_EXPORT void initLeaAst(triton::arch::MemoryAccess &mem, bool force=true)
Initializes the effective address of a memory access.
TRITON_EXPORT const SharedSymbolicExpression & createSymbolicExpression(triton::arch::Instruction &inst, const triton::ast::SharedAbstractNode &node, const triton::arch::OperandWrapper &dst, const std::string &comment="")
Returns the new symbolic expression and links this expression to the instruction.
TRITON_EXPORT triton::ast::SharedAbstractNode getOperandAst(const triton::arch::OperandWrapper &op)
Returns the AST corresponding to the operand.
TRITON_EXPORT bool setTaint(const triton::arch::OperandWrapper &op, bool flag)
Sets the flag (taint or untaint) to an abstract operand (Register or Memory).
TRITON_EXPORT bool isTainted(const triton::arch::OperandWrapper &op) const
Abstract taint verification. Returns true if the operand is tainted.
TRITON_EXPORT bool taintUnion(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
Abstract union tainting.
TRITON_EXPORT bool setTaintRegister(const triton::arch::Register ®, bool flag)
Sets the flag (taint or untaint) to a register.
TRITON_EXPORT bool taintAssignment(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
Abstract assignment tainting.
The exception class used by all semantics.
std::shared_ptr< triton::ast::AstContext > SharedAstContext
Shared AST context.
constexpr triton::uint32 dword
dword size in bit
constexpr triton::uint32 qword
qword size in bit
std::shared_ptr< triton::modes::Modes > SharedModes
Shared Modes.
const bool UNTAINTED
Defines an untainted item.