Skip to content

Commit

Permalink
Fix #1310: LDRSW (literal)
Browse files Browse the repository at this point in the history
  • Loading branch information
Triton Library committed Mar 11, 2024
1 parent 06610ca commit 924bcbb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .build_number
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1590
1591
5 changes: 5 additions & 0 deletions src/libtriton/arch/arm/aarch64/aarch64Semantics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3385,6 +3385,11 @@ namespace triton {
triton::arch::OperandWrapper& dst = inst.operands[0];
triton::arch::OperandWrapper& src = inst.operands[1];

/* LDRSW (literal) */
if (inst.operands.size() == 2 && src.getType() == triton::arch::OP_IMM) {
src = triton::arch::MemoryAccess(src.getConstImmediate().getValue(), dst.getSize());
}

/* Create symbolic operands */
auto op = this->symbolicEngine->getOperandAst(inst, src);

Expand Down
13 changes: 13 additions & 0 deletions src/testers/unittests/test_github_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,19 @@ def test_2(self):
x0 = self.ctx.getConcreteRegisterValue(self.ctx.registers.x0)
self.assertEqual(x0, 0x55667788)

class TestIssue1310(unittest.TestCase):
"""Testing #1310."""

def setUp(self):
self.ctx = TritonContext(ARCH.AARCH64)
self.ctx.setConcreteMemoryAreaValue(0x400000+0x30, b'\x72\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

def test_1(self):
inst = Instruction(0x400000, b'\x91\x01\x00\x98') # ldrsw x17, #0x30
self.ctx.processing(inst)
x17 = self.ctx.getConcreteRegisterValue(self.ctx.registers.x17)
self.assertEqual(x17, 0x72)


# FIXME: Uncomment this one when we will move to Capstone 5 as min version
#class TestIssue1195(unittest.TestCase):
Expand Down

0 comments on commit 924bcbb

Please sign in to comment.