Skip to content

Commit

Permalink
Fixes handling of fallthroughs in IR theory (BinaryAnalysisPlatform#1380
Browse files Browse the repository at this point in the history
)

* Update LLVM backend to work with version 12

This may also work with later versions, but I did not test them

* Fixes handling of fallthroughs in IR theory

The previous change did not account for calls which are conditional,
and thus would fail to include the fallthrough edge.

* Runs `make indent`

Co-authored-by: Benjamin Mourad <bqm0621@ocsdev02.ocsportal.draper.com>
  • Loading branch information
bmourad01 and Benjamin Mourad authored Dec 3, 2021
1 parent 47a614a commit d1c01da
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions plugins/bil/bil_ir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,21 @@ module IR = struct

let is_call jmp = Option.is_some (Jmp.alt jmp)

let is_unconditional jmp = match Jmp.cond jmp with
| Int w when Word.(w = b1) -> true
| _ -> false

let fall ~tid x dst = match x.jmps with
| [jmp] when is_call jmp -> {
| [jmp] when is_call jmp ->
let jmp' = Jmp.with_dst jmp @@ Some (Jmp.resolved dst) in
if is_unconditional jmp then {
x with jmps = [jmp'];
} else {
x with jmps = [
Jmp.with_dst jmp (Some (Jmp.resolved dst))
]}
Jmp.create_goto (Direct dst);
jmp';
]
}
| jmps -> {x with jmps = goto ~tid dst :: jmps}

let appgraphs fst snd =
Expand Down

0 comments on commit d1c01da

Please sign in to comment.