From 24e491b31fd8a796e96c0d625d44042d9b0ec3b0 Mon Sep 17 00:00:00 2001 From: Vasiliy Ulyanov Date: Tue, 8 Apr 2014 09:48:40 +0400 Subject: [PATCH] [FIX] CBZ branch displacement calculation - zero out original branch displacement: imm5 = 0; i = 0; - replace it with 8 bytes offset in execbuf: imm5 = 0b00010 Change-Id: Ib59d362964845516000637f0a4eb295ad211d221 Signed-off-by: Vasiliy Ulyanov --- uprobe/arch/asm-arm/swap_uprobes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/uprobe/arch/asm-arm/swap_uprobes.c b/uprobe/arch/asm-arm/swap_uprobes.c index a4c1157..120226f 100644 --- a/uprobe/arch/asm-arm/swap_uprobes.c +++ b/uprobe/arch/asm-arm/swap_uprobes.c @@ -516,7 +516,9 @@ static int arch_copy_trampoline_thumb_uprobe(struct uprobe *up) } else if (THUMB_INSN_MATCH(CBZ, insn)) { memcpy(tramp, cbz_insn_execbuf_thumb, tramp_len); *((unsigned short*)tramp + 13) = 0xdeff; - *((unsigned short*)tramp + 0) = insn & (~0xf8); + /* zero out original branch displacement (imm5 = 0; i = 0) */ + *((unsigned short*)tramp + 0) = insn & (~0x2f8); + /* replace it with 8 bytes offset in execbuf (imm5 = 0b00010) */ *((unsigned short*)tramp + 0) |= 0x20; addr = cbz_t16_dest(insn, vaddr); *((unsigned short*)tramp + 14) = (addr & 0x0000ffff) | 0x1; -- 2.7.4