Skip to content

Commit

Permalink
Moving logic to library, extending project.
Browse files Browse the repository at this point in the history
This PR heavily refactors Project module. First of all it hides project
implementation. Next most of the stuff from `bap` utility is moved to
the project. So now, one can create projects easily without the bap
utility.

The project itself was changed no only cosmetically. The deprecated
fields were removed. First of all, the memory (`mem` field) is now
represented as a [memmap] not as a contiguous chunk of data. Second,
instead of symbol table, represented as `string table`, we now have
[symtab] data structure, that allows to represent non-contiguous and
overlapping symbols. As a result, many functions that depend on previous
symbol representation were changed. All functions that accepts `bound`
as memory, now accepts bound as a function `addr -> bool`. The ABI now
has new, more clean and easy to use interface.

Other changes includes extending plugin system. (Now any plugin can be
loaded dynamically from file). Moving plugin loading stuff from bap
utility to bap_plugins library, and the latter is no more dependend on
bap library.

Also, this PR introduces new more correct and robust symbol recognition
algorithm.

Some polishes of the IR representation, like adding lifter from
instruction and optimizing BIL before lifting (much nicer IR).

New pretty-printing for IR, with all attributes printed as tags, that
can be enabled with `--emit-attr` option.

bap-mc now can print IR for each instruction.

Lots of other changes that will be properly enumerated in CHANGES file
before the release.
  • Loading branch information
ivg committed May 31, 2015
1 parent d4eca45 commit 96bd334
Show file tree
Hide file tree
Showing 75 changed files with 1,432 additions and 1,040 deletions.
6 changes: 3 additions & 3 deletions .merlin
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ EXT ounit
FLG -short-paths
FLG -w -4-33-40-41-42-43-34-44

PKG camlzip
PKG core_kernel
PKG ocamlbuild
PKG fileutils
PKG jsonm
PKG ocamlbuild
PKG ocamlgraph
PKG camlzip
PKG fileutils
PKG uuidm

B _build
Expand Down
45 changes: 16 additions & 29 deletions _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,22 @@ Library bap
BuildDepends: bap.disasm,
bap.dwarf,
bap.elf,
bap.elf_backend,
bap.image,
bap.llvm,
bap.llvm_loader,
bap.sema,
bap.types,
dynlink,
findlib
bap.types
Modules: Bap
InternalModules: Bap_project


Library plugins
Path: lib/bap
FindLibParent: bap
FindLibName: plugins
Modules: Bap_plugins
InternalModules: Bap_plugin
BuildDepends: bap.elf_backend,
bap.llvm_loader_backend,
bap.llvm
BuildDepends: core_kernel, dynlink, fileutils, findlib

Library top
XMETADescription:
Expand Down Expand Up @@ -176,8 +174,8 @@ Library elf_backend
FindlibName: elf_backend
XMETAExtraLines: plugin_system = "bap.image.disabled"
CompiledObject: best
BuildDepends: bap, core_kernel
InternalModules: Image_elf
BuildDepends: core_kernel
InternalModules: Bap_native_loader

Library elf
Path: lib/bap_elf
Expand All @@ -193,30 +191,19 @@ Library elf

Library llvm_loader
Path: lib/bap_image/
FindlibParent: bap_image
FindlibParent: bap
FindlibName: llvm_loader
CompiledObject: best
BuildDepends: bap, core_kernel
Modules: Llvm_loader,
Llvm_binary,
Llvm_binary_segment,
Llvm_binary_symbol,
Llvm_binary_section
BuildDepends: core_kernel
InternalModules: Bap_llvm_binary,
Bap_llvm_loader,
Bap_llvm_types

CCOpt: $cc_optimization
CCLib: $llvm_lib $cxxlibs $llvm_ldflags
CSources: llvm_binary_stubs.c,
llvm_binary_stubs.h
CSources: bap_llvm_binary_stubs.c,
bap_llvm_binary_stubs.h

Library llvm_loader_backend
Path: lib/bap_image/
FindlibParent: bap
FindlibName: llvm_loader_backend
XMETAExtraLines: plugin_system = "bap.image.disabled"
CompiledObject: best
BuildDepends: bap,
bap.image.llvm_loader,
core_kernel
InternalModules: Llvm_loader_backend

Library dwarf
Path: lib/bap_dwarf
Expand Down Expand Up @@ -273,6 +260,7 @@ Library disasm
Bap_disasm_prim,
Bap_disasm_rec,
Bap_disasm_std,
Bap_disasm_symtab,
Bap_disasm_types,
Bap_insn_kind,
Bap_byteweight,
Expand Down Expand Up @@ -305,7 +293,6 @@ Library sema
bap.types
InternalModules:
Bap_sema,
Bap_sema_symtab,
Bap_sema_lift,
Bap_ir,
Bap_lnf
Expand Down
9 changes: 9 additions & 0 deletions lib/bap/bap.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open Core_kernel.Std

module Std = struct
type 'a printer = Format.formatter -> 'a -> unit
include Bap_types.Std
Expand All @@ -12,3 +14,10 @@ module Std = struct
module Signatures = Bap_signatures
module Byteweight = Bap_byteweight
end

(* load internal plugins *)
let internal : (module Unit) list = [
(module Bap_llvm);
(module Bap_llvm_loader);
(module Bap_native_loader);
]
Loading

0 comments on commit 96bd334

Please sign in to comment.