-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uses ghidra backend for AVR lifter and disassembler
- Loading branch information
Showing
6 changed files
with
43 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,5 @@ | ||
open Bap_core_theory | ||
|
||
val parent : Theory.target | ||
val atmega328 : Theory.target | ||
val llvm_avr16 : Theory.language | ||
|
||
type r16 and r8 | ||
|
||
type 'a bitv = 'a Theory.Bitv.t Theory.Value.sort | ||
|
||
val r16 : r16 bitv | ||
val r8 : r8 bitv | ||
|
||
val code : (r16, r16) Theory.Mem.t Theory.var | ||
val data : (r16, r8) Theory.Mem.t Theory.var | ||
val gpr : r8 Theory.Bitv.t Theory.var list | ||
val sp : r16 Theory.Bitv.t Theory.var | ||
val flags : Theory.Bool.t Theory.var list | ||
val load : unit -> unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,12 @@ | ||
open Bap_main | ||
open Bap.Std | ||
open Bap_core_theory | ||
open KB.Syntax | ||
module CT = Theory | ||
|
||
include Bap_main.Loggers() | ||
|
||
module Target = Bap_avr_target | ||
module Dis = Disasm_expert.Basic | ||
|
||
let provide_decoding () = | ||
KB.promise CT.Label.encoding @@ fun label -> | ||
CT.Label.target label >>| fun t -> | ||
if CT.Target.belongs Target.parent t | ||
then Target.llvm_avr16 | ||
else CT.Language.unknown | ||
|
||
let enable_llvm () = | ||
Dis.register Target.llvm_avr16 @@ fun _target -> | ||
Dis.create ~backend:"llvm" "avr" | ||
|
||
let enable_loader () = | ||
let request_arch doc = | ||
let open Ogre.Syntax in | ||
match Ogre.eval (Ogre.request Image.Scheme.arch) doc with | ||
| Error _ -> assert false (* nothing could go wrong here! *) | ||
| Ok arch -> arch in | ||
KB.promise CT.Unit.target @@ fun unit -> | ||
KB.collect Image.Spec.slot unit >>| request_arch >>| function | ||
| Some "avr" -> Target.atmega328 | ||
| _ -> CT.Target.unknown | ||
|
||
|
||
let main _ctxt = | ||
enable_llvm (); | ||
enable_loader (); | ||
provide_decoding (); | ||
Avr_lifter.load (); | ||
Bap_avr_target.load (); | ||
Ok () | ||
|
||
(* semantic tags that describe what our plugin is providing, | ||
setting them is important not only for introspection but | ||
for the proper function of the cache subsystem. | ||
*) | ||
let provides = [ | ||
"avr"; | ||
"lifter"; | ||
] | ||
|
||
(* finally, let's register our extension and call the main function *) | ||
let () = Bap_main.Extension.declare main | ||
~provides | ||
~provides:[ | ||
"avr"; | ||
"lifter"; | ||
] |