airbus-seclab / bincat

Binary code static analyser, with IDA integration. Performs value and taint analysis, type reconstruction, use-after-free and double-free detection
1.66k stars 159 forks source link

Compilation failed on Windows #99

Closed p-state closed 5 years ago

p-state commented 5 years ago

I have followed this instruction to build bincat, but it causes error during compilation:

$ make windist PYTHON=python
Compiling OCaml part.................................................
make[1]: Entering directory '/cygdrive/c/OCaml64/bincat/ocaml/src'
ocamllex frontend/lexer.mll
57 states, 2172 transitions, table size 9030 bytes
menhir --explain frontend/parser.mly
File "frontend/parser.mly", line 171, characters 13-17:
Warning: the token SINT is unused.
File "frontend/parser.mly", line 160, characters 39-44:
Warning: the token STACK is unused.
File "frontend/parser.mly", line 335, characters 4-12:
Warning: symbol x64_item is unreachable from any of the start symbol(s).
[ -f bincat_ver.ml ] || touch bincat_ver.ml
grep -q v1.1 bincat_ver.ml || sed s/XXX/v1.1/ bincat_ver.ml.tmpl > bincat_ver.ml
rm -f .depend
ocamldep  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint -slash -native utils/exceptions.ml utils/misc.ml data-struct/register.ml utils/mapOpt.ml utils/setExt.ml utils/bits.ml data-struct/taint.ml utils/config.ml data-struct/data.ml utils/log.ml frontend/init_check.ml data-struct/types.ml data-struct/asm.ml utils/dump.ml data-struct/mapped_mem.ml loaders/manual.ml loaders/raw.ml loaders/elf_core.ml loaders/elf.ml loaders/elf_coredump.ml disassembly/decodeutils.ml fixpoint/stubs.ml fixpoint/rules.ml disassembly/x86Imports.ml disassembly/x64Imports.ml disassembly/armv7Imports.ml disassembly/armv8aImports.ml disassembly/powerpcImports.ml frontend/lexer.ml frontend/parser.ml domains/env.ml domains/typenv.ml domains/bit.ml domains/unrel.ml domains/vector.ml domains/pointer.ml domains/unrels.ml domains/reduced_bit_tainting.ml domains/heap.ml domains/reduced_unrel_typenv_heap.ml disassembly/cfa.ml disassembly/core_x86.ml disassembly/armv7.ml disassembly/armv8A.ml disassembly/powerpc.ml fixpoint/interpreter.ml bincat_ver.ml main.ml data-struct/register.mli utils/mapOpt.mli utils/setExt.mli data-struct/data.mli loaders/loader.mli domains/domain.mli disassembly/cfa.mli disassembly/decoder.mli fixpoint/stubs.mli > .depend
[ -f bincat_ver.ml ] || touch bincat_ver.ml
grep -q v1.1 bincat_ver.ml || sed s/XXX/v1.1/ bincat_ver.ml.tmpl > bincat_ver.ml
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint  -c utils/exceptions.ml
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint  -c data-struct/register.ml
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint  -c data-struct/taint.ml
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint -I npk/c2newspeak -c utils/config.ml
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint  -c data-struct/data.mli
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint  -c data-struct/data.ml
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint  -c utils/log.ml
File "utils/log.ml", line 159, characters 10-27:
159 |     flush Pervasives.stdout;
                ^^^^^^^^^^^^^^^^^
Alert deprecated: module Stdlib.Pervasives
Use Stdlib instead.

If you need to stay compatible with OCaml < 4.07, you can use the
stdlib-shims library: https://github.com/ocaml/stdlib-shims
File "utils/log.ml", line 168, characters 10-27:
168 |     flush Pervasives.stdout;
                ^^^^^^^^^^^^^^^^^
Alert deprecated: module Stdlib.Pervasives
Use Stdlib instead.

If you need to stay compatible with OCaml < 4.07, you can use the
stdlib-shims library: https://github.com/ocaml/stdlib-shims
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint  -c frontend/init_check.ml
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint -I npk/c2newspeak -c data-struct/types.ml
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint  -c data-struct/asm.ml
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint  -c utils/dump.ml
ocamlopt -g -w Ael -warn-error +a-3-7-50-42-44-58 -w -42 -w -58  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/ocamlgraph  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/zarith  -I C:/OCaml64/home/root/.opam/ocaml-variants.4.08.0+mingw64c/lib/num -I data-struct -I domains -I utils -I disassembly -I frontend -I loaders -I fixpoint  -c data-struct/mapped_mem.ml
File "data-struct/mapped_mem.ml", line 50, characters 20-44:
50 |   let mapped_file = Bigarray.Array1.map_file
                         ^^^^^^^^^^^^^^^^^^^^^^^^
Error: Unbound value Bigarray.Array1.map_file
make[1]: *** [Makefile:200: data-struct/mapped_mem.cmx] Error 2
make[1]: Leaving directory '/cygdrive/c/OCaml64/bincat/ocaml/src'
make: *** [Makefile:20: all] Error 2

I've tried to build latest revision from repository and after checkout to v1.1 tag too.

p-state commented 5 years ago

I fixed it by downgrading OCaml to 4.07.1 (also tried 4.08.1 unsuccessfully).

opam switch create 4.07.1+mingw64c
opam install depext depext-cygwinports
opam depext conf-gmp.1 
opam install menhir zarith ocamlgraph ppx_tools cppo num
eval $(ocaml-env cygwin)
make clean PYTHON=python
make windist PYTHON=python