Skip to content

Commit a2aa9b7

Browse files
Merge pull request #1399 from GaoYuCan/master
Add support for the SETM instruction under aarch64 & opcode python bindings for alias class instructions in the AArch64 Architecture
2 parents d49beb7 + 497805c commit a2aa9b7

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

src/libtriton/arch/arm/aarch64/aarch64Semantics.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ namespace triton {
256256
case ID_INS_CNEG: this->cneg_s(inst); break;
257257
case ID_INS_CSEL: this->csel_s(inst); break;
258258
case ID_INS_CSET: this->cset_s(inst); break;
259+
case ID_INS_CSETM: this->csetm_s(inst); break;
259260
case ID_INS_CSINC: this->csinc_s(inst); break;
260261
case ID_INS_CSNEG: this->csneg_s(inst); break;
261262
case ID_INS_CSINV: this->csinv_s(inst); break;
@@ -1734,6 +1735,28 @@ namespace triton {
17341735
}
17351736

17361737

1738+
void AArch64Semantics::csetm_s(triton::arch::Instruction& inst) {
1739+
auto& dst = inst.operands[0];
1740+
1741+
/* Create symbolic operands */
1742+
triton::uint512 temp = 1;
1743+
auto op1 = this->astCtxt->bv((temp << dst.getBitSize()) - 1, dst.getBitSize());
1744+
auto op2 = this->astCtxt->bv(0, dst.getBitSize());
1745+
1746+
/* Create the semantics */
1747+
auto node = this->getCodeConditionAst(inst, op1, op2);
1748+
1749+
/* Create symbolic expression */
1750+
auto expr = this->symbolicEngine->createSymbolicExpression(inst, node, dst, "CSETM operation");
1751+
1752+
/* Spread taint */
1753+
expr->isTainted = this->taintEngine->setTaint(dst, this->getCodeConditionTainteSate(inst));
1754+
1755+
/* Update the symbolic control flow */
1756+
this->controlFlow_s(inst);
1757+
}
1758+
1759+
17371760
void AArch64Semantics::csinc_s(triton::arch::Instruction& inst) {
17381761
auto& dst = inst.operands[0];
17391762
auto& src1 = inst.operands[1];

src/libtriton/bindings/python/namespaces/initOpcodesNamespace.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,41 @@ According to the CPU architecture, the OPCODE namespace contains all kinds of op
21792179
- **OPCODE.AARCH64.XTN**<br>
21802180
- **OPCODE.AARCH64.ZIP1**<br>
21812181
- **OPCODE.AARCH64.ZIP2**<br>
2182+
- **OPCODE.AARCH64.MNEG**<br>
2183+
- **OPCODE.AARCH64.UMNEGL**<br>
2184+
- **OPCODE.AARCH64.SMNEGL**<br>
2185+
- **OPCODE.AARCH64.NOP**<br>
2186+
- **OPCODE.AARCH64.YIELD**<br>
2187+
- **OPCODE.AARCH64.WFE**<br>
2188+
- **OPCODE.AARCH64.WFI**<br>
2189+
- **OPCODE.AARCH64.SEV**<br>
2190+
- **OPCODE.AARCH64.SEVL**<br>
2191+
- **OPCODE.AARCH64.NGC**<br>
2192+
- **OPCODE.AARCH64.SBFIZ**<br>
2193+
- **OPCODE.AARCH64.UBFIZ**<br>
2194+
- **OPCODE.AARCH64.SBFX**<br>
2195+
- **OPCODE.AARCH64.UBFX**<br>
2196+
- **OPCODE.AARCH64.BFI**<br>
2197+
- **OPCODE.AARCH64.BFXIL**<br>
2198+
- **OPCODE.AARCH64.CMN**<br>
2199+
- **OPCODE.AARCH64.MVN**<br>
2200+
- **OPCODE.AARCH64.TST**<br>
2201+
- **OPCODE.AARCH64.CSET**<br>
2202+
- **OPCODE.AARCH64.CINC**<br>
2203+
- **OPCODE.AARCH64.CSETM**<br>
2204+
- **OPCODE.AARCH64.CINV**<br>
2205+
- **OPCODE.AARCH64.CNEG**<br>
2206+
- **OPCODE.AARCH64.SXTB**<br>
2207+
- **OPCODE.AARCH64.SXTH**<br>
2208+
- **OPCODE.AARCH64.SXTW**<br>
2209+
- **OPCODE.AARCH64.CMP**<br>
2210+
- **OPCODE.AARCH64.UXTB**<br>
2211+
- **OPCODE.AARCH64.UXTH**<br>
2212+
- **OPCODE.AARCH64.UXTW**<br>
2213+
- **OPCODE.AARCH64.IC**<br>
2214+
- **OPCODE.AARCH64.DC**<br>
2215+
- **OPCODE.AARCH64.AT**<br>
2216+
- **OPCODE.AARCH64.TLBI**<br>
21822217
21832218
\subsection OPCODE_riscv64_py_api RV64
21842219
@@ -4081,6 +4116,41 @@ namespace triton {
40814116
xPyDict_SetItemString(Aarch64OpcodesDict, "XTN", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_XTN));
40824117
xPyDict_SetItemString(Aarch64OpcodesDict, "ZIP1", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_ZIP1));
40834118
xPyDict_SetItemString(Aarch64OpcodesDict, "ZIP2", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_ZIP2));
4119+
xPyDict_SetItemString(Aarch64OpcodesDict, "MNEG", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_MNEG));
4120+
xPyDict_SetItemString(Aarch64OpcodesDict, "UMNEGL", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_UMNEGL));
4121+
xPyDict_SetItemString(Aarch64OpcodesDict, "SMNEGL", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_SMNEGL));
4122+
xPyDict_SetItemString(Aarch64OpcodesDict, "NOP", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_NOP));
4123+
xPyDict_SetItemString(Aarch64OpcodesDict, "YIELD", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_YIELD));
4124+
xPyDict_SetItemString(Aarch64OpcodesDict, "WFE", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_WFE));
4125+
xPyDict_SetItemString(Aarch64OpcodesDict, "WFI", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_WFI));
4126+
xPyDict_SetItemString(Aarch64OpcodesDict, "SEV", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_SEV));
4127+
xPyDict_SetItemString(Aarch64OpcodesDict, "SEVL", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_SEVL));
4128+
xPyDict_SetItemString(Aarch64OpcodesDict, "NGC", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_NGC));
4129+
xPyDict_SetItemString(Aarch64OpcodesDict, "SBFIZ", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_SBFIZ));
4130+
xPyDict_SetItemString(Aarch64OpcodesDict, "UBFIZ", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_UBFIZ));
4131+
xPyDict_SetItemString(Aarch64OpcodesDict, "SBFX", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_SBFX));
4132+
xPyDict_SetItemString(Aarch64OpcodesDict, "UBFX", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_UBFX));
4133+
xPyDict_SetItemString(Aarch64OpcodesDict, "BFI", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_BFI));
4134+
xPyDict_SetItemString(Aarch64OpcodesDict, "BFXIL", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_BFXIL));
4135+
xPyDict_SetItemString(Aarch64OpcodesDict, "CMN", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_CMN));
4136+
xPyDict_SetItemString(Aarch64OpcodesDict, "MVN", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_MVN));
4137+
xPyDict_SetItemString(Aarch64OpcodesDict, "TST", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_TST));
4138+
xPyDict_SetItemString(Aarch64OpcodesDict, "CSET", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_CSET));
4139+
xPyDict_SetItemString(Aarch64OpcodesDict, "CINC", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_CINC));
4140+
xPyDict_SetItemString(Aarch64OpcodesDict, "CSETM", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_CSETM));
4141+
xPyDict_SetItemString(Aarch64OpcodesDict, "CINV", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_CINV));
4142+
xPyDict_SetItemString(Aarch64OpcodesDict, "CNEG", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_CNEG));
4143+
xPyDict_SetItemString(Aarch64OpcodesDict, "SXTB", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_SXTB));
4144+
xPyDict_SetItemString(Aarch64OpcodesDict, "SXTH", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_SXTH));
4145+
xPyDict_SetItemString(Aarch64OpcodesDict, "SXTW", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_SXTW));
4146+
xPyDict_SetItemString(Aarch64OpcodesDict, "CMP", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_CMP));
4147+
xPyDict_SetItemString(Aarch64OpcodesDict, "UXTB", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_UXTB));
4148+
xPyDict_SetItemString(Aarch64OpcodesDict, "UXTH", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_UXTH));
4149+
xPyDict_SetItemString(Aarch64OpcodesDict, "UXTW", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_UXTW));
4150+
xPyDict_SetItemString(Aarch64OpcodesDict, "IC", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_IC));
4151+
xPyDict_SetItemString(Aarch64OpcodesDict, "DC", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_DC));
4152+
xPyDict_SetItemString(Aarch64OpcodesDict, "AT", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_AT));
4153+
xPyDict_SetItemString(Aarch64OpcodesDict, "TLBI", PyLong_FromUint32(triton::arch::arm::aarch64::ID_INS_TLBI));
40844154

40854155
PyObject* Aarch64OpcodesDictClass = xPyClass_New(nullptr, Aarch64OpcodesDict, xPyString_FromString("AARCH64"));
40864156
xPyDict_SetItemString(opcodesDict, "AARCH64", Aarch64OpcodesDictClass);

src/libtriton/includes/triton/aarch64Semantics.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ namespace triton {
240240
//! The CSET semantics
241241
void cset_s(triton::arch::Instruction& inst);
242242

243+
//! The CSETM semantics
244+
void csetm_s(triton::arch::Instruction& inst);
245+
243246
//! The CSINC semantics
244247
void csinc_s(triton::arch::Instruction& inst);
245248

0 commit comments

Comments
 (0)