Skip to content

Commit d1f332b

Browse files
committed
Merge branch 'it-block-split' into 'main'
Fix a bug that could cause IT block to split Closes #629 See merge request rewriting/ddisasm!1244
2 parents 5a8779f + 9f3057a commit d1f332b

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 1.9.2 (Unreleased)
22

3+
* Fix bug that could cause conditionial code to be missing in IT-block instructions.
4+
35
# 1.9.1
46

57
* Fix a hang due to incorrect jump-table boundaries inferred from irrelevant register correlations to the index register

src/datalog/arch/arm32_code_inference.dl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,17 @@ negative_block_heuristic(Block,"code",Size,0,"arm: possibly invalid thumb block"
760760
align_addr(BlockAligned,Block),
761761
code_in_block_candidate_refined(BlockAligned,_).
762762

763+
/**
764+
Control flow must not jump into the middle of an IT block.
765+
*/
766+
negative_block_heuristic(Block,"code",Size,0,"arm: possibly jump to in the middle of IT block"):-
767+
unresolved_block(Block,"code",Size),
768+
arch.it_conditional(JmpTarget,IT_EA),
769+
direct_jump(EA,JmpTarget),
770+
code_in_block_candidate(EA,Block),
771+
code_in_block_candidate_refined(JmpTarget,_),
772+
code_in_block_candidate_refined(IT_EA,_).
773+
763774
/**
764775
There can be false positives of literal pools.
765776
Give more points to the literal pool (data) and the ref block (code)

src/datalog/arch/arm32_code_inference_weights.dl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ default_heuristic_weight("arm: plt call",SIMPLE_WEIGHT,1).
5353
default_heuristic_weight("arm: pointer to string adjacent to another strings in data",SIMPLE_WEIGHT,3).
5454
default_heuristic_weight("arm: pointer to string in data",SIMPLE_WEIGHT,2).
5555
default_heuristic_weight("arm: possibly invalid thumb block",SIMPLE_WEIGHT,-1).
56+
default_heuristic_weight("arm: possibly jump to in the middle of IT block",SIMPLE_WEIGHT,-30).
5657
default_heuristic_weight("arm: return followed by a function",SIMPLE_WEIGHT,2).
5758
default_heuristic_weight("litpool: litpool ref block: adr/ldm",SIMPLE_WEIGHT,4).
5859
default_heuristic_weight("litpool: litpool ref block: adr/ldm unresolved",SIMPLE_WEIGHT,2).

0 commit comments

Comments
 (0)