Skip to content

Commit 256676c

Browse files
authored
fixes unconditional pop with return in thumb (#1449)
Not really a bug but an ugly code generated for the unconditional pop instruction that involves the PC register, ``` bap mc --arch=thumb --show-bil --show-insn=asm --show-mem --addr=0x1c04 -- f0 bd 1c04: f0 bd pop {r4, r5, r6, r7, pc} { if (1) { R4 := mem[SP, el]:u32 R5 := mem[SP + 4, el]:u32 R6 := mem[SP + 8, el]:u32 R7 := mem[SP + 0xC, el]:u32 SP := SP + 0x10 jmp (mem[SP, el]:u32) } } ``` This change removes this bogus `if(1)`.
1 parent 17676c2 commit 256676c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

plugins/thumb/thumb_mem.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ module Make(CT : Theory.Core) = struct
9999
sp += const Int.(List.length regs * 4);
100100
] in
101101
let ctrl = CT.jmp (load s32 (var sp)) in
102-
CT.branch ~?cnd (CT.blk null data ctrl) (seq [])
102+
match cnd with
103+
| `AL -> CT.blk null data ctrl
104+
| _ -> CT.branch ~?cnd (CT.blk null data ctrl) (seq [])
103105

104106

105107
let push regs cnd = branch cnd [

0 commit comments

Comments
 (0)