Skip to content

Commit dd3bfe7

Browse files
committed
CHB:ARM: handle ADR instructions with PC-target
1 parent b60843a commit dd3bfe7

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

CodeHawk/CHB/bchlibarm32/bCHConstructARMFunction.ml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
------------------------------------------------------------------------------
55
The MIT License (MIT)
66
7-
Copyright (c) 2022-2024 Aarno Labs LLC
7+
Copyright (c) 2022-2025 Aarno Labs LLC
88
99
Permission is hereby granted, free of charge, to any person obtaining a copy
1010
of this software and associated documentation files (the "Software"), to deal
@@ -126,6 +126,20 @@ let get_successors
126126
| Pop (_, _, rl, _) when rl#includes_pc ->
127127
(next ()) @ [wordmax]
128128

129+
| Adr (ACCAlways, dst, src)
130+
when dst#is_pc_register && dst#is_absolute_address ->
131+
if src#get_absolute_address#equal iaddr then
132+
[]
133+
else
134+
[src#get_absolute_address]
135+
136+
| Adr (_, dst, src)
137+
when dst#is_pc_register && dst#is_absolute_address ->
138+
if src#get_absolute_address#equal iaddr then
139+
(next ())
140+
else
141+
(next ()) @ [src#get_absolute_address]
142+
129143
(* return via LDM/LDMDB/LDMDA/LDMIB *)
130144
| LoadMultipleDecrementBefore (_, ACCAlways, _, rl, _)
131145
| LoadMultipleDecrementAfter (_, ACCAlways, _, rl, _)

CodeHawk/CHB/bchlibarm32/bCHDisassembleARM.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,13 @@ let set_block_boundaries () =
696696
when is_nr_call_instruction instr ->
697697
set_block_entry (va#add_int 4)
698698

699+
| Adr (_, dst, src) when dst#is_pc_register ->
700+
begin
701+
set_block_entry (va#add_int 4);
702+
if src#is_absolute_address then
703+
set_block_entry src#get_absolute_address
704+
end
705+
699706
| _ -> ())
700707
with
701708
| BCH_failure p ->

0 commit comments

Comments
 (0)