Skip to content

Commit

Permalink
Fixes ARM/Thumb movt semantics (BinaryAnalysisPlatform#1391)
Browse files Browse the repository at this point in the history
* Fixes ARM/Thumb `movt` semantics

The lifter was incorrectly re-using the upper 16 bits of the destination
register, when the manual states that it is completely overwritten by
the source operand.

* Use bit-wise operations instead of casts

Co-authored-by: Ivan Gotovchits <ivg@ieee.org>
Co-authored-by: bmourad01 <bmourad@draper.com>
  • Loading branch information
3 people authored Jan 5, 2022
1 parent ec806bd commit 92d67c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/arm/arm_lifter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ let lift_move ~encoding mem ops (insn : move_insn) : stmt list =
exec [Bil.move (Env.of_reg dest) (exp_of_op src)] cond

| `MOVTi16, [|`Reg dest; _; src; cond; _wflag|] ->
let dest = Env.of_reg dest in
[Bil.move dest Bil.(var dest lor exp_of_op src lsl int32 16)] |>
let dest = Env.of_reg dest and src = exp_of_op src in
Bil.[dest := var dest land int32 0xFFFF lor src lsl int32 16] |>
fun ins -> exec ins cond
| insn,ops ->
fail [%here] "ops %s doesn't match move insn %s"
Expand Down

0 comments on commit 92d67c8

Please sign in to comment.