Skip to content

Commit

Permalink
Merge pull request JonathanSalwan#1300 from cnheitman/fix/adr-semantics
Browse files Browse the repository at this point in the history
Fix semantics of ADR (thumb)
  • Loading branch information
JonathanSalwan authored Dec 22, 2023
2 parents 922b187 + aac6ce8 commit 428fafb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/libtriton/arch/arm/arm32/arm32Semantics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,11 +1085,17 @@ namespace triton {
auto pc = triton::arch::OperandWrapper(this->architecture->getParentRegister(ID_REG_ARM32_PC));

/*
* Note: Capstone already encodes the result into the source operand. We don't have
* to compute the add operation but do we lose the symbolic?
* Note: Here we deal only with the Thumb version of ADR. For the ARM
* version, Capstone decodes it as an ADD and adds pc as an explicit
* operand.
*/
/* Create symbolic semantics */
auto node1 = this->symbolicEngine->getOperandAst(inst, src);

/* Create symbolic operands */
auto op1 = this->getArm32SourceOperandAst(inst, src);
auto op2 = this->getArm32SourceOperandAst(inst, pc);

/* Create the semantics */
auto node1 = this->astCtxt->bvadd(op1, op2);
auto node2 = this->buildConditionalSemantics(inst, dst, node1);

/* Create symbolic expression */
Expand Down
3 changes: 3 additions & 0 deletions src/testers/arm32/unicorn_test_arm32_loadstore_thumb_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
SIZE = 5 * 1024 * 1024

CODE = [
# ADR -------------------------------------------------------------------- #
(b"\x08\xa0", "adr r0, 0x20"),

# LDM - Pre-indexed addressing ------------------------------------------- #
(b"\x91\xe8\x3c\x00", "ldm r1, {r2, r3, r4, r5}"),

Expand Down

0 comments on commit 428fafb

Please sign in to comment.