|
From: <sv...@va...> - 2011-05-11 14:17:42
|
Author: sewardj
Date: 2011-05-11 15:17:35 +0100 (Wed, 11 May 2011)
New Revision: 2151
Log:
ARM front end only: when processing Thumb instructions, create
IMark entries for the correct addresses.
Modified:
trunk/priv/guest_generic_bb_to_IR.c
Modified: trunk/priv/guest_generic_bb_to_IR.c
===================================================================
--- trunk/priv/guest_generic_bb_to_IR.c 2011-05-09 21:45:04 UTC (rev 2150)
+++ trunk/priv/guest_generic_bb_to_IR.c 2011-05-11 14:17:35 UTC (rev 2151)
@@ -261,9 +261,22 @@
/* Add an instruction-mark statement. We won't know until after
disassembling the instruction how long it instruction is, so
- just put in a zero length and we'll fix it up later. */
- addStmtToIRSB( irsb, IRStmt_IMark( guest_IP_curr_instr, 0 ));
+ just put in a zero length and we'll fix it up later.
+ On ARM, the least significant bit of the instr address
+ distinguishes ARM vs Thumb instructions. All instructions
+ actually start on at least 2-aligned addresses. So we need
+ to ignore the bottom bit of the insn address when forming the
+ IMark. For more details of this convention, see comments on
+ definition of guest_R15 in libvex_guest_arm.h. */
+ addStmtToIRSB( irsb,
+ IRStmt_IMark( arch_guest == VexArchARM
+ ? (guest_IP_curr_instr & ~(Addr64)1)
+ : guest_IP_curr_instr,
+ 0
+ )
+ );
+
/* for the first insn, the dispatch loop will have set
%IP, but for all the others we have to do it ourselves. */
need_to_put_IP = toBool(n_instrs > 0);
|