├── .gitignore ├── README.ROPC ├── README.md ├── bin └── .gitignore ├── doc ├── presentation │ └── compilador-rop.ekoparty-2013.slides.pdf └── src │ ├── .gitignore │ └── style.css ├── lib ├── .gitignore └── bap-0.4 │ ├── AUTHORS │ ├── BIGINT │ ├── COPYING │ ├── ChangeLog │ ├── INSTALL │ ├── Makefile │ ├── Makefile.am │ ├── Makefile.in │ ├── NEWS │ ├── NOTESTS │ ├── README │ ├── STYLE.C │ ├── STYLE.ocaml │ ├── TAGS │ ├── TODO │ ├── VEX │ ├── BAP.README │ ├── HACKING.README │ ├── LICENSE.GPL │ ├── LICENSE.README │ ├── Makefile │ ├── Makefile-gcc │ ├── Makefile-icc │ ├── TODO.txt │ ├── auxprogs │ │ └── genoffsets.c │ ├── bap_patch_20110908.patch │ ├── nanoarm.orig │ ├── newline.txt │ ├── orig_amd64 │ │ ├── Compare.hs │ │ ├── SortedToOrig.hs │ │ ├── test1.orig │ │ ├── test1.sorted │ │ ├── test2.orig │ │ └── test2.sorted │ ├── orig_arm │ │ ├── nanoarm │ │ └── nanoarm.orig │ ├── orig_ppc32 │ │ ├── date.orig │ │ ├── loadsafp.orig │ │ ├── morefp.orig │ │ └── return0.orig │ ├── orig_x86 │ │ ├── exit42.orig │ │ ├── fpu_mmx_sse.orig │ │ └── manyfp.orig │ ├── priv │ │ ├── guest_amd64_defs.h │ │ ├── guest_amd64_helpers.c │ │ ├── guest_amd64_toIR.c │ │ ├── guest_arm_defs.h │ │ ├── guest_arm_helpers.c │ │ ├── guest_arm_toIR.c │ │ ├── guest_generic_bb_to_IR.c │ │ ├── guest_generic_bb_to_IR.h │ │ ├── guest_generic_x87.c │ │ ├── guest_generic_x87.h │ │ ├── guest_ppc_defs.h │ │ ├── guest_ppc_helpers.c │ │ ├── guest_ppc_toIR.c │ │ ├── guest_s390_defs.h │ │ ├── guest_s390_helpers.c │ │ ├── guest_s390_toIR.c │ │ ├── guest_x86_defs.h │ │ ├── guest_x86_helpers.c │ │ ├── guest_x86_toIR.c │ │ ├── host_amd64_defs.c │ │ ├── host_amd64_defs.h │ │ ├── host_amd64_isel.c │ │ ├── host_arm_defs.c │ │ ├── host_arm_defs.h │ │ ├── host_arm_isel.c │ │ ├── host_generic_reg_alloc2.c │ │ ├── host_generic_regs.c │ │ ├── host_generic_regs.h │ │ ├── host_generic_simd128.c │ │ ├── host_generic_simd128.h │ │ ├── host_generic_simd64.c │ │ ├── host_generic_simd64.h │ │ ├── host_ppc_defs.c │ │ ├── host_ppc_defs.h │ │ ├── host_ppc_isel.c │ │ ├── host_s390_defs.c │ │ ├── host_s390_defs.h │ │ ├── host_s390_disasm.c │ │ ├── host_s390_disasm.h │ │ ├── host_s390_isel.c │ │ ├── host_x86_defs.c │ │ ├── host_x86_defs.h │ │ ├── host_x86_isel.c │ │ ├── ir_defs.c │ │ ├── ir_match.c │ │ ├── ir_match.h │ │ ├── ir_opt.c │ │ ├── ir_opt.h │ │ ├── main_globals.c │ │ ├── main_globals.h │ │ ├── main_main.c │ │ ├── main_util.c │ │ └── main_util.h │ ├── pub │ │ ├── libvex.h │ │ ├── libvex_basictypes.h │ │ ├── libvex_emwarn.h │ │ ├── libvex_guest_amd64.h │ │ ├── libvex_guest_arm.h │ │ ├── libvex_guest_ppc32.h │ │ ├── libvex_guest_ppc64.h │ │ ├── libvex_guest_s390x.h │ │ ├── libvex_guest_x86.h │ │ ├── libvex_ir.h │ │ ├── libvex_s390x_common.h │ │ └── libvex_trc_values.h │ ├── quote.txt │ ├── switchback │ │ ├── Makefile │ │ ├── binary_switchback.pl │ │ ├── linker.c │ │ ├── linker.h │ │ ├── switchback.c │ │ ├── test_bzip2.c │ │ ├── test_emfloat.c │ │ ├── test_hello.c │ │ ├── test_ppc_jm1.c │ │ └── test_simple.c │ ├── test │ │ ├── fldenv.c │ │ ├── fp1.c │ │ ├── fp1.s │ │ ├── fpconst.c │ │ ├── fpgames.s │ │ ├── fpspeed.c │ │ ├── fpucw.c │ │ ├── frstor.c │ │ ├── fsave.c │ │ ├── fstenv.c │ │ ├── fxsave.c │ │ ├── mmxtest.c │ │ ├── mxcsr.c │ │ ├── rounderr.c │ │ ├── test-amd64-muldiv.h │ │ ├── test-amd64-shift.h │ │ ├── test-amd64.c │ │ ├── test-amd64.h │ │ ├── test-i386-muldiv.h │ │ ├── test-i386-shift.h │ │ ├── test-i386.c │ │ ├── test-i386.h │ │ ├── x87fxam.c │ │ └── x87tst.c │ ├── test_main.c │ ├── test_main.h │ ├── test_main.h.base │ ├── unused │ │ ├── arena.h │ │ ├── dispatch.c │ │ └── linker.c │ └── useful │ │ ├── cpuid.c │ │ ├── fp_80_64.c │ │ ├── fpround.c │ │ ├── fspill.c │ │ ├── gradual_underflow.c │ │ ├── hd_fpu.c │ │ ├── show_fp_state.c │ │ ├── smchash.c │ │ └── x87_to_vex_and_back.c │ ├── aclocal.m4 │ ├── autogen.sh │ ├── autom4te.cache │ ├── output.0 │ ├── output.1 │ ├── requests │ ├── traces.0 │ └── traces.1 │ ├── batteries-1.4.0 │ ├── .gitignore │ ├── ChangeLog │ ├── FAQ │ ├── LICENSE │ ├── META.in │ ├── Makefile │ ├── README │ ├── README.folders │ ├── README.md │ ├── VERSION │ ├── _oasis │ ├── _tags │ ├── batteries.odocl │ ├── battop.ml │ ├── benchsuite │ │ ├── README │ │ ├── _tags │ │ ├── bench_int.ml │ │ ├── bench_map.ml │ │ ├── bench_set.ml │ │ └── grouping.ml │ ├── build │ │ ├── README │ │ ├── camlzip │ │ │ ├── META │ │ │ └── Makefile │ │ ├── fix_camlp4_print.ml │ │ ├── import.ml │ │ ├── intro.text │ │ ├── make_suite.mll │ │ ├── mkconf.ml │ │ ├── myocamlbuild.ml │ │ ├── odoc_batteries_factored.ml │ │ ├── odoc_extract_mli.ml │ │ ├── odoc_generator_batlib.ml │ │ ├── odoc_tags.ml │ │ ├── optcomp │ │ │ ├── LICENSE │ │ │ ├── META │ │ │ ├── README │ │ │ ├── _tags │ │ │ ├── optcomp.ml │ │ │ ├── optcomp_o.ml │ │ │ ├── optcomp_r.ml │ │ │ ├── pa_optcomp.ml │ │ │ ├── sample.ml │ │ │ └── sample_incl.ml │ │ ├── packdoc.ml │ │ └── preprocess_mli │ │ │ ├── _tags │ │ │ ├── extract_mli.ml │ │ │ ├── generate_mli.ml │ │ │ └── preprocess_common.ml │ ├── byte.itarget │ ├── doc │ │ ├── batteries.svg │ │ ├── batteries │ │ │ ├── GUIDELINES │ │ │ ├── documentation.idex │ │ │ ├── html │ │ │ │ ├── about.html │ │ │ │ ├── batteries_large.png │ │ │ │ ├── extensions.html │ │ │ │ ├── guidelines.html │ │ │ │ ├── index.html │ │ │ │ ├── setup.html │ │ │ │ ├── style.css │ │ │ │ ├── toplevel.html │ │ │ │ ├── tutorial.html │ │ │ │ └── tutorial_godi.html │ │ │ ├── language.idex │ │ │ └── toplevel.help │ │ ├── batteries_large.png │ │ └── external_site_icon.gif │ ├── examples │ │ ├── README │ │ ├── _tags │ │ ├── benchmark │ │ │ ├── Makefile │ │ │ ├── _tags │ │ │ ├── arg2.ml │ │ │ ├── myocamlbuild.ml │ │ │ ├── run_tests.sh │ │ │ ├── t_enum.ml │ │ │ ├── t_list.ml │ │ │ ├── t_pow.ml │ │ │ ├── t_read.log │ │ │ ├── t_read.ml │ │ │ ├── t_read_stub.c │ │ │ └── t_strstr.ml │ │ ├── euler │ │ │ ├── Makefile │ │ │ ├── euler001.ml │ │ │ ├── euler008.ml │ │ │ ├── euler009.ml │ │ │ ├── euler010.ml │ │ │ ├── euler011.ml │ │ │ ├── euler012.ml │ │ │ ├── euler013.ml │ │ │ ├── euler014.ml │ │ │ ├── euler018.ml │ │ │ ├── euler019.ml │ │ │ ├── euler021.ml │ │ │ ├── euler022.ml │ │ │ ├── euler023.ml │ │ │ ├── euler024.ml │ │ │ ├── euler067.ml │ │ │ ├── mathlib.ml │ │ │ └── names.txt │ │ ├── pleac │ │ │ └── strings.ml │ │ ├── snippets │ │ │ ├── _tags │ │ │ ├── accumulator.ml │ │ │ ├── myocamlbuild.ml │ │ │ ├── netchan_cat.ml │ │ │ ├── parallelsort.ml │ │ │ ├── ropes_vs_strings.ml │ │ │ ├── snippets.itarget │ │ │ ├── test_printf.ml │ │ │ ├── unicode.ml │ │ │ └── unicode2.ml │ │ └── tools │ │ │ ├── _tags │ │ │ ├── browser.ml │ │ │ ├── cat.ml │ │ │ ├── cat2.ml │ │ │ ├── conv.ml │ │ │ ├── gunzip.ml │ │ │ ├── mygzip.ml │ │ │ ├── myocamlbuild.ml │ │ │ ├── now.ml │ │ │ ├── pair.ml │ │ │ ├── shuffle.ml │ │ │ ├── shuffle2.ml │ │ │ └── tools.itarget │ ├── libs │ │ ├── .gitignore │ │ ├── estring.itarget │ │ └── estring │ │ │ ├── LICENSE │ │ │ ├── META │ │ │ ├── Makefile │ │ │ ├── README │ │ │ ├── VERSION │ │ │ ├── _tags │ │ │ ├── pa_estring.ml │ │ │ ├── pa_estring.mli │ │ │ ├── pa_estring_top.ml │ │ │ └── sample │ │ │ ├── pa_string_list.ml │ │ │ └── sample.ml │ ├── myocamlbuild.ml │ ├── native.itarget │ ├── num │ ├── ocamlinit │ ├── qtest │ │ ├── _tags │ │ ├── quickcheck.ml │ │ ├── test_runner.ml │ │ └── tests.ml │ ├── setup.ml │ ├── shared.itarget │ ├── src │ │ ├── _tags │ │ ├── batArg.ml │ │ ├── batArg.mli │ │ ├── batArray.ml │ │ ├── batArray.mli │ │ ├── batAvlTree.ml │ │ ├── batAvlTree.mli │ │ ├── batBase64.ml │ │ ├── batBase64.mli │ │ ├── batBig_int.ml │ │ ├── batBig_int.mli │ │ ├── batBigarray.ml │ │ ├── batBigarray.mli │ │ ├── batBitSet.ml │ │ ├── batBitSet.mli │ │ ├── batBool.ml │ │ ├── batBool.mli │ │ ├── batBuffer.ml │ │ ├── batBuffer.mli │ │ ├── batCache.ml │ │ ├── batCache.mli │ │ ├── batCamomile-0.7.ml │ │ ├── batCamomile-0.8.1.ml │ │ ├── batCamomile-0.8.2.ml │ │ ├── batChar.ml │ │ ├── batChar.mli │ │ ├── batCharEncodings.ml │ │ ├── batCharEncodings.mli │ │ ├── batCharParser.ml │ │ ├── batCharParser.mli │ │ ├── batComplex.ml │ │ ├── batComplex.mli │ │ ├── batConcurrent.ml │ │ ├── batConcurrent.mli │ │ ├── batDeque.ml │ │ ├── batDeque.mli │ │ ├── batDigest.ml │ │ ├── batDigest.mli │ │ ├── batDllist.ml │ │ ├── batDllist.mli │ │ ├── batDynArray.ml │ │ ├── batDynArray.mli │ │ ├── batEnum.ml │ │ ├── batEnum.mli │ │ ├── batFile.ml │ │ ├── batFile.mli │ │ ├── batFloat.ml │ │ ├── batFloat.mli │ │ ├── batFormat.ml │ │ ├── batFormat.mli │ │ ├── batGc.ml │ │ ├── batGc.mli │ │ ├── batGenlex.ml │ │ ├── batGenlex.mli │ │ ├── batGlobal.ml │ │ ├── batGlobal.mli │ │ ├── batHashcons.ml │ │ ├── batHashcons.mli │ │ ├── batHashtbl.ml │ │ ├── batHashtbl.mli │ │ ├── batHeap.ml │ │ ├── batHeap.mli │ │ ├── batIMap.ml │ │ ├── batIMap.mli │ │ ├── batIO.ml │ │ ├── batIO.mli │ │ ├── batISet.ml │ │ ├── batISet.mli │ │ ├── batInnerIO.ml │ │ ├── batInnerIO.mli │ │ ├── batInnerWeaktbl.ml │ │ ├── batInnerWeaktbl.mli │ │ ├── batInt.ml │ │ ├── batInt.mli │ │ ├── batInt32.ml │ │ ├── batInt32.mli │ │ ├── batInt64.ml │ │ ├── batInt64.mli │ │ ├── batInterfaces.ml │ │ ├── batInterfaces.mli │ │ ├── batLazyList.ml │ │ ├── batLazyList.mli │ │ ├── batLexing.ml │ │ ├── batLexing.mli │ │ ├── batList.ml │ │ ├── batList.mli │ │ ├── batLogger.ml │ │ ├── batLogger.mli │ │ ├── batMap.ml │ │ ├── batMap.mli │ │ ├── batMarshal.ml │ │ ├── batMarshal.mli │ │ ├── batMonad.ml │ │ ├── batMonad.mli │ │ ├── batMultiPMap.ml │ │ ├── batMultiPMap.mli │ │ ├── batMutex.ml │ │ ├── batMutex.mli │ │ ├── batNativeint.ml │ │ ├── batNativeint.mli │ │ ├── batNum.ml │ │ ├── batNum.mli │ │ ├── batNumber.ml │ │ ├── batNumber.mli │ │ ├── batOo.ml │ │ ├── batOo.mli │ │ ├── batOptParse.ml │ │ ├── batOptParse.mli │ │ ├── batOption.ml │ │ ├── batOption.mli │ │ ├── batPMap.ml │ │ ├── batPMap.mli │ │ ├── batPSet.ml │ │ ├── batPSet.mli │ │ ├── batPair.ml │ │ ├── batPair.mli │ │ ├── batParserCo.ml │ │ ├── batParserCo.mli │ │ ├── batPathGen.ml │ │ ├── batPathGen.mli │ │ ├── batPervasives.ml │ │ ├── batPervasives.mli │ │ ├── batPrint.ml │ │ ├── batPrint.mli │ │ ├── batPrintexc.ml │ │ ├── batPrintexc.mli │ │ ├── batPrintf.ml │ │ ├── batPrintf.mli │ │ ├── batQueue.ml │ │ ├── batQueue.mli │ │ ├── batRMutex.ml │ │ ├── batRMutex.mli │ │ ├── batRandom.ml │ │ ├── batRandom.mli │ │ ├── batRef.ml │ │ ├── batRef.mli │ │ ├── batRefList.ml │ │ ├── batRefList.mli │ │ ├── batResult.ml │ │ ├── batResult.mli │ │ ├── batReturn.ml │ │ ├── batReturn.mli │ │ ├── batRope.ml │ │ ├── batRope.mli │ │ ├── batScanf.ml │ │ ├── batScanf.mli │ │ ├── batSeq.ml │ │ ├── batSeq.mli │ │ ├── batSet.ml │ │ ├── batSet.mli │ │ ├── batSplay.ml │ │ ├── batSplay.mli │ │ ├── batStack.ml │ │ ├── batStack.mli │ │ ├── batStd.ml │ │ ├── batStd.mli │ │ ├── batStr.ml │ │ ├── batStr.mli │ │ ├── batStream.ml │ │ ├── batStream.mli │ │ ├── batString.ml │ │ ├── batString.mli │ │ ├── batSubstring.ml │ │ ├── batSubstring.mli │ │ ├── batSys.ml │ │ ├── batSys.mli │ │ ├── batTuple.ml │ │ ├── batTuple.mli │ │ ├── batUChar.ml │ │ ├── batUChar.mli │ │ ├── batUCharParser.ml │ │ ├── batUCharParser.mli │ │ ├── batUTF8.ml │ │ ├── batUTF8.mli │ │ ├── batUnit.ml │ │ ├── batUnit.mli │ │ ├── batUnix.ml │ │ ├── batUnix.mli │ │ ├── batUref.ml │ │ ├── batUref.mli │ │ ├── batValue_printer.ml │ │ ├── batValue_printer.mli │ │ ├── batVect.ml │ │ ├── batVect.mli │ │ ├── batteries.ml │ │ ├── batteries.mllib │ │ ├── batteries_config.mli │ │ ├── batteries_config.mlp │ │ ├── batteries_help.ml │ │ ├── batteries_help.mli │ │ ├── batteries_print.ml │ │ ├── batteries_uni.ml │ │ ├── batteries_uni.mllib │ │ ├── extlibcompat.ml │ │ └── syntax │ │ │ ├── pa_comprehension │ │ │ ├── README │ │ │ ├── _tags │ │ │ └── pa_comprehension.ml │ │ │ ├── pa_llist │ │ │ ├── _tags │ │ │ └── pa_llist.ml │ │ │ └── pa_strings │ │ │ ├── _tags │ │ │ ├── pa_format.ml │ │ │ ├── pa_strings.ml │ │ │ └── pa_strings.mllib │ ├── syntax.itarget │ └── testsuite │ │ ├── _tags │ │ ├── main.ml │ │ ├── myocamlbuild.ml │ │ ├── test_base64.ml │ │ ├── test_digest.ml │ │ ├── test_dynarray.ml │ │ ├── test_enum.ml │ │ ├── test_file.ml │ │ ├── test_hashcons.ml │ │ ├── test_lazy_pattern.ml │ │ ├── test_map.ml │ │ ├── test_mapfunctors.ml │ │ ├── test_mappable.ml │ │ ├── test_multipmap.ml │ │ ├── test_pmap.ml │ │ ├── test_print.ml │ │ ├── test_set.ml │ │ ├── test_stack.ml │ │ ├── test_std.ml │ │ ├── test_string.ml │ │ ├── test_substring.ml │ │ ├── test_toplevel.ml │ │ ├── test_unix.ml │ │ └── test_vect.ml │ ├── bigint-3.12 │ ├── .cvsignore │ ├── .depend │ ├── Changes │ ├── INSTALL │ ├── LICENSE │ ├── Makefile │ ├── Makefile.nt │ ├── Makefile.old │ ├── README │ ├── README.win32 │ ├── Upgrading │ ├── VERSION │ ├── _tags │ ├── byterun │ │ ├── .cvsignore │ │ ├── .depend │ │ ├── Makefile │ │ ├── Makefile.common │ │ ├── Makefile.nt │ │ ├── alloc.c │ │ ├── alloc.h │ │ ├── array.c │ │ ├── backtrace.c │ │ ├── backtrace.h │ │ ├── callback.c │ │ ├── callback.h │ │ ├── compact.c │ │ ├── compact.h │ │ ├── compare.c │ │ ├── compare.h │ │ ├── compatibility.h │ │ ├── config.h │ │ ├── custom.c │ │ ├── custom.h │ │ ├── debugger.c │ │ ├── debugger.h │ │ ├── dynlink.c │ │ ├── dynlink.h │ │ ├── exec.h │ │ ├── extern.c │ │ ├── fail.c │ │ ├── fail.h │ │ ├── finalise.c │ │ ├── finalise.h │ │ ├── fix_code.c │ │ ├── fix_code.h │ │ ├── floats.c │ │ ├── freelist.c │ │ ├── freelist.h │ │ ├── gc.h │ │ ├── gc_ctrl.c │ │ ├── gc_ctrl.h │ │ ├── globroots.c │ │ ├── globroots.h │ │ ├── hash.c │ │ ├── instrtrace.c │ │ ├── instrtrace.h │ │ ├── instruct.h │ │ ├── int64_emul.h │ │ ├── int64_format.h │ │ ├── int64_native.h │ │ ├── intern.c │ │ ├── interp.c │ │ ├── interp.h │ │ ├── intext.h │ │ ├── ints.c │ │ ├── io.c │ │ ├── io.h │ │ ├── lexing.c │ │ ├── main.c │ │ ├── major_gc.c │ │ ├── major_gc.h │ │ ├── md5.c │ │ ├── md5.h │ │ ├── memory.c │ │ ├── memory.h │ │ ├── meta.c │ │ ├── minor_gc.c │ │ ├── minor_gc.h │ │ ├── misc.c │ │ ├── misc.h │ │ ├── mlvalues.h │ │ ├── obj.c │ │ ├── osdeps.h │ │ ├── parsing.c │ │ ├── prims.h │ │ ├── printexc.c │ │ ├── printexc.h │ │ ├── reverse.h │ │ ├── roots.c │ │ ├── roots.h │ │ ├── signals.c │ │ ├── signals.h │ │ ├── signals_byt.c │ │ ├── signals_machdep.h │ │ ├── stacks.c │ │ ├── stacks.h │ │ ├── startup.c │ │ ├── startup.h │ │ ├── str.c │ │ ├── sys.c │ │ ├── sys.h │ │ ├── terminfo.c │ │ ├── ui.h │ │ ├── unix.c │ │ ├── weak.c │ │ ├── weak.h │ │ └── win32.c │ ├── config │ │ ├── .cvsignore │ │ ├── Makefile │ │ ├── Makefile-templ │ │ ├── Makefile.mingw │ │ ├── Makefile.msvc │ │ ├── Makefile.msvc64 │ │ ├── auto-aux │ │ │ ├── .cvsignore │ │ │ ├── align.c │ │ │ ├── ansi.c │ │ │ ├── async_io.c │ │ │ ├── bytecopy.c │ │ │ ├── dblalign.c │ │ │ ├── divmod.c │ │ │ ├── elf.c │ │ │ ├── endian.c │ │ │ ├── getgroups.c │ │ │ ├── gethostbyaddr.c │ │ │ ├── gethostbyname.c │ │ │ ├── hasgot │ │ │ ├── ia32sse2.c │ │ │ ├── initgroups.c │ │ │ ├── int64align.c │ │ │ ├── longlong.c │ │ │ ├── runtest │ │ │ ├── schar.c │ │ │ ├── schar2.c │ │ │ ├── searchpath │ │ │ ├── setgroups.c │ │ │ ├── sharpbang │ │ │ ├── sharpbang2 │ │ │ ├── sighandler.c │ │ │ ├── signals.c │ │ │ ├── sizes.c │ │ │ ├── solaris-ld │ │ │ ├── stackov.c │ │ │ ├── tclversion.c │ │ │ └── trycompile │ │ ├── gnu │ │ │ ├── config.guess │ │ │ └── config.sub │ │ ├── m-nt.h │ │ ├── m-templ.h │ │ ├── m.h │ │ ├── s-nt.h │ │ ├── s-templ.h │ │ └── s.h │ ├── configure │ ├── myocamlbuild.ml │ ├── myocamlbuild_config.mli │ └── otherlibs │ │ ├── Makefile │ │ ├── Makefile.nt │ │ ├── Makefile.shared │ │ └── num │ │ ├── .cvsignore │ │ ├── .depend │ │ ├── .depend.nt │ │ ├── Makefile │ │ ├── Makefile.nt │ │ ├── README │ │ ├── arith_flags.ml │ │ ├── arith_flags.mli │ │ ├── arith_status.ml │ │ ├── arith_status.mli │ │ ├── big_int.ml │ │ ├── big_int.mli │ │ ├── bignum │ │ └── .cvsignore │ │ ├── bng.c │ │ ├── bng.h │ │ ├── bng_alpha.c │ │ ├── bng_amd64.c │ │ ├── bng_digit.c │ │ ├── bng_ia32.c │ │ ├── bng_mips.c │ │ ├── bng_ppc.c │ │ ├── bng_sparc.c │ │ ├── int_misc.ml │ │ ├── int_misc.mli │ │ ├── libnums.clib │ │ ├── nat.h │ │ ├── nat.ml │ │ ├── nat.mli │ │ ├── nat_stubs.c │ │ ├── num.ml │ │ ├── num.mli │ │ ├── nums.mllib │ │ ├── ratio.ml │ │ └── ratio.mli │ ├── config.log │ ├── config.status │ ├── configure │ ├── configure.ac │ ├── depcomp │ ├── doc │ ├── Makefile │ ├── bibtex │ │ ├── biblio.bib │ │ └── misc.bib │ ├── challenges.tex │ ├── chap-developer.tex │ ├── chap-developer │ │ └── overview.tex │ ├── chap-examples.tex │ ├── chap-examples │ │ ├── basic.S │ │ ├── basic.il │ │ ├── basic_mod.il │ │ ├── cdg.pdf │ │ ├── cfg.pdf │ │ ├── cfg_simp.pdf │ │ ├── conceval.tex │ │ ├── ddg.pdf │ │ ├── functions.tex │ │ ├── il.tex │ │ ├── test.c │ │ └── traces.tex │ ├── chap-formalism.tex │ ├── chap-formalism │ │ ├── language.tex │ │ ├── operational-semantics-table.tex │ │ ├── operational-semantics.tex │ │ ├── running-example.tex │ │ ├── syntax-table.tex │ │ ├── syntax.tex │ │ ├── typecheck-table.tex │ │ └── typecheck.tex │ ├── chap-intro.tex │ ├── chap-intro │ │ ├── intro.tex │ │ └── overview.tex │ ├── chap-tools.tex │ ├── chap-tools │ │ ├── discussion.tex │ │ ├── iltrans.tex │ │ ├── obtaining.tex │ │ ├── other-utils.tex │ │ ├── overview.tex │ │ └── toil.tex │ ├── code.sty │ ├── credits.tex │ ├── djb.sty │ ├── fig │ │ ├── Makefile │ │ ├── add-shl.dot │ │ ├── add-shl.pdf │ │ ├── components.fig │ │ ├── components.pdf │ │ ├── memvsarray-1.eps │ │ ├── memvsarray-1.fig │ │ ├── memvsarray-1.pdf │ │ ├── memvsarray-2.eps │ │ ├── memvsarray-2.fig │ │ ├── memvsarray-2.pdf │ │ ├── running-example-patch.eps │ │ ├── running-example-patch.fig │ │ ├── running-example-patch.pdf │ │ ├── running-example.eps │ │ ├── running-example.fig │ │ ├── running-example.pdf │ │ ├── toolchain.fig │ │ └── toolchain.pdf │ ├── goals.tex │ ├── just-formals │ │ ├── Makefile │ │ ├── code.sty │ │ ├── djb.sty │ │ ├── lecnotes.sty │ │ ├── proof.sty │ │ ├── shortcuts.sty │ │ └── vine.tex │ ├── lecnotes.sty │ ├── main.tex │ ├── operational-semantics-functions-table.tex │ ├── proof.sty │ ├── related.tex │ ├── running-asm.tex │ ├── running-il.tex │ └── shortcuts.sty │ ├── gpl-2.0.txt │ ├── install-sh │ ├── libasmir │ ├── Makefile │ ├── Makefile.am │ ├── Makefile.in │ ├── TAGS │ ├── apps │ │ ├── .deps │ │ │ ├── ir_printer.Po │ │ │ ├── lifttrace.Po │ │ │ └── print-ir.Po │ │ ├── Makefile │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── TAGS │ │ ├── ir_printer.cpp │ │ ├── ir_printer.h │ │ ├── lifttrace.cpp │ │ └── print-ir.cpp │ ├── config.h │ ├── config.h.in │ ├── include │ │ ├── asm_program.h │ │ ├── common.h │ │ ├── exp.h │ │ ├── info.h │ │ ├── irtoir-internal.h │ │ ├── irtoir.h │ │ ├── irvisitor.h │ │ ├── jumpbuf.h │ │ ├── stmt.h │ │ ├── translate.h │ │ └── vexmem.h │ ├── makefile.inc │ ├── src │ │ ├── .deps │ │ │ ├── asm_program.Po │ │ │ ├── exp.Po │ │ │ ├── exp_c.Po │ │ │ ├── irtoir-arm.Po │ │ │ ├── irtoir-i386.Po │ │ │ ├── irtoir.Po │ │ │ ├── irtoir_c.Po │ │ │ ├── memory_data.Po │ │ │ ├── ocaml_helpers.Po │ │ │ ├── pin_frame.Po │ │ │ ├── pin_trace.Po │ │ │ ├── readtrace.Po │ │ │ ├── reg_mapping.Po │ │ │ ├── stmt.Po │ │ │ ├── stmt_c.Po │ │ │ ├── symbols.Po │ │ │ ├── trace.Po │ │ │ ├── trace_v40.Po │ │ │ ├── trace_v41.Po │ │ │ ├── trace_v50.Po │ │ │ ├── vexir.Po │ │ │ └── vexmem.Po │ │ ├── Makefile │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── TAGS │ │ ├── asm_program.c │ │ ├── irtoir-arm.cpp │ │ ├── irtoir-i386.cpp │ │ ├── irtoir.cpp │ │ ├── irtoir_c.cpp │ │ ├── memory_data.cpp │ │ ├── ocaml_helpers.c │ │ ├── old_ir │ │ │ ├── exp.cpp │ │ │ ├── exp_c.cpp │ │ │ ├── stmt.cpp │ │ │ └── stmt_c.cpp │ │ ├── symbols.c │ │ ├── traces │ │ │ ├── pin_common.h │ │ │ ├── pin_frame.cpp │ │ │ ├── pin_frame.h │ │ │ ├── pin_syscalls.h │ │ │ ├── pin_taint.cpp │ │ │ ├── pin_taint.h │ │ │ ├── pin_trace.cpp │ │ │ ├── pin_trace.h │ │ │ ├── readtrace.cpp │ │ │ ├── readtrace.h │ │ │ ├── reg_mapping.cpp │ │ │ ├── reg_mapping.h │ │ │ ├── trace.cpp │ │ │ ├── trace.h │ │ │ ├── trace_v40.cpp │ │ │ ├── trace_v40.h │ │ │ ├── trace_v41.cpp │ │ │ ├── trace_v41.h │ │ │ ├── trace_v50.cpp │ │ │ ├── trace_v50.h │ │ │ ├── trace_vXX.h │ │ │ ├── winsyscalls.cpp │ │ │ └── winsyscalls.h │ │ ├── vexir.c │ │ └── vexmem.c │ └── stamp-h1 │ ├── m4 │ ├── ac_ocaml.m4 │ ├── ac_prog_latex.m4 │ ├── acltx_package.m4 │ ├── acltx_package_location.m4 │ └── acltx_prog_kpsewhich.m4 │ ├── missing │ ├── ocaml-proj.example │ ├── Makefile │ ├── README │ └── test.ml │ ├── ocaml │ ├── BatListFull.ml │ ├── Makefile │ ├── OCamlMakefile │ ├── TAGS │ ├── arithmetic.ml │ ├── asmir.ml │ ├── asmir.mli │ ├── asmirconsts.ml │ ├── ast.ml │ ├── ast_convenience.ml │ ├── ast_slice.ml │ ├── ast_visitor.ml │ ├── ast_visitor.mli │ ├── big_int_convenience.ml │ ├── cfg.ml │ ├── cfg.mli │ ├── cfg_ast.ml │ ├── cfg_ast.mli │ ├── cfg_pp.ml │ ├── cfg_ssa.ml │ ├── cfg_ssa.mli │ ├── coalesce.ml │ ├── cvc3_grammar.mly │ ├── cvc3_grammar.output │ ├── cvc3_lexer.mll │ ├── deadcode.ml │ ├── deadcode.mli │ ├── debug.ml │ ├── debug.mli │ ├── debug_snippets.ml │ ├── depgraphs.ml │ ├── disasm.ml │ ├── disasm_i386.ml │ ├── dominator.ml │ ├── eval.ml │ ├── formulap.ml │ ├── gcl.ml │ ├── gcl.mli │ ├── grammar.mly │ ├── grammar.mly.mli │ ├── grammar.output │ ├── grammar_scope.ml │ ├── graphDataflow.ml │ ├── graphDataflow.mli │ ├── graphDataflowW.ml │ ├── hacks.ml │ ├── input.ml │ ├── input.mli │ ├── interpreter.ml │ ├── lexer.mll │ ├── libasmir.idl │ ├── libbfd.idl │ ├── memory2array.ml │ ├── parser.ml │ ├── pp.ml │ ├── prune_unreachable.ml │ ├── prune_unreachable.mli │ ├── reachable.ml │ ├── reachable.mli │ ├── sccvn.ml │ ├── sccvn.mli │ ├── smtexec.ml │ ├── smtexec.mli │ ├── smtlib1.ml │ ├── smtlib2.ml │ ├── ssa.ml │ ├── ssa_simp.ml │ ├── ssa_simp_misc.ml │ ├── ssa_slice.ml │ ├── ssa_visitor.ml │ ├── ssa_visitor.mli │ ├── stp.ml │ ├── stp_grammar.mly │ ├── stp_grammar.output │ ├── stp_lexer.mll │ ├── structural_analysis.ml │ ├── symbeval.ml │ ├── symbeval_search.ml │ ├── template.ml │ ├── test_common.ml │ ├── to_c.ml │ ├── traces.ml │ ├── type.ml │ ├── type.mli │ ├── typecheck.ml │ ├── typesig.sh │ ├── unroll.ml │ ├── util.ml │ ├── util.mli │ ├── utils_common.ml │ ├── var.ml │ ├── var.mli │ ├── vsa.ml │ ├── wp.ml │ ├── yices_grammar.mly │ ├── yices_grammar.output │ └── yices_lexer.mll │ ├── ounit-1.1.0 │ ├── .boring │ ├── AUTHORS.txt │ ├── INSTALL.txt │ ├── LICENSE.txt │ ├── Makefile │ ├── README.txt │ ├── _oasis │ ├── _tags │ ├── changelog │ ├── configure │ ├── doc │ │ └── manual.txt │ ├── examples │ │ ├── Makefile │ │ ├── example.ml │ │ ├── test_list.ml │ │ ├── test_list2.ml │ │ ├── test_stack.ml │ │ └── test_suite.ml │ ├── myocamlbuild.ml │ ├── setup.data │ ├── setup.ml │ ├── src │ │ ├── META │ │ ├── api-ounit.odocl │ │ ├── oUnit.ml │ │ ├── oUnit.mli │ │ ├── oUnit.mllib │ │ ├── oUnitDiff.ml │ │ └── oUnitDiff.mli │ └── test │ │ └── test.ml │ ├── pcre-ocaml-release-6.2.2 │ ├── .hg_archival.txt │ ├── .hgignore │ ├── .hgtags │ ├── Changelog │ ├── INSTALL │ ├── LICENSE │ ├── Makefile │ ├── Makefile.conf │ ├── OCamlMakefile │ ├── OMakefile │ ├── README.txt │ ├── README.win32 │ ├── d3debcff192d │ ├── d3debcff192d.1 │ ├── examples │ │ ├── OMakefile │ │ ├── cloc │ │ │ ├── Makefile │ │ │ ├── OMakefile │ │ │ ├── README │ │ │ ├── cloc.ml │ │ │ └── make_win32_cloc.bat │ │ ├── count_hash │ │ │ ├── Makefile │ │ │ ├── OMakefile │ │ │ ├── README │ │ │ └── count_hash.ml │ │ ├── pcregrep │ │ │ ├── Makefile │ │ │ ├── OMakefile │ │ │ ├── README │ │ │ └── pcregrep.ml │ │ └── subst │ │ │ ├── Makefile │ │ │ ├── OMakefile │ │ │ ├── README │ │ │ └── subst.ml │ ├── lib │ │ ├── META │ │ ├── Makefile │ │ ├── Makefile.win32 │ │ ├── OMakefile │ │ ├── make_msvc.bat │ │ ├── pcre.ml │ │ ├── pcre.mli │ │ └── pcre_stubs.c │ └── pcre_make.win32 │ │ ├── Makefile.mingw │ │ ├── Makefile.win32 │ │ ├── make_pcre.ml │ │ └── pcre.h │ ├── pcre-ocaml-release-6.2.2_ │ ├── .hg_archival.txt │ ├── .hgignore │ ├── .hgtags │ ├── Changelog │ ├── INSTALL │ ├── LICENSE │ ├── Makefile │ ├── Makefile.conf │ ├── OCamlMakefile │ ├── OMakefile │ ├── README.txt │ ├── README.win32 │ ├── examples │ │ ├── OMakefile │ │ ├── cloc │ │ │ ├── ._d │ │ │ │ └── cloc.d │ │ │ ├── Makefile │ │ │ ├── OMakefile │ │ │ ├── README │ │ │ ├── cloc.ml │ │ │ └── make_win32_cloc.bat │ │ ├── count_hash │ │ │ ├── ._d │ │ │ │ └── count_hash.d │ │ │ ├── Makefile │ │ │ ├── OMakefile │ │ │ ├── README │ │ │ └── count_hash.ml │ │ ├── pcregrep │ │ │ ├── ._d │ │ │ │ └── pcregrep.d │ │ │ ├── Makefile │ │ │ ├── OMakefile │ │ │ ├── README │ │ │ └── pcregrep.ml │ │ └── subst │ │ │ ├── ._d │ │ │ └── subst.d │ │ │ ├── Makefile │ │ │ ├── OMakefile │ │ │ ├── README │ │ │ └── subst.ml │ ├── lib │ │ ├── ._bcdi │ │ │ └── pcre.di │ │ ├── ._d │ │ │ └── pcre.d │ │ ├── ._ncdi │ │ │ └── pcre.di │ │ ├── META │ │ ├── Makefile │ │ ├── Makefile.win32 │ │ ├── OMakefile │ │ ├── make_msvc.bat │ │ ├── pcre.ml │ │ ├── pcre.mli │ │ └── pcre_stubs.c │ └── pcre_make.win32 │ │ ├── Makefile.mingw │ │ ├── Makefile.win32 │ │ ├── make_pcre.ml │ │ └── pcre.h │ ├── pintraces │ ├── Makefile │ ├── README │ ├── cache.h │ ├── ddk-inc │ │ ├── README │ │ ├── bugcodes.h │ │ ├── dpfilter.h │ │ ├── mce.h │ │ ├── ntdef.h │ │ ├── ntiologc.h │ │ └── wdm.h │ ├── examples │ │ └── bof1 │ │ │ ├── Makefile │ │ │ └── bof1.c │ ├── gentrace.cpp │ ├── getpin.sh │ ├── iltest │ │ ├── TRACE │ │ └── test_wrapper.cpp │ ├── pivot.cpp │ ├── pivot.h │ ├── pivottest.cpp │ └── readtrace.cpp │ ├── stpwrap │ └── Makefile │ ├── tests │ └── Makefile │ ├── utils-proj.example │ ├── Makefile │ ├── README │ └── testutil.ml │ └── utils │ ├── Makefile │ ├── add.il │ ├── copy_reg.il │ ├── formula.ml │ ├── formula_add.txt │ ├── formula_copy_reg.txt │ ├── get_functions.ml │ ├── ileval.ml │ ├── iltrans.ml │ ├── split_disjunction.ml │ ├── streamtrans.ml │ ├── toil.ml │ ├── topredicate.ml │ ├── tricky.il │ └── tricky.txt ├── src ├── Makefile ├── TODO.md ├── common │ ├── Makefile │ ├── common.ml │ └── int_utils.ml ├── compile │ ├── .gitignore │ ├── Makefile │ ├── analysis.ml │ ├── llvmAst.ml │ ├── llvmAstPrinter.ml │ ├── llvmAstTranslator.ml │ ├── llvmLexer.mll │ ├── llvmParser.mly │ ├── regSets.ml │ ├── ropCodeWriter.ml │ ├── ropc.ml │ ├── roplAst.ml │ ├── roplAstRewriter.ml │ ├── roplLexer.mll │ ├── roplParser.mly │ ├── ssaForm.ml │ └── ssaFormPrinter.ml ├── dumper │ ├── Makefile │ └── dumper.ml ├── gadget │ ├── Makefile │ ├── gadget.ml │ ├── gadgetClassifier.ml │ ├── gadgetClassifierHelper.ml │ ├── gadgetFinder.ml │ └── gadgetSet.ml └── verify │ ├── Makefile │ └── verify.ml └── test ├── Makefile ├── examples-llvm ├── Makefile ├── baz.c ├── fib.c ├── foo.c ├── llvm_intrinsics.h └── trivial.c ├── examples-ropl ├── baz.ropl ├── fib.ropl ├── foo.ropl └── trivial.ropl ├── test.asm └── test.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.cmi 3 | *.cmo 4 | *.cmx 5 | *.bin 6 | a.out 7 | *.formula.txt 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ROPC-LLVM 2 | 3 | Compilador **ROPC** refactorizado y modificado para soportar un subconjunto 4 | básico del lenguaje intermedio de **LLVM**. 5 | 6 | Antes de usarlo: 7 | 8 | * Hay que compilar la libería BAP. Ver lib/bap-0.4/INSTALL para más información. 9 | * Instalar un SMT solver (STP). 10 | * Instalar clang. 11 | 12 | Para compilar un programa de prueba: 13 | 14 | $ cd src 15 | $ make 16 | $ cd ../test/examples-llvm 17 | $ make 18 | $ cd .. 19 | $ make test-llvm 20 | 21 | Luego de que un programa es *explotado*, termina en *segmentation fault*. 22 | 23 | # Advertencia 24 | 25 | Esto es un PoC, no esperar que ande sin modificaciones sobre un binario *real*. 26 | 27 | Hay algunos problemas conocidos que están comentados en el código, referirse 28 | a ellos para más información. 29 | 30 | # Más Información 31 | 32 | * README.ROPC 33 | * ROPC : http://github.com/pakt/ropc 34 | * STP : http://sourceforge.net/projects/stp-fast-prover/files/STP2/ 35 | -------------------------------------------------------------------------------- /bin/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /doc/presentation/compilador-rop.ekoparty-2013.slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/doc/presentation/compilador-rop.ekoparty-2013.slides.pdf -------------------------------------------------------------------------------- /doc/src/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/.gitignore -------------------------------------------------------------------------------- /lib/bap-0.4/AUTHORS: -------------------------------------------------------------------------------- 1 | The following currently work on BAP: 2 | Ivan Jager 3 | David Brumley 4 | Thanassis Avgerinos 5 | Edward Schwartz 6 | JongHyup Lee 7 | 8 | The original version of BAP was called VINE. VINE developers included: 9 | David Brumley 10 | Juan Caballero 11 | Cody Hartwig 12 | Ivan Jager 13 | Eric Li 14 | James Newsome 15 | Pongsin Poosankam 16 | Heng Yin 17 | -------------------------------------------------------------------------------- /lib/bap-0.4/BIGINT: -------------------------------------------------------------------------------- 1 | This version of BAP includes a stripped down version of ocaml 3.12. 2 | This is because the big int implementation in ML prior to version 3.12 3 | did not include shifts. Rather than make everyone upgrade, we'll just 4 | build the newer big int implementation and use that until most people 5 | can easily upgrade to 3.12. We also include a version of batteries 6 | that builds using this big int implementation, rather than using the 7 | user's version. 8 | 9 | We do need to keep a good chunk of the ocaml build system around. 10 | This is because the big int implementation will build optimized 11 | versions (e.g., in assembly) for different architectures. The logic 12 | for this is in the configure/Make scripts, so we can't just get rid of 13 | them entirely. -------------------------------------------------------------------------------- /lib/bap-0.4/ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/ChangeLog -------------------------------------------------------------------------------- /lib/bap-0.4/Makefile.am: -------------------------------------------------------------------------------- 1 | # Owned and copyright BitBlaze, 2007. All rights reserved. 2 | # Do not copy, disclose, or distribute without explicit written 3 | # permission. 4 | 5 | #include @top_srcdir@/config/recursive.mk 6 | 7 | if TESTS_OPT 8 | TESTPOSTDIRS=tests stpwrap 9 | endif 10 | 11 | SUBDIRS=bigint-3.12 batteries-1.4.0 ounit-1.1.0 pcre-ocaml-release-6.2.2 VEX libasmir ocaml utils $(TESTPOSTDIRS) 12 | 13 | 14 | # pintraces removed temporarily 15 | # stp/ocaml ocaml utils doc 16 | 17 | test: all 18 | $(MAKE) -C tests test 19 | 20 | cscope: 21 | cscope -b `find . -name "*.[ch]" -or -name "*.hh" -or -name "*.cc" -or -name "*.cpp"` 22 | 23 | #regression: 24 | # cd $(top_srcdir)/../regression/ocaml;./test.sh 25 | 26 | all-local: tags 27 | -------------------------------------------------------------------------------- /lib/bap-0.4/NEWS: -------------------------------------------------------------------------------- 1 | New in BAP 0.2: 2 | 3 | * Temporaries introduced in SSA can be removed when converting back to the AST. 4 | * Added constant folding and algebraic simplifications to SCCVN. 5 | * Added a simple interface in Ssa_simp to apply all safe optimizations easily. 6 | * Changed REG_{1,8,16,32,64} to Reg of int so there is less special casing. 7 | * Added Control Dependence Graphs again. 8 | * Syntax errors now include line numbers. 9 | * Added memory2array. 10 | * Makefile now recompiles utils when library changes. 11 | * Removed unneeded jump instructions when lifting code. 12 | * Fixed a problem in Cfg_ast.to_prog. 13 | * Fixed a bug in unsigned division. 14 | * Temporarily stopped using -pack to work around problems with ocamldebug. 15 | -------------------------------------------------------------------------------- /lib/bap-0.4/NOTESTS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/NOTESTS -------------------------------------------------------------------------------- /lib/bap-0.4/README: -------------------------------------------------------------------------------- 1 | BAP: The Binary Analysis Platform. For more information see our 2 | project webpage via http://bap.ece.cmu.edu/ 3 | 4 | For installation instruction see the INSTALL file. 5 | 6 | For copyright information see the COPYING file. 7 | 8 | 9 | This is a pre-alpha release. It is completely unsupported. If you need help, 10 | this is not for you; please wait for a later version or learn some problem 11 | solving skills. If you find a bug, please submit patches to 12 | https://kestrel.ece.cmu.edu/bugzilla/ 13 | -------------------------------------------------------------------------------- /lib/bap-0.4/STYLE.C: -------------------------------------------------------------------------------- 1 | For our C code, we use K&R style. 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/TAGS: -------------------------------------------------------------------------------- 1 | 2 | /home/p/ropc-repo/bap-0.4/libasmir/TAGS,include 3 | 4 | /home/p/ropc-repo/bap-0.4/ocaml/TAGS,include 5 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/BAP.README: -------------------------------------------------------------------------------- 1 | This is VEX version 2199 with the patch bap_patch_20110908.patch applied. Also, Makefile is a copy of Makefil-gcc with "-fPIC" added to the CFLAGS. -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/HACKING.README: -------------------------------------------------------------------------------- 1 | 2 | This directory and its children contain LibVEX, a library for dynamic 3 | binary instrumentation and translation. See LICENSE.README for 4 | licensing and contribution information. 5 | 6 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/LICENSE.README: -------------------------------------------------------------------------------- 1 | 2 | This directory and its children contain LibVEX, a library for dynamic 3 | binary instrumentation and translation. 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 | 02110-1301, USA. 19 | 20 | The GNU General Public License is contained in the file LICENSE.GPL. 21 | 22 | If you want to contribute code to LibVEX, please ensure it is licensed 23 | as "GPL v2 or later". 24 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/nanoarm.orig: -------------------------------------------------------------------------------- 1 | 0: e1a0c00d mov ip, sp 2 | . 0 00008000 4 3 | . 0d c0 a0 e1 4 | 5 | 4: e92dd810 stmdb sp!, {r4, fp, ip, lr, pc} 6 | . 1 00008004 4 7 | . 10 d8 2d e9 8 | 9 | 8: e24cb004 sub fp, ip, #4 ; 0x4 10 | . 2 00008008 4 11 | . 04 b0 4c e2 12 | 13 | c: e3a00014 mov r0, #20 ; 0x14 14 | . 3 0000800C 4 15 | . 14 00 a0 e3 16 | 17 | 10: ebfffffe bl 0 18 | . 4 00008010 4 19 | . fe ff ff eb 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/newline.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/orig_amd64/SortedToOrig.hs: -------------------------------------------------------------------------------- 1 | 2 | module Main where 3 | 4 | main 5 | = do x1 <- readFile "test2.sorted" 6 | let x2 = lines x1 7 | x3 = zip [1 ..] x2 8 | x4 = concat (map qq x3) 9 | --putStr x4 10 | writeFile "test2.orig" x4 11 | 12 | 13 | qq :: (Int, String) -> String 14 | qq (n, s0) 15 | = let ws = words s0 16 | bytes = head ws 17 | rest = unwords (tail ws) 18 | bytes2 = foo bytes 19 | in 20 | unlines [ 21 | "", 22 | rest, 23 | ". " ++ show n ++ " 0x12345678 " ++ show (1 + (length bytes `div` 2)), 24 | ". " ++ bytes2 ++ "C3" 25 | ] 26 | 27 | 28 | foo [] = [] 29 | foo (x:y:rest) = x:y:' ':foo rest 30 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/orig_arm/nanoarm: -------------------------------------------------------------------------------- 1 | 0: e1a0c00d mov ip, sp 2 | 4: e92dd810 stmdb sp!, {r4, fp, ip, lr, pc} 3 | 8: e24cb004 sub fp, ip, #5 ; 0x4 4 | c: e3a00014 mov r0, #20 ; 0x14 5 | 10: ebfffffe bl 0 6 | . 0 00008000 20 7 | . 0d c0 a0 e1 10 d8 2d e9 05 b0 4c e2 14 00 a0 e3 fe ff ff eb 8 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/orig_arm/nanoarm.orig: -------------------------------------------------------------------------------- 1 | 0: e1a0c00d mov ip, sp 2 | . 0 00008000 4 3 | . 0d c0 a0 e1 4 | 5 | 4: e92dd810 stmdb sp!, {r4, fp, ip, lr, pc} 6 | . 1 00008004 4 7 | . 10 d8 2d e9 8 | 9 | 8: e24cb004 sub fp, ip, #4 ; 0x4 10 | . 2 00008008 4 11 | . 04 b0 4c e2 12 | 13 | c: e3a00014 mov r0, #20 ; 0x14 14 | . 3 0000800C 4 15 | . 14 00 a0 e3 16 | 17 | 10: ebfffffe bl 0 18 | . 4 00008010 4 19 | . fe ff ff eb 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/quote.txt: -------------------------------------------------------------------------------- 1 | " -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/switchback/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: switchback.c linker.c linker.h 3 | gcc -m64 -Wall -O -g -o switchback switchback.c linker.c ../libvex_ppc64_linux.a 4 | # gcc -Wall -O -g -o switchback switchback.c linker.c ../libvex.a 5 | 6 | test_ppc: 7 | gcc -Wall -m64 -mregnames -O -c test_ppc_jm1.c 8 | 9 | clean: 10 | rm -f switchback switchback.o linker.o 11 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/switchback/linker.h: -------------------------------------------------------------------------------- 1 | 2 | extern 3 | void* linker_top_level_LINK ( int n_object_names, char** object_names ); 4 | 5 | extern void* mymalloc ( int ); 6 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/switchback/test_hello.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | static void bar ( void*(*service)(int,int) ) 4 | { 5 | int i; 6 | for (i = 0; i < 100000; i++) ; 7 | service(1, 'h'); 8 | service(1, 'e'); 9 | service(1, 'l'); 10 | service(1, 'l'); 11 | service(1, 'o'); 12 | service(1, '\n'); 13 | } 14 | 15 | void entry ( void*(*service)(int,int) ) 16 | { 17 | bar(service); 18 | service(0,0); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/switchback/test_simple.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | static void bar ( void*(*service)(int,int) ) 4 | { 5 | __asm__ __volatile__ ("addi 17, 14, 5"); 6 | } 7 | 8 | void entry ( void*(*service)(int,int) ) 9 | { 10 | bar(service); 11 | service(0,0); 12 | } 13 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test/fldenv.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | void do_fstenv ( void* p ) 6 | { 7 | asm("movl 8(%esp), %eax ; fstenv (%eax)"); 8 | } 9 | 10 | void do_fldenv ( void* p ) 11 | { 12 | asm("movl 8(%esp), %eax ; fldenv (%eax)"); 13 | } 14 | 15 | int main ( void ) 16 | { 17 | int i; 18 | unsigned short* buf = malloc(14*sizeof(short)); 19 | for (i = 0; i < 14; i++) 20 | buf[i] = i; 21 | buf[0] = 0x037f; 22 | 23 | do_fldenv(buf); 24 | do_fstenv(buf); 25 | for (i = 0; i < 14; i++) { 26 | printf("%04x ", buf[i]); 27 | if (i > 0 && ((i % 12) == 11)) 28 | printf("\n"); 29 | } 30 | printf("\n"); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test/fp1.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | double a[10]; 5 | 6 | int main ( void ) 7 | { 8 | int i; 9 | double s; 10 | for (i = 0; i < 10; i++) 11 | a[i] = 11.11 * i; 12 | s = 0.0; 13 | for (i = 0; i < 10; i++) 14 | s += a[i]; 15 | printf("result = %f\n", s); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test/fp1.s: -------------------------------------------------------------------------------- 1 | .file "fp1.c" 2 | .version "01.01" 3 | gcc2_compiled.: 4 | .section .rodata.str1.1,"aMS",@progbits,1 5 | .LC2: 6 | .string "result = %f\n" 7 | .section .rodata.cst8,"aM",@progbits,8 8 | .align 8 9 | .LC0: 10 | .long 0xeb851eb8,0x40263851 11 | .text 12 | .align 4 13 | .globl main 14 | .type main,@function 15 | main: 16 | pushl %ebp 17 | movl %esp, %ebp 18 | subl $8, %esp 19 | movl $0, %eax 20 | movl $a, %edx 21 | fldl .LC0 22 | .p2align 2 23 | .L21: 24 | fld %st(0) 25 | pushl %eax 26 | fimull (%esp) 27 | popl %eax 28 | fstpl (%edx,%eax,8) 29 | incl %eax 30 | cmpl $9, %eax 31 | jle .L21 32 | fstp %st(0) 33 | fldz 34 | movl $0, %eax 35 | movl $a, %edx 36 | .p2align 2 37 | .L26: 38 | faddl (%edx,%eax,8) 39 | incl %eax 40 | cmpl $9, %eax 41 | jle .L26 42 | subl $12, %esp 43 | fstpl (%esp) 44 | pushl $.LC2 45 | call printf 46 | movl $0, %eax 47 | leave 48 | ret 49 | .Lfe1: 50 | .size main,.Lfe1-main 51 | .comm a,80,32 52 | .ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.3 2.96-110)" 53 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test/fpspeed.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | int main ( void ) 7 | { 8 | int i, j; 9 | double s, r; 10 | s = 0.0; 11 | double* a1 = malloc(1000 * sizeof(double)); 12 | double* a2 = malloc(1000 * sizeof(double)); 13 | for (i = 0; i < 1000; i++) { 14 | a1[i] = s; 15 | s += 0.3374893482232; 16 | a2[i] = s; 17 | } 18 | 19 | s = 0.0; 20 | r = 0.0; 21 | for (j = 0; j < 5000; j++) { 22 | for (i = 0; i < 1000; i++) { 23 | s += (a1[i] - a2[i]) * (a1[i] + a2[i]) - sqrt(r + 1.0); 24 | r += 0.001; 25 | } 26 | } 27 | printf("s = %f, r = %f\n", s, r ); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test/fpucw.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void fldcw_default ( void ) 5 | { 6 | asm(" pushw $0x037F ; fldcw (%esp) ; addl $2, %esp"); 7 | } 8 | 9 | void fldcw_exns ( void ) 10 | { 11 | asm(" pushw $0x037E ; fldcw (%esp) ; addl $2, %esp"); 12 | } 13 | 14 | void fldcw_precision ( void ) 15 | { 16 | asm(" pushw $0x007F ; fldcw (%esp) ; addl $2, %esp"); 17 | } 18 | 19 | void fldcw_rounding ( void ) 20 | { 21 | asm(" pushw $0x077F ; fldcw (%esp) ; addl $2, %esp"); 22 | } 23 | 24 | int main ( void ) 25 | { 26 | printf("default\n"); 27 | fldcw_default(); 28 | printf("\n"); 29 | 30 | printf("exns\n"); 31 | fldcw_exns(); 32 | printf("\n"); 33 | 34 | printf("precision\n"); 35 | fldcw_precision(); 36 | printf("\n"); 37 | 38 | printf("rounding\n"); 39 | fldcw_rounding(); 40 | printf("\n"); 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test/fstenv.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | void do_fstenv ( void* p ) 6 | { 7 | asm("fldpi ; fld1; fldln2 ; movl 8(%esp), %eax ; fstenv (%eax)"); 8 | } 9 | 10 | int main ( void ) 11 | { 12 | int i; 13 | unsigned int* buf = malloc(7*sizeof(int)); 14 | do_fstenv(buf); 15 | for (i = 0; i < 7; i++) { 16 | printf("%08x ", buf[i]); 17 | if (i > 0 && ((i % 6) == 5)) 18 | printf("\n"); 19 | } 20 | printf("\n"); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test/mxcsr.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void mxcsr_default ( void ) 5 | { 6 | asm(" pushl $0x1F80 ; ldmxcsr (%esp) ; addl $4, %esp"); 7 | } 8 | 9 | void mxcsr_exns ( void ) 10 | { 11 | asm(" pushl $0x1F00 ; ldmxcsr (%esp) ; addl $4, %esp"); 12 | } 13 | 14 | /* PIII doesn't have DAZ, so this segfaults (!) on PIII. */a 15 | void mxcsr_daz ( void ) 16 | { 17 | asm(" pushl $0x1FC0 ; ldmxcsr (%esp) ; addl $4, %esp"); 18 | } 19 | 20 | void mxcsr_fz ( void ) 21 | { 22 | asm(" pushl $0x9F80 ; ldmxcsr (%esp) ; addl $4, %esp"); 23 | } 24 | 25 | 26 | int main ( void ) 27 | { 28 | printf("default\n"); 29 | mxcsr_default(); 30 | printf("\n"); 31 | 32 | printf("exns\n"); 33 | mxcsr_exns(); 34 | printf("\n"); 35 | 36 | printf("daz\n"); 37 | mxcsr_daz(); 38 | printf("\n"); 39 | 40 | printf("fz\n"); 41 | mxcsr_fz(); 42 | printf("\n"); 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test/x87fxam.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | double d; 6 | int i; 7 | 8 | extern void do_fxam ( void ); 9 | 10 | asm( 11 | "\n" 12 | "do_fxam:\n" 13 | "\txorl %eax,%eax\n" 14 | "\tfld d\n" 15 | "\tfxam\n" 16 | "\tfnstsw %ax\n" 17 | "\tffree %st(0)\n" 18 | "\tmovl %eax, i\n" 19 | "\tret\n" 20 | ); 21 | 22 | 23 | double inf ( void ) { return 1.0 / 0.0; } 24 | double nAn ( void ) { return 0.0 / 0.0; } 25 | double den ( void ) { return 9.1e-220 / 1e100; } 26 | 27 | /* Try positive and negative variants of: zero, infinity, 28 | nAn, and denorm */ 29 | 30 | int main ( void ) 31 | { 32 | d = 0.0; do_fxam(); printf("0x%4x: %f\n", i, d ); 33 | d = -0.0; do_fxam(); printf("0x%4x: %f\n", i, d ); 34 | 35 | d = inf(); do_fxam(); printf("0x%4x: %f\n", i, d ); 36 | d = -inf(); do_fxam(); printf("0x%4x: %f\n", i, d ); 37 | 38 | d = nAn(); do_fxam(); printf("0x%4x: %f\n", i, d ); 39 | d = -nAn(); do_fxam(); printf("0x%4x: %f\n", i, d ); 40 | 41 | d = den(); do_fxam(); printf("0x%4x: %f\n", i, d ); 42 | d = -den(); do_fxam(); printf("0x%4x: %f\n", i, d ); 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test/x87tst.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | double d; 6 | int i; 7 | 8 | extern void do_tst ( void ); 9 | 10 | asm( 11 | "\n" 12 | "do_tst:\n" 13 | "\txorl %eax,%eax\n" 14 | "\tfld d\n" 15 | "\tftst\n" 16 | "\tfnstsw %ax\n" 17 | "\tmovl %eax, i\n" 18 | "\tret\n" 19 | ); 20 | 21 | int main ( void ) 22 | { 23 | d = -1.23; do_tst(); printf("%f -> 0x%x\n", d, i ); 24 | d = 0.0; do_tst(); printf("%f -> 0x%x\n", d, i ); 25 | d = 9.87; do_tst(); printf("%f -> 0x%x\n", d, i ); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test_main.h: -------------------------------------------------------------------------------- 1 | 2 | /* Copy this file (test_main.h.in) to test_main.h, and edit */ 3 | 4 | /* DEBUG RUN, ON V */ 5 | #if 0 6 | #define TEST_VSUPPORT True 7 | #define TEST_N_ITERS 1 8 | #define TEST_N_BBS 1 9 | #define TEST_FLAGS (1<<7) /* |(1<<2)|(1<<1) */ 10 | #endif 11 | 12 | /* CHECKING RUN, ON V */ 13 | #if 1 14 | #define TEST_VSUPPORT True 15 | #define TEST_N_ITERS 1 16 | #define TEST_N_BBS 100000 17 | #define TEST_FLAGS 0 18 | #endif 19 | 20 | /* PROFILING RUN, NATIVE */ 21 | #if 0 22 | #define TEST_VSUPPORT False 23 | #define TEST_N_ITERS 100 24 | #define TEST_N_BBS 1000 25 | #define TEST_FLAGS 0 26 | #endif 27 | 28 | /* PROFILING RUN, REDUCED WORKLOAD */ 29 | #if 0 30 | #define TEST_VSUPPORT False 31 | #define TEST_N_ITERS 3 32 | #define TEST_N_BBS 1000 33 | #define TEST_FLAGS 0 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/test_main.h.base: -------------------------------------------------------------------------------- 1 | 2 | /* Copy this file (test_main.h.in) to test_main.h, and edit */ 3 | 4 | /* DEBUG RUN, ON V */ 5 | #if 1 6 | #define TEST_VSUPPORT True 7 | #define TEST_N_ITERS 1 8 | #define TEST_N_BBS 1 9 | #define TEST_FLAGS (1<<7) 10 | #endif 11 | 12 | /* CHECKING RUN, ON V */ 13 | #if 0 14 | #define TEST_VSUPPORT True 15 | #define TEST_N_ITERS 1 16 | #define TEST_N_BBS 100000 17 | #define TEST_FLAGS 0 18 | #endif 19 | 20 | /* PROFILING RUN, NATIVE */ 21 | #if 0 22 | #define TEST_VSUPPORT False 23 | #define TEST_N_ITERS 100 24 | #define TEST_N_BBS 1000 25 | #define TEST_FLAGS 0 26 | #endif 27 | 28 | /* PROFILING RUN, REDUCED WORKLOAD */ 29 | #if 0 30 | #define TEST_VSUPPORT False 31 | #define TEST_N_ITERS 3 32 | #define TEST_N_BBS 1000 33 | #define TEST_FLAGS 0 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/useful/fpround.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main ( void ) 5 | { 6 | double d = 0.0; 7 | int i; 8 | for (i = 0; i < 30; i++) { 9 | printf("i = %d, d = %f, (int)d = %d\n", i, d, (int)d); 10 | d += 0.11; 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/useful/fspill.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | double qq ( void ) 5 | {int i; 6 | long double a = 0.0, b = 0.0, c = 0.0, d = 0.0, e = 0.0, f = 0.0, g = 0.0, h = 0.0; 7 | for (i = 0; i < 10; i++) { 8 | a += 1.1; b += 1.2; c += 1.3; d += 1.4; e += 1.5; f += 1.6; 9 | g += 1.7; h += 1.8001; 10 | } 11 | return a+b+c+d+e+f+g+h; 12 | } 13 | 14 | int main ( void ) 15 | { 16 | double r = qq(); 17 | printf("answer is %f %d\n", r, (int)r ); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/VEX/useful/gradual_underflow.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main ( void ) 5 | { 6 | double d = 7.25063790881233303e-303; 7 | int i; 8 | 9 | for (i = 0; i < 26; i++) { 10 | printf("%.16e\n", d); 11 | d *= 0.1012198489248992489422; 12 | } 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /lib/bap-0.4/autogen.sh: -------------------------------------------------------------------------------- 1 | aclocal 2 | autoconf 3 | autoheader 4 | automake --add-missing --copy 5 | -------------------------------------------------------------------------------- /lib/bap-0.4/autom4te.cache/output.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/autom4te.cache/output.0 -------------------------------------------------------------------------------- /lib/bap-0.4/autom4te.cache/output.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/autom4te.cache/output.1 -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | _build 3 | build/META 4 | build/make_suite 5 | src/batteries_config.ml 6 | doc/batteries/html/api/ 7 | hdoc/* 8 | man/* 9 | *.byte 10 | *.native 11 | /.omake* 12 | *.swp 13 | *.opt 14 | *.run 15 | apidocs 16 | batteries.docdir 17 | qtest/*_t.ml 18 | qtest/test_mods.mllib 19 | src/batCamomile.ml 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/ChangeLog: -------------------------------------------------------------------------------- 1 | Look in git log for list of changes 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/README: -------------------------------------------------------------------------------- 1 | See README.md 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/README.folders: -------------------------------------------------------------------------------- 1 | The following directories contain: 2 | 3 | * build/ various (old) files needed for building 4 | * examples/ example files showing how to use various features of batteries 5 | * apidocs/ the html documentation 6 | * src/ the core of Batteries Included, all the batFoo modules 7 | * src/syntax/ several syntax extensions for OCaml 8 | * testsuite/ a minimal testsuite for batteries 9 | 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/VERSION: -------------------------------------------------------------------------------- 1 | 1.4.0 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/_oasis: -------------------------------------------------------------------------------- 1 | OASISFormat: 0.2 2 | OCamlVersion: >= 3.11.0 3 | Name: batteries 4 | Version: 1.4.0 5 | Authors: Batteries Included Team 6 | License: LGPL-2.1 with OCaml linking exception 7 | LicenseFile: LICENSE 8 | BuildType: custom (0.2) 9 | InstallType: custom (0.2) 10 | BuildTools: make 11 | Synopsis: Extended OCaml Standard Library 12 | 13 | BuildDepends: camomile (>= 0.7.0) 14 | XCustomBuild: $make all 15 | XCustomInstall: $make install 16 | XCustomUninstall: $make uninstall 17 | 18 | Document manual 19 | Type: custom (0.2) 20 | Title: Ocaml Batteries Documentation 21 | XCustom: $make doc 22 | 23 | Test main 24 | Type: custom (0.2) 25 | Command: $make test 26 | 27 | SourceRepository master 28 | Type: git 29 | Location: git://github.com/ocaml-batteries-team/batteries-included.git 30 | Branch: master 31 | Browser: https://github.com/ocaml-batteries-team/batteries-included 32 | 33 | Library "batteries" 34 | Path: src/ 35 | 36 | Library "estring" 37 | Path: libs/estring/ 38 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/_tags: -------------------------------------------------------------------------------- 1 | <**/*.ml> : annot 2 | "build": include 3 | "src": include 4 | "libs" or "libs/estring": include 5 | "testsuite": include 6 | "qtest": include 7 | "benchsuite": include 8 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/batteries.odocl: -------------------------------------------------------------------------------- 1 | src/batteries.mllib -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/benchsuite/README: -------------------------------------------------------------------------------- 1 | The purpose of this directory is to provide performance evaluations of 2 | Batteries functions implementations. This is specially useful when 3 | testing changes against an upstream library such as INRIA's stdlib or 4 | Extlib. 5 | The benchmarks rely on the Ocaml [benchmark] library. 6 | 7 | [benchmark] http://ocaml-benchmark.sourceforge.net/ -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/benchsuite/_tags: -------------------------------------------------------------------------------- 1 | <*>: pkg_benchmark 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/benchsuite/grouping.ml: -------------------------------------------------------------------------------- 1 | let rec makeintervals_aux d lo hi acc = function 2 | | [] -> List.rev ((lo,hi)::acc) 3 | | h::t when h > hi+d -> makeintervals_aux d h h ((lo,hi)::acc) t 4 | | h::t (* h <= lim *) -> makeintervals_aux d lo h acc t 5 | 6 | let make_intervals d = function 7 | | [] -> [] 8 | | h::t -> makeintervals_aux d h h [] t 9 | 10 | let makeIntervals d = 11 | let merge ((start,stop) :: tail as s) num = 12 | if abs(num-stop) <= d then 13 | (start,num) :: tail 14 | else 15 | (num,num) :: s 16 | in 17 | function 18 | | [] -> [] 19 | | head :: tail -> List.fold_left merge [(head,head)] tail 20 | 21 | let g = [1;3;5;9;12;13;14] 22 | 23 | let tests = [ "fsharp", makeIntervals 2, g; 24 | "ocaml", make_intervals 2, g; 25 | ] 26 | 27 | open Benchmark 28 | 29 | let () = tabulate (latencyN 50_000_000L tests) 30 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/build/README: -------------------------------------------------------------------------------- 1 | This directory contains tools used during the compilation 2 | of Batteries Included. 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/build/camlzip/META: -------------------------------------------------------------------------------- 1 | name="zip" 2 | version="1.03" 3 | description="reading and writing ZIP, JAR and GZIP files" 4 | requires="unix" 5 | archive(byte)="zip.cma" 6 | archive(native)="zip.cmxa" 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/build/import.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Placeholder for a future tool. 3 | 4 | This tool will import a set of interfaces from a library for quick 5 | initialization of layer code. 6 | *) 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/build/optcomp/META: -------------------------------------------------------------------------------- 1 | # -*- conf-mode -*- 2 | name = "optcomp" 3 | version = "1.1" 4 | description = "Optional compilation with cpp-like directives" 5 | requires = "camlp4" 6 | archive(syntax, preprocessor) = "pa_optcomp.cmo" 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/build/optcomp/_tags: -------------------------------------------------------------------------------- 1 | <*>:camlp4of,use_camlp4_full 2 | : use_dynlink 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/build/optcomp/optcomp_o.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * optcomp_o.ml 3 | * ------------ 4 | * Copyright : (c) 2009, Jeremie Dimino 5 | * Licence : BSD3 6 | *) 7 | 8 | (* Standalone version, original syntax *) 9 | 10 | let module M = Camlp4OCamlParser.Make(Camlp4OCamlRevisedParser.Make(Camlp4.PreCast.Syntax)) in () 11 | 12 | let _ = Optcomp.main () 13 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/build/optcomp/optcomp_r.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * optcomp_r.ml 3 | * ------------ 4 | * Copyright : (c) 2009, Jeremie Dimino 5 | * Licence : BSD3 6 | *) 7 | 8 | (* Standalone version, revised syntax *) 9 | 10 | let module M = Camlp4OCamlRevisedParser.Make(Camlp4.PreCast.Syntax) in () 11 | 12 | let _ = Optcomp.main () 13 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/build/optcomp/sample_incl.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * sample_incl.ml 3 | * -------------- 4 | * Copyright : (c) 2009, Jeremie Dimino 5 | * Licence : BSD3 6 | * 7 | * This file is a part of optcomp. 8 | *) 9 | 10 | (* File included by "sample.ml" *) 11 | 12 | #let x = 1 13 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/build/preprocess_mli/_tags: -------------------------------------------------------------------------------- 1 | <*>:camlp4oof,use_camlp4_full,use_ocamlbuild -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/byte.itarget: -------------------------------------------------------------------------------- 1 | src/batteries_uni.cma 2 | src/batteries.cma 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/doc/batteries/documentation.idex: -------------------------------------------------------------------------------- 1 | attributes html/api/attributes.idex 2 | values html/api/values.idex 3 | types html/api/types.idex 4 | modules html/api/modules.idex 5 | modtypes html/api/module_types.idex 6 | exceptions html/api/exceptions.idex 7 | classes html/api/classes.idex 8 | methods html/api/methods.idex 9 | class_types html/api/class_types.idex 10 | language language.idex 11 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/doc/batteries/html/batteries_large.png: -------------------------------------------------------------------------------- 1 | ../../batteries_large.png -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/doc/batteries/html/tutorial.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | OCaml Batteries Included 9 | 10 | 11 |

Starting with OCaml Batteries Included

12 |

Installation

13 |

14 | Several methods exist for installing OCaml Batteries Included: 15 |

16 |
    17 |
  • The GODI package manager is rather complicated to install for the first time 18 | but is then quite simple to use. It works under any version of Unix, including 19 | Linux, MacOS X, BSD, ...
  • 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/doc/batteries/language.idex: -------------------------------------------------------------------------------- 1 | "the tutorial": "http://www.cs.jhu.edu/~scott/pl/lectures/caml-intro.html" 2 | "The tutorial": "http://www.cs.jhu.edu/~scott/pl/lectures/caml-intro.html" 3 | "The Tutorial": "http://www.cs.jhu.edu/~scott/pl/lectures/caml-intro.html" 4 | "For programmers": "http://www.ocaml-tutorial.org" 5 | "for programmers": "http://www.ocaml-tutorial.org" 6 | "directives": "html/toplevel.html#directives" 7 | "batteries": "html/index.html" 8 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/doc/batteries_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/batteries-1.4.0/doc/batteries_large.png -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/doc/external_site_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/batteries-1.4.0/doc/external_site_icon.gif -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/README: -------------------------------------------------------------------------------- 1 | A few examples of short programs written using OCaml Batteries Included. 2 | 3 | Directory tools/ contains small tools. 4 | Directory snippets/ contains random code extracts. 5 | Directory euler/ contains solution programs to varous eulerproject.com puzzles 6 | Directory pleac/ contains the start of a PLEAC for batteries 7 | 8 | To build all these programs, install batteries and run 9 | 10 | make 11 | 12 | from each directory. If this doesn't work, steal the makefile, _tags 13 | and myocamlbuild from another example directory, make them work for 14 | the files in the new directory and send us the patch. :) Extra points 15 | for implementing a toplevel `make examples` that makes the examples. 16 | 17 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/_tags: -------------------------------------------------------------------------------- 1 | 2 | : pkg_netstring 3 | : thread 4 | 5 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/benchmark/_tags: -------------------------------------------------------------------------------- 1 | : pkg_bitstring 2 | : pkg_batteries,pkg_core,debug,pkg_threads,pkg_benchmark 3 | : pkg_batteries,pkg_core,pkg_threads 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/benchmark/run_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ocamlbuild t_list.byte 4 | 5 | TESTS="nth map mapx folr folrx map2" 6 | for a in byte 7 | do 8 | for b in $TESTS 9 | do 10 | # echo -n ${b}_g.$a, 11 | ./t_list.$a -s 200 ${b}_g | tee data/${b}_gallium.$a 12 | # echo -n ${b}_e.$a, 13 | ./t_list.$a -s 200 ${b}_e | tee data/${b}_extlib.$a 14 | done 15 | done 16 | 17 | cd data 18 | 19 | for a in byte 20 | do 21 | for b in $TESTS 22 | do 23 | G_PRE="set logscale x; set logscale y; set terminal png; set xlabel \"List Length\"; set ylabel \"actions per second\";" 24 | echo "$G_PRE set output \"$b.$a.png\"; plot \"${b}_extlib.$a\" w lp, \"${b}_gallium.$a\" w lp" | gnuplot 25 | done 26 | done -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/euler/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean 2 | 3 | SOURCES = $(wildcard euler*.ml) 4 | TARGETS = $(SOURCES:.ml=.byte) 5 | LIBRARIES = mathlib.ml 6 | 7 | all: $(TARGETS) 8 | 9 | clean: 10 | rm *.byte *.native *.cmi *.cmo 11 | 12 | %.byte: $(LIBRARIES) %.ml 13 | ocamlfind ocamlc -thread -package threads,batteries -linkpkg $^ -o $@ 14 | 15 | %.native: $(LIBRARIES) %.ml 16 | ocamlfind ocamlc -thread -package threads,batteries -linkpkg $^ -o $@ -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/euler/euler001.ml: -------------------------------------------------------------------------------- 1 | open Batteries 2 | open Enum 3 | 4 | let say e = e |> map string_of_int |> print ~last:"\n" IO.nwrite stdout 5 | let print_sum e = e |> reduce (+) |> string_of_int |> print_endline 6 | 7 | let top = 999 8 | 9 | let () = 10 | (1 -- top) 11 | |> filter (fun x -> x mod 3 = 0 or x mod 5 = 0) 12 | |> print_sum 13 | 14 | let () = 15 | let mul3 = (1 -- (top / 3)) |> map ( ( * ) 3) 16 | and mul5 = (1 -- (top / 5)) |> map ( ( * ) 5) 17 | in 18 | (* say (clone mul3); 19 | say (clone mul5); *) 20 | merge (<) mul3 mul5 |> uniq |> print_sum 21 | 22 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/euler/euler009.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | let max_search = 100 in 3 | for n = 1 to max_search do 4 | for m = n+1 to max_search do 5 | let a = 2 * m * n 6 | and b = m * m - n * n 7 | and c = m * m + n * n 8 | in 9 | let s = a + b + c in 10 | if 1000 mod s = 0 then 11 | let m = (1000 / s) in 12 | Printf.printf "mult: %d\n" m; 13 | Printf.printf "a: %d b: %d c: %d\n" (a*m) (b*m) (c*m); 14 | print_int (a * b * c * m * m * m); print_newline (); 15 | exit 0 16 | done; 17 | done 18 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/euler/euler010.ml: -------------------------------------------------------------------------------- 1 | open Batteries 2 | open Enum 3 | 4 | let max_val = 2_000_000 5 | let max_test = max_val |> float |> sqrt |> Float.to_int 6 | 7 | let () = 8 | let primes = ref (2--max_val) in 9 | let s = ref 0 in 10 | let rec loop () = 11 | match get !primes with 12 | | None -> print_int !s; print_newline () 13 | | Some p -> 14 | s := !s + p; 15 | if p < max_test then 16 | primes := !primes // (fun x -> x mod p != 0); (* damn inefficient *) 17 | loop() 18 | in 19 | loop () 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/euler/euler012.ml: -------------------------------------------------------------------------------- 1 | open Batteries 2 | let num_div x = 3 | let count = ref 1 in (* already counted 1 *) 4 | let max_test = x |> float |> sqrt |> Float.to_int in 5 | for i = 2 to max_test do 6 | if x mod i = 0 then incr count 7 | done; 8 | count := !count * 2; (* every factor < max_test has a corresponding one > *) 9 | if x mod max_test = 0 then decr count; (* dont double count root if x square *) 10 | !count 11 | 12 | let rec loop i n = 13 | let d = num_div n in 14 | if d > 500 then begin 15 | print_int n; print_newline(); exit 0 16 | end else loop (i+1) (n+i+1) 17 | 18 | let () = loop 1 1 19 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/euler/euler014.ml: -------------------------------------------------------------------------------- 1 | let rec seq i = function 2 | 1 -> i 3 | | n when n land 1 = 0 -> seq (i+1) (n asr 1) 4 | | n (* odd *) -> seq (i+1) (3*n+1) 5 | 6 | let () = 7 | let best_i = ref 1 8 | and best_n0 = ref 1 in 9 | for n = 1 to 1_000_000 do 10 | let i = seq 1 n in 11 | if i > !best_i then 12 | ( best_i := i; best_n0 := n ); 13 | done; 14 | print_int !best_n0; print_newline () 15 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/euler/euler021.ml: -------------------------------------------------------------------------------- 1 | open Batteries 2 | let d n = Mathlib.sum_factors n 3 | 4 | module ISet = Set.Make(Int) 5 | 6 | let ret_amicable ~upto = 7 | let is_amic = ref ISet.empty 8 | and not_amic = ref ISet.empty 9 | and to_test = ref ((2--upto) |> ISet.of_enum) 10 | in 11 | let rec test n = (* cleanup - ugly code *) 12 | if n >= upto then () 13 | else if ISet.mem n !is_amic 14 | || ISet.mem n !not_amic then 15 | () 16 | else 17 | let dn = d n in 18 | if dn >= upto || dn = n then 19 | not_amic := !not_amic |> ISet.add n 20 | else 21 | let ddn = d dn in 22 | if n = ddn then 23 | is_amic := !is_amic |> ISet.add n |> ISet.add dn 24 | else 25 | not_amic := !not_amic |> ISet.add n 26 | in 27 | while not (ISet.is_empty !to_test) do 28 | let n = ISet.choose !to_test in 29 | to_test := !to_test |> ISet.remove n; 30 | test n 31 | done; 32 | ISet.enum !is_amic 33 | 34 | let print_int_enum e = Enum.print (fun stdout n -> IO.nwrite stdout (string_of_int n)) stdout e 35 | 36 | let () = 37 | ret_amicable ~upto:10_000 |> Enum.reduce (+) |> print_int; 38 | print_newline();; 39 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/euler/euler022.ml: -------------------------------------------------------------------------------- 1 | (* uses names.txt *) 2 | 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/euler/euler023.ml: -------------------------------------------------------------------------------- 1 | open Batteries 2 | open List 3 | 4 | let is_abundant n = n < Mathlib.sum_factors n 5 | 6 | let max_sum = if Array.length Sys.argv > 1 7 | then int_of_string Sys.argv.(1) else 28123 8 | 9 | let () = 10 | let x = BitSet.create_full max_sum in 11 | let found = RefList.empty () in 12 | for i = 12 to max_sum do 13 | if is_abundant i then begin 14 | RefList.push found i; 15 | RefList.iter (fun j -> BitSet.unset x (i+j)) found; 16 | end 17 | done; 18 | 19 | BitSet.enum x 20 | |> Enum.reduce (+) |> print_int; 21 | 22 | print_newline () 23 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/euler/euler024.ml: -------------------------------------------------------------------------------- 1 | open Batteries 2 | open Mathlib 3 | 4 | let pos = 1_000_000 5 | 6 | let tokens = [0;1;2;3;4;5;6;7;8;9] 7 | 8 | let rec permute tokens acc pos = 9 | match tokens with 10 | [] -> List.rev (acc) 11 | | [x] -> List.rev (x :: acc) 12 | | t -> 13 | let len = List.length t in 14 | let sub_count = factorial (len-1) in 15 | let token_pos = pos / sub_count 16 | and next_pos = pos mod sub_count in 17 | let found = List.at t token_pos in 18 | Printf.printf "subperm %d: %d (pos %d clust %d) next: %d\n" pos found token_pos sub_count next_pos; 19 | permute (List.remove t found) (found::acc) next_pos 20 | 21 | let () = 22 | permute tokens [] (pos-1) |> List.iter (fun i -> print_int i); 23 | print_newline() 24 | 25 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/snippets/_tags: -------------------------------------------------------------------------------- 1 | <*>: pkg_batteries, syntax_camlp4o, pkg_batteries.syntax, debug 2 | : pkg_netstring 3 | : thread -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/snippets/accumulator.ml: -------------------------------------------------------------------------------- 1 | (*A problem I found some time ago on Paul Graham's website. 2 | 3 | "Revenge of the Nerds yielded a collection of canonical solutions to 4 | the same problem in a number of languages. 5 | 6 | The problem: Write a function foo that takes a number n and returns a 7 | function that takes a number i, and returns n incremented by i. 8 | 9 | Note: (a) that's number, not integer, (b) that's incremented by, not plus." 10 | 11 | Solutions in other languages are available at 12 | http://www.paulgraham.com/accgen.html 13 | *) 14 | 15 | 16 | (** [adder t n] is an adder for elements of [numeric] typeclass [t], 17 | initialized with [n]*) 18 | let adder t n i = 19 | open Numeric in 20 | Ref.post r (t.add i) 21 | where r = ref n 22 | 23 | (*Examples:*) 24 | let adder_of_floats : float -> float = 25 | adder Float.operations 5. 26 | 27 | let adder_of_ints : int -> int = 28 | adder Int.operations 5 29 | 30 | let adder_of_complexes: Complex.t -> Complex.t = 31 | adder Complex.operations Complex.i 32 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/snippets/myocamlbuild.ml: -------------------------------------------------------------------------------- 1 | ../../build/myocamlbuild.ml -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/snippets/netchan_cat.ml: -------------------------------------------------------------------------------- 1 | (* Yet another (slower) "cat" implementation, it is just meant to be a 2 | showcase for integration with ocamlnet's Netchannels. *) 3 | 4 | let oc = 5 | Netchannels.lift_out 6 | (`Rec (new Netchannels.channel_of_output IO.stdout :> 7 | Netchannels.rec_out_channel)) 8 | let _ = 9 | Netchannels.with_in_obj_channel 10 | (Netchannels.lift_in (`Rec (new Netchannels.channel_of_input IO.stdin))) 11 | (fun ic -> 12 | try 13 | while true do 14 | oc # output_string (ic # input_line () ^ "\n"); 15 | oc # flush () 16 | done 17 | with End_of_file -> ()) 18 | 19 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/snippets/parallelsort.ml: -------------------------------------------------------------------------------- 1 | open Threads, Event 2 | 3 | let tasks = 5 4 | 5 | let main = 6 | let input = Sys.argv in 7 | let input_len = Array.length input in 8 | let channels = Array.init tasks (fun _ -> new_channel ()) in 9 | let part_size = input_len / tasks in 10 | let gen_part i = 11 | let len = if i=tasks-1 then (input_len) - (i * part_size) else part_size in 12 | Array.sub input (i*part_size) len 13 | in 14 | let partitions = Array.init tasks gen_part in 15 | let task (c,arr) = Array.sort compare arr; send c arr |> sync in 16 | let make_thread c arr = ignore (Thread.create task (c,arr)) in 17 | Array.iter2 make_thread channels partitions; 18 | let get_print c = c |> receive |> sync |> Array.iter print_endline in 19 | Array.iter get_print channels 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/snippets/ropes_vs_strings.ml: -------------------------------------------------------------------------------- 1 | open Rope 2 | 3 | let (^^^) = append 4 | 5 | let test_strings num = 6 | let x = ref "" 7 | and s = "a" 8 | in for i = 1 to num do 9 | x := !x ^ s 10 | done 11 | 12 | let test_ropes num = 13 | let x = ref (r"") 14 | and s = r"a" 15 | in for i = 1 to num do 16 | x := !x ^^^ s 17 | done 18 | 19 | let delta f x = 20 | let t0 = Sys.time () in 21 | let _ = f x in 22 | let t1 = Sys.time () in 23 | t1 -. t0 24 | 25 | let _ = 26 | Printf.printf "Strings: %fms\n" (delta (fun () -> 27 | for i = 1 to 10 do 28 | test_strings 10000 29 | done 30 | ) ()); 31 | Printf.printf "Ropes: %fms\n" (delta (fun () -> 32 | for i = 1 to 10 do 33 | test_ropes 1000000 34 | done 35 | ) ()) 36 | 37 | 38 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/snippets/snippets.itarget: -------------------------------------------------------------------------------- 1 | netchan_cat.byte 2 | netchan_cat.native 3 | parallelsort.byte 4 | parallelsort.native 5 | test_printf.byte 6 | test_printf.native 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/snippets/test_printf.ml: -------------------------------------------------------------------------------- 1 | open Batteries 2 | open Print 3 | 4 | let _ = 5 | (* Simple test *) 6 | printf p"x = (%d, %s)\n" 1 "a"; 7 | 8 | (* With flags: *) 9 | printf p"x = %04x\n" 42; 10 | 11 | (* Test with labelled directives: *) 12 | printf p"Hello %(name:s), i am ocaml version %(version:s)\n%!" 13 | ~name:(try Sys.getenv "USER" with _ -> "toto") 14 | ~version:Sys.ocaml_version; 15 | 16 | (* Printing an object: *) 17 | printf p"o = %obj\n" 18 | (object(self) 19 | method print oc = fprintf oc p"" (Oo.id self) 20 | end); 21 | 22 | (* Printing a list: *) 23 | printf p"l = %{int option list}\n" [Some 1; None; Some 2]; 24 | 25 | (* A custom directive, printing pair of integers: *) 26 | let printer_foo k (x, y) = k (fun oc -> fprintf oc p"(%d, %d)" x y) in 27 | 28 | printf p"pair = %foo\n" (42, 1024); 29 | 30 | (* A custom directive, taking multiple arguments: *) 31 | let printer_test k x y z = k (fun oc -> fprintf oc p"(%d, %d, %d)" x y z) in 32 | 33 | printf p"x = %test\n" 1 2 3; 34 | 35 | (* Labelled directives with multiple argument: *) 36 | printf p"x = %(x,y,z:test)\n" ~x:1 ~y:2 ~z:2; 37 | printf p"x = %(x,_,z:test)\n" ~x:1 2 ~z:2 38 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/snippets/unicode.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/batteries-1.4.0/examples/snippets/unicode.ml -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/snippets/unicode2.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/batteries-1.4.0/examples/snippets/unicode2.ml -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/_tags: -------------------------------------------------------------------------------- 1 | not(<*_dyn*>): pkg_batteries,debug 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/browser.ml: -------------------------------------------------------------------------------- 1 | (** 2 | Call your favorite browser to browse each of the URLs entered on the command-line. 3 | *) 4 | open Batteries_config 5 | 6 | iter (fun x -> ignore **> browse x) (args ()) 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/cat.ml: -------------------------------------------------------------------------------- 1 | (** Implementation of a cat-like tool: read each file whose name is 2 | given on the command-line and print the contents to stdout. 3 | 4 | Usage: 5 | ./cat.byte *.ml 6 | 7 | *) 8 | 9 | open Batteries 10 | 11 | iter (fun x -> IO.copy (File.open_in x) stdout) (args ());; 12 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/cat2.ml: -------------------------------------------------------------------------------- 1 | (** Implementation of a cat-like tool: read each file whose name is 2 | given on the command-line and print the contents to stdout. 3 | 4 | Usage: 5 | ./cat2.byte *.ml 6 | 7 | Variants based on function composition 8 | *) 9 | 10 | (* 11 | For reference 12 | 13 | write_lines : unit output -> string Enum.t -> unit 14 | stdout : unit output 15 | args : unit -> string Enum.t 16 | () : unit 17 | concat : string Enum.t Enum.t -> string Enum.t 18 | map : (string -> string Enum.t) -> string Enum.t -> string Enum.t Enum.t 19 | File.lines_of:string -> string Enum.t 20 | *) 21 | 22 | (*(*Variant 1*) 23 | let _ = 24 | write_lines stdout -| concat <| map lines_of (args ()) 25 | *) 26 | 27 | (*Variant 2*) 28 | let _ = 29 | () |> args |> (File.lines_of |> map) |> concat |> (stdout |> IO.write_lines) 30 | 31 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/conv.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Convert encodings. 3 | Everything received from the standard input is converted and written onto the standard output, 4 | using the encodings specified on the command-line. 5 | 6 | Usage: 7 | ./conv ASCII UTF-8 < README 8 | *) 9 | open CharEncodings, Sys, IO 10 | 11 | try 12 | (*V1: Convert output: 13 | copy stdin (encoded_as (transcode_out (as_encoded stdout (`named argv.(1))) (`named argv.(2))))*) 14 | (*V2: Convert input*) 15 | copy (encoded_as **> transcode_in (as_encoded stdin **> `named argv.(1)) (`named argv.(2))) stdout; 16 | flush_all () 17 | with Not_found -> Print.eprintf p"Sorry, unknown encoding.\n%!" 18 | | Malformed_code -> Print.eprintf p"Error: This text is not encoded with encoding %S\n" (argv.(1)) 19 | | e -> Print.eprintf p"Error:\n%s\n%!" (Printexc.to_string e) 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/gunzip.ml: -------------------------------------------------------------------------------- 1 | (* Open a .gz file and decompress it on the spot. 2 | 3 | Usage: 4 | ./gunzip.byte some_file.gz 5 | (produces some_file, removes some_file.gz) 6 | *) 7 | open File, IO, Filename 8 | 9 | iter f (args ()) 10 | where let f name = 11 | if check_suffix name ".gz" then 12 | with_file_in name (fun inp -> 13 | with_file_out (chop_suffix name ".gz") (fun out -> 14 | Gzip.with_in inp (fun inp'-> 15 | copy inp' out; 16 | Sys.remove name))) 17 | else prerr_endline ("I don't know what to do with file "^name) 18 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/mygzip.ml: -------------------------------------------------------------------------------- 1 | (* Compress a file to .gz on the spot 2 | 3 | Usage: 4 | ./gzip.byte some_file 5 | (produces some_file.gz, removes some_file) 6 | *) 7 | open File, IO, Filename 8 | 9 | iter f (args ()) 10 | where let f name = 11 | with_file_out (name ^ ".gz") (fun out -> 12 | with_file_in name (fun inp -> 13 | copy inp (Gzip.compress out); 14 | Sys.remove name 15 | )) 16 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/myocamlbuild.ml: -------------------------------------------------------------------------------- 1 | ../../build/myocamlbuild.ml -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/now.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Print the current date 3 | 4 | Usage: 5 | ./now 6 | *) 7 | 8 | open Date 9 | print stdout (now ()); 10 | print_newline () 11 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/shuffle.ml: -------------------------------------------------------------------------------- 1 | (* Randomly reorder the elements given on the command-line. 2 | 3 | Usage: 4 | ./shuffle 1 2 3 4 5 6 7 8 9 5 | *) 6 | 7 | open Random with self_init () 8 | 9 | let _ = Array.print ~sep:" " ~first:"" ~last:"\n" output_string stdout (shuffle (args ()));; 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/shuffle2.ml: -------------------------------------------------------------------------------- 1 | (*Randomly reorder the elements given on stdin. 2 | 3 | Usage: 4 | ./shuffle2.byte < some_file.txt 5 | *) 6 | 7 | open Random with self_init () 8 | open IO, Printf 9 | 10 | let shift x = x + 1;; 11 | 12 | Array.iteri (shift |- printf "%-2d: %s\n") (shuffle (lines_of stdin)) 13 | 14 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/examples/tools/tools.itarget: -------------------------------------------------------------------------------- 1 | conv.byte 2 | conv.native 3 | now.byte 4 | now.native 5 | cat.byte 6 | cat.native 7 | cat2.byte 8 | cat2.native 9 | shuffle.byte 10 | shuffle.native 11 | shuffle2.byte 12 | shuffle2.native 13 | gzip.byte 14 | gzip.native 15 | gunzip.byte 16 | gunzip.native 17 | browser.byte 18 | browser.native -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/libs/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/batteries-1.4.0/libs/.gitignore -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/libs/estring.itarget: -------------------------------------------------------------------------------- 1 | estring/pa_estring.cmi 2 | estring/pa_estring.cmo 3 | estring/pa_estring_top.cmo 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/libs/estring/META: -------------------------------------------------------------------------------- 1 | # -*- conf -*- 2 | description = "syntax extension for extended strings" 3 | version = "1.0" 4 | requires = "camlp4" 5 | archive(syntax,preprocessor) = "pa_estring.cmo" 6 | archive(syntax,toploop) = "pa_estring.cmo pa_estring_top.cmo" 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/libs/estring/VERSION: -------------------------------------------------------------------------------- 1 | 1.0 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/libs/estring/_tags: -------------------------------------------------------------------------------- 1 | <*.ml> or <*.mli>: camlp4of 2 | true: debug -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/libs/estring/pa_estring_top.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * pa_estring_top.ml 3 | * ----------------- 4 | * Copyright : (c) 2009, Jeremie Dimino 5 | * Licence : BSD3 6 | * 7 | * This file is a part of estring. 8 | *) 9 | 10 | (* Setup pa_estring for the toplevel *) 11 | 12 | open Camlp4.PreCast 13 | 14 | 15 | (* Hack used to force camlp4 to define a new token stream filtered 16 | with the newly defined filter. *) 17 | let _ = 18 | let parse = !Toploop.parse_toplevel_phrase and lexbufs = ref [] in 19 | Toploop.parse_toplevel_phrase := 20 | (fun lexbuf -> 21 | match try Some(List.assq lexbuf !lexbufs) with _ -> None with 22 | | Some lexbuf -> 23 | parse lexbuf 24 | | None -> 25 | let new_lexbuf = { lexbuf with Lexing.refill_buff = lexbuf.Lexing.refill_buff } in 26 | lexbufs := (lexbuf, new_lexbuf) :: !lexbufs; 27 | parse new_lexbuf) 28 | 29 | (* Reload "Camlp4Top.cmo" to force camlp4 to use the new topphrase filter *) 30 | (*let _ = Topdirs.dir_load Format.std_formatter "Camlp4Top.cmo" *) 31 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/libs/estring/sample/pa_string_list.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * pa_string_list.ml 3 | * ----------------- 4 | * Copyright : (c) 2009, Jeremie Dimino 5 | * Licence : BSD3 6 | * 7 | * This file is a part of estring. 8 | *) 9 | 10 | (* Sample syntax extension for replacing strings by list of 11 | characters *) 12 | 13 | open Camlp4.PreCast 14 | open Pa_estring 15 | 16 | let _ = 17 | register_expr_specifier "l" 18 | (fun ctx loc str -> llist_expr (fun _loc ch -> <:expr< $chr:Char.escaped ch$ >>) (unescape loc str)); 19 | register_patt_specifier "l" 20 | (fun ctx loc str -> llist_patt (fun _loc ch -> <:patt< $chr:Char.escaped ch$ >>) (unescape loc str)) 21 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/libs/estring/sample/sample.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * sample.ml 3 | * --------- 4 | * Copyright : (c) 2009, Jeremie Dimino 5 | * Licence : BSD3 6 | * 7 | * This file is a part of estring. 8 | *) 9 | 10 | open Printf 11 | 12 | (* [x] is a list of characters defined in a convenient way: *) 13 | let x = l"Hello, world!" 14 | 15 | (* Simple function on list of characters: *) 16 | let replace patt repl l = 17 | List.map (fun ch -> if ch = patt then repl else ch) l 18 | 19 | let y = replace 'o' 'i' x 20 | 21 | let output_char_list oc l = List.iter (output_char oc) l 22 | 23 | let _ = 24 | printf "x = %a\ny = %a\n" output_char_list x output_char_list y 25 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/native.itarget: -------------------------------------------------------------------------------- 1 | src/batteries_uni.cmxa 2 | src/batteries.cmxa 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/num: -------------------------------------------------------------------------------- 1 | ../bigint-3.12/otherlibs/num -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/ocamlinit: -------------------------------------------------------------------------------- 1 | let interactive = !Sys.interactive;; 2 | Sys.interactive := false;; (*Pretend to be in non-interactive mode*) 3 | #use "topfind";; 4 | Sys.interactive := interactive;; (*Return to regular interactive mode*) 5 | 6 | Toploop.use_silently 7 | Format.err_formatter (Filename.concat (Findlib.package_directory 8 | "batteries") "battop.ml");; 9 | 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/qtest/_tags: -------------------------------------------------------------------------------- 1 | <*>: pkg_oUnit, pkg_threads, debug 2 | : linkall 3 | : linkall 4 | : use_batteries, use_test_mods, threads -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/shared.itarget: -------------------------------------------------------------------------------- 1 | src/batteries_uni.cmxs 2 | src/batteries.cmxs 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/_tags: -------------------------------------------------------------------------------- 1 | <{batMutex,batRMutex}.{ml,mli}>: threads 2 | "syntax/pa_comprehension" or "syntax/pa_strings": include 3 | true: debug 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batAvlTree.mli: -------------------------------------------------------------------------------- 1 | (* $Id: avlTree.mli,v 1.3 2003/06/18 15:11:07 yori Exp $ *) 2 | (* Copyright 2003 Yamagata Yoriyuki. distributed with LGPL *) 3 | (* Modified by Edgar Friendly *) 4 | 5 | (** Internals of ISet and IMap, usable as generic tree library *) 6 | 7 | type +'a tree 8 | 9 | val empty : 'a tree 10 | 11 | val is_empty : 'a tree -> bool 12 | 13 | val make_tree : 'a tree -> 'a -> 'a tree -> 'a tree 14 | 15 | val height : 'a tree -> int 16 | 17 | (* If tree is empty, then raise Not_found *) 18 | val left_branch : 'a tree -> 'a tree 19 | val right_branch : 'a tree -> 'a tree 20 | val root : 'a tree -> 'a 21 | 22 | (* Utilities *) 23 | val singleton_tree : 'a -> 'a tree 24 | val split_leftmost : 'a tree -> 'a * 'a tree 25 | val split_rightmost : 'a tree -> 'a * 'a tree 26 | 27 | val concat : 'a tree -> 'a tree -> 'a tree 28 | 29 | val iter : ('a -> unit) -> 'a tree -> unit 30 | 31 | val fold : ('a -> 'b -> 'b) -> 'a tree -> 'b -> 'b 32 | 33 | val enum : 'a tree -> 'a BatEnum.t 34 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batCamomile-0.7.ml: -------------------------------------------------------------------------------- 1 | (* Interface to camomile that defaults to CamomileDefaultConfig but 2 | tries to use CAMOMILE_BASE from environment to set root *) 3 | 4 | let camomile_base = "CAMOMILE_BASE" 5 | 6 | (* default to default config dirs if unset *) 7 | let try_env suff default = 8 | try Filename.concat (Sys.getenv camomile_base) suff 9 | with Not_found -> default 10 | 11 | module CDC = CamomileLibrary.CamomileDefaultConfig 12 | 13 | module CamConfig = struct 14 | let datadir = try_env "database" CDC.datadir 15 | let localedir = try_env "locales" CDC.localedir 16 | let charmapdir = try_env "charmaps" CDC.charmapdir 17 | let unimapdir = try_env "mappings" CDC.unimapdir 18 | end 19 | 20 | include CamomileLibrary.Main.Make(CamConfig) 21 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batCamomile-0.8.1.ml: -------------------------------------------------------------------------------- 1 | (* Interface to camomile that defaults to CamomileDefaultConfig but 2 | tries to use CAMOMILE_BASE from environment to set root *) 3 | 4 | let camomile_base = "CAMOMILE_BASE" 5 | 6 | (* default to default config dirs if unset *) 7 | let try_env suff default = 8 | try Filename.concat (Sys.getenv camomile_base) suff 9 | with Not_found -> default 10 | 11 | module CDC = CamomileLibraryDefault.Config 12 | 13 | module CamConfig = struct 14 | let datadir = try_env "database" CDC.datadir 15 | let localedir = try_env "locales" CDC.localedir 16 | let charmapdir = try_env "charmaps" CDC.charmapdir 17 | let unimapdir = try_env "mappings" CDC.unimapdir 18 | end 19 | 20 | include CamomileLibrary.Make(CamConfig) 21 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batCamomile-0.8.2.ml: -------------------------------------------------------------------------------- 1 | include CamomileLibrary.Make(CamomileLibraryDyn.Config) 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batChar.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/batteries-1.4.0/src/batChar.ml -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batChar.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/batteries-1.4.0/src/batChar.mli -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batCharEncodings.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/batteries-1.4.0/src/batCharEncodings.mli -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batMonad.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * Monad -- Base monadic operations 3 | * Copyright (C) 2008 David Teller 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version, 9 | * with the special exception on linking described in file LICENSE. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | *) 20 | 21 | module type S = sig 22 | type 'a m 23 | val bind : 'a m -> ('a -> 'b m) -> 'b m 24 | val return: 'a -> 'a m 25 | end 26 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batOo.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * ExtOO - Extended operations on objects 3 | * Copyright (C) 1996 Jerome Vouillon, INRIA 4 | * 2008 David Teller, LIFO, Universite d'Orleans 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version, 10 | * with the special exception on linking described in file LICENSE. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | *) 21 | 22 | 23 | 24 | module Oo = 25 | struct 26 | include Oo 27 | module Internal = CamlinternalOO 28 | end 29 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batPMap.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * PMap - Polymorphic maps 3 | * Copyright (C) 1996-2003 Xavier Leroy, Nicolas Cannasse, Markus Mottl 4 | * 2009 David Rajchenbach-Teller, LIFO, Universite d'Orleans 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version, 10 | * with the special exception on linking described in file LICENSE. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | *) 21 | 22 | include BatMap 23 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batPSet.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * PMap - Polymorphic sets 3 | * Copyright (C) 1996-2003 Xavier Leroy, Nicolas Cannasse, Markus Mottl 4 | * Copyright (C) 2008 David Teller 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version, 10 | * with the special exception on linking described in file LICENSE. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | *) 21 | 22 | include BatSet 23 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batPrintexc.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * ExtPrintexc - Extended Printexc module 3 | * Copyright (C) 1996 Xavier Leroy 4 | * 2008 David Teller, LIFO, Universite d'Orleans 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version, 10 | * with the special exception on linking described in file LICENSE. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | *) 21 | 22 | 23 | open Printexc 24 | 25 | let pass = print 26 | let print out e = BatInnerIO.nwrite out (to_string e) 27 | let print_backtrace out = BatInnerIO.nwrite out (get_backtrace ()) 28 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batPrintf.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * ExtPrintf - Extended Printf module 3 | * Copyright (C) 2008 David Teller (contributor) 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version, 9 | * with the special exception on linking described in file LICENSE. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | *) 20 | 21 | 22 | include BatInnerIO.Printf 23 | 24 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batResult.ml: -------------------------------------------------------------------------------- 1 | 2 | open BatStd 3 | type ('a, 'b) t = ('a, 'b) BatStd.result = 4 | | Ok of 'a 5 | | Bad of 'b 6 | 7 | let catch f x = 8 | try Ok (f x) 9 | with e -> Bad e 10 | 11 | let of_option = function 12 | | Some x -> Ok x 13 | | None -> Bad () 14 | 15 | let to_option = function 16 | | Ok x -> Some x 17 | | Bad _-> None 18 | 19 | let bind m k = match m with 20 | | Ok x -> k x 21 | | Bad _ as e -> e 22 | 23 | let (>>=) = bind 24 | 25 | module Infix = struct 26 | let (>>=) = (>>=) 27 | end 28 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batResult.mli: -------------------------------------------------------------------------------- 1 | open BatStd 2 | (** Monadic results of computations that can raise exceptions *) 3 | 4 | type ('a, 'b) t = ('a, 'b) result 5 | (** The type of a result*) 6 | 7 | val catch: ('a -> 'b) -> 'a -> ('b, exn) result 8 | (** Execute a function and catch any exception as a [!result]*) 9 | 10 | val of_option: 'a option -> ('a, unit) result 11 | (** Convert an [option] to a [result]*) 12 | 13 | val to_option: ('a, _) result -> 'a option 14 | (** Convert a [result] to an [option]*) 15 | 16 | val bind: ('a, 'b) result -> ('a -> ('c, 'b) result) -> ('c, 'b) result 17 | (** Monadic composition. 18 | 19 | [bind r f] proceeds as [f x] if [r] is [Ok x], or returns [r] if 20 | [r] is an error.*) 21 | 22 | val ( >>= ): ('a, 'b) result -> ('a -> ('c, 'b) result) -> ('c, 'b) result 23 | (** as [bind] *) 24 | 25 | (** {6 Infix submodule regrouping all infix operators} *) 26 | module Infix : sig 27 | val ( >>= ): ('a, 'b) result -> ('a -> ('c, 'b) result) -> ('c, 'b) result 28 | end 29 | 30 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batSys.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * ExtSys - additional and modified functions for System 3 | * Copyright (C) 1996 Xavier Leroy 4 | * Copyright (C) 2009 David Teller, LIFO, Universite d'Orleans 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version, 10 | * with the special exception on linking described in file LICENSE. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | *) 21 | 22 | 23 | 24 | let files_of d = BatArray.enum (Sys.readdir d) 25 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/batteries.ml: -------------------------------------------------------------------------------- 1 | include Batteries_uni (* the meat of this module is in batteries_uni.mli *) 2 | module Mutex = BatMutex;; 3 | module RMutex = BatRMutex;; 4 | 5 | Unix.lock := Mutex.Mutex.make ();; 6 | IO.lock := Mutex.Mutex.make ();; 7 | IO.lock_factory := Mutex.Mutex.make;; 8 | lock := Mutex.Mutex.make ();; 9 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/extlibcompat.ml: -------------------------------------------------------------------------------- 1 | module Base64 = BatBase64 2 | module BitSet = BatBitSet 3 | module Dllist = BatDllist 4 | module DynArray = BatDynArray 5 | module Enum = BatEnum 6 | module ExtArray = struct 7 | module Array = struct include Array include BatArray end 8 | end 9 | module ExtHashtbl = struct 10 | module Hashtbl = BatHashtbl 11 | end 12 | module ExtList = struct 13 | module List = struct include List include BatList end 14 | end 15 | module ExtString = struct 16 | module String = struct include String include BatString end 17 | end 18 | module Global = BatGlobal 19 | module IO = BatIO 20 | module OptParse = BatOptParse 21 | module Option = BatOption 22 | module PMap = BatPMap 23 | module RefList = BatRefList 24 | module Std = BatStd 25 | module UChar = BatUChar 26 | module UTF8 = BatUTF8 27 | (* module Unzip = BatUnzip *) 28 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/syntax/pa_comprehension/_tags: -------------------------------------------------------------------------------- 1 | "pa_comprehension.ml": camlp4rf 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/syntax/pa_llist/_tags: -------------------------------------------------------------------------------- 1 | "pa_llist.ml": camlp4of 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/syntax/pa_llist/pa_llist.ml: -------------------------------------------------------------------------------- 1 | (* Small extension to provide lazy pattern matching. *) 2 | open Camlp4.PreCast;; 3 | open Syntax;; 4 | 5 | EXTEND Gram 6 | GLOBAL: patt expr ; 7 | 8 | expr: LEVEL "simple" 9 | [ [ "[%"; "]" -> <:expr< lazy BatLazyList.Nil >> ] ]; 10 | 11 | patt: LEVEL "simple" 12 | [ [ "[%"; "]" -> <:patt< lazy BatLazyList.Nil >> ] ]; 13 | patt: LEVEL "::" 14 | [ [ p1 = SELF; "%::"; p2 = SELF -> 15 | <:patt< lazy BatLazyList.Cons($p1$,$p2$) >> ] ] ; 16 | END 17 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/syntax/pa_strings/_tags: -------------------------------------------------------------------------------- 1 | <*.ml>: camlp4of 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/src/syntax/pa_strings/pa_strings.mllib: -------------------------------------------------------------------------------- 1 | Pa_strings 2 | Pa_format 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/syntax.itarget: -------------------------------------------------------------------------------- 1 | libs/estring.otarget 2 | src/syntax/pa_comprehension/pa_comprehension.cmo 3 | src/syntax/pa_strings/pa_strings.cma 4 | src/syntax/pa_llist/pa_llist.cmo 5 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/testsuite/_tags: -------------------------------------------------------------------------------- 1 | true: pkg_oUnit, threads, debug 2 | "test_lazy_pattern.ml": with_pa_llist, syntax_camlp4o 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/testsuite/main.ml: -------------------------------------------------------------------------------- 1 | open OUnit 2 | 3 | let all_tests = 4 | [ 5 | Test_std.tests; 6 | Test_base64.tests; 7 | Test_unix.tests; 8 | (* Test_print.tests; 9 | Test_toplevel.tests; *) 10 | Test_map.tests; 11 | (* pmap is actually tested in test_map.ml, as they share their 12 | implementation *) 13 | Test_multipmap.tests; 14 | Test_vect.tests; 15 | Test_file.tests; 16 | Test_string.tests; 17 | Test_substring.tests; 18 | Test_digest.tests; 19 | Test_enum.tests; 20 | Test_set.tests; 21 | Test_dynarray.tests; 22 | Test_stack.tests; 23 | Test_mappable.tests; 24 | Test_hashcons.tests; 25 | Test_mapfunctors.tests; 26 | Test_lazy_pattern.tests; 27 | ] 28 | 29 | let () = 30 | ignore(OUnit.run_test_tt_main ("All" >::: all_tests)); 31 | 32 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/testsuite/myocamlbuild.ml: -------------------------------------------------------------------------------- 1 | ../build/myocamlbuild.ml -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/testsuite/test_digest.ml: -------------------------------------------------------------------------------- 1 | open OUnit 2 | 3 | (*1. Compute the digest of this file using Legacy.Digest*) 4 | 5 | let legacy_result () = 6 | let inp = Pervasives.open_in_bin Sys.argv.(0) in 7 | let result = Digest.channel inp (-1) in 8 | Pervasives.close_in inp; 9 | result 10 | 11 | (*2. Compute the digest of this file using Batteries.Digest*) 12 | 13 | let batteries_result () = 14 | let inp = BatFile.open_in Sys.argv.(0) in 15 | let result = BatDigest.channel inp (-1) in 16 | BatIO.close_in inp; 17 | result 18 | 19 | (*3. Compare*) 20 | let test_legacy_against_batteries () = 21 | assert_equal ~printer:(Printf.sprintf "%S") 22 | (legacy_result ()) (batteries_result ()) 23 | 24 | let tests = "Digest" >::: [ 25 | "Comparing Legacy.Digest and MD5" >:: test_legacy_against_batteries; 26 | ] 27 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/testsuite/test_dynarray.ml: -------------------------------------------------------------------------------- 1 | open Batteries 2 | open OUnit 3 | 4 | module DA = DynArray 5 | 6 | let s1 = DA.of_list [1;2;3] 7 | let s2 = DA.of_list [1;2] 8 | 9 | let asseq_int = assert_equal ~printer:(DA.print Int.print |> IO.to_string) 10 | let asseq_str = assert_equal ~printer:identity 11 | 12 | let test_dynarray_filter () = 13 | let e = BatDynArray.create () in 14 | BatDynArray.add e "a"; 15 | BatDynArray.add e "b"; 16 | BatDynArray.keep ((=) "a") e; 17 | asseq_str (BatDynArray.get e 0) "a" 18 | 19 | 20 | let tests = "Set" >::: [ 21 | "Dynarray_filter" >:: test_dynarray_filter; 22 | ] 23 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/testsuite/test_lazy_pattern.ml: -------------------------------------------------------------------------------- 1 | open OUnit 2 | open Batteries_uni 3 | module L = LazyList 4 | 5 | let tests = "LazyPattern" >::: [ 6 | "match nil" >:: begin fun () -> 7 | assert_bool "nil didn't match" 8 | (match L.nil with [%] -> true | _ -> false) 9 | end; 10 | "nil doesn't match non-nil" >:: begin fun () -> 11 | assert_bool "nil matched incorrectly" 12 | (match L.cons 3 L.nil with [%] -> false | _ -> true) 13 | end; 14 | "match cons" >:: begin fun () -> 15 | assert_equal ~printer:string_of_int 5 16 | (match L.cons 5 L.nil with x %:: _ -> x | _ -> 0) 17 | end; 18 | "form nil" >:: begin fun () -> 19 | assert_equal L.Nil (Lazy.force [%]) 20 | end; 21 | ];; 22 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/testsuite/test_multipmap.ml: -------------------------------------------------------------------------------- 1 | open OUnit 2 | open BatPervasives 3 | open BatMultiPMap 4 | 5 | let test_multimap_empty_assoc_lists () = 6 | let map = 7 | add 0 "foo" empty |> add 0 "bar" |> add 0 "sna" |> 8 | remove 0 "foo" |> remove 0 "bar" |> remove 0 "sna" 9 | in 10 | if mem 0 map then 11 | assert_failure 12 | (Printf.sprintf "map[0] should be empty but contains %d bindings\n" 13 | (BatPSet.cardinal (find 0 map))) 14 | 15 | let tests = "MultiPMap" >::: [ 16 | "MultiPMap: removing empty association lists" >:: test_multimap_empty_assoc_lists; 17 | ] 18 | -------------------------------------------------------------------------------- /lib/bap-0.4/batteries-1.4.0/testsuite/test_std.ml: -------------------------------------------------------------------------------- 1 | open OUnit 2 | open Batteries_uni 3 | 4 | let test_using () = 5 | let obj = (ref 0), (ref 0) in 6 | let dispose (_,closed) = closed := 5 in 7 | let f (run,_) = run := 7; 42 in 8 | let r = with_dispose ~dispose f obj in 9 | let printer = string_of_int in 10 | let run, closed = obj in 11 | assert_equal ~printer 42 r; 12 | assert_equal ~printer 7 (!run); 13 | assert_equal ~printer 5 (!closed) 14 | 15 | let tests = "Std" >::: [ 16 | "using" >:: test_using 17 | ];; 18 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/.cvsignore: -------------------------------------------------------------------------------- 1 | .depend 2 | configure 3 | ocamlc 4 | ocamlc.opt 5 | expunge 6 | ocaml 7 | ocamlopt 8 | ocamlopt.opt 9 | ocamlcomp.sh 10 | ocamlcompopt.sh 11 | package-macosx 12 | .DS_Store 13 | *.annot 14 | _boot_log1 15 | _boot_log2 16 | _build 17 | _log 18 | myocamlbuild_config.ml 19 | ocamlnat 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/Changes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/bigint-3.12/Changes -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/Makefile: -------------------------------------------------------------------------------- 1 | clean: 2 | make -C otherlibs/num clean 3 | 4 | all: 5 | make -C otherlibs/num all 6 | make -C otherlibs/num allopt 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/VERSION: -------------------------------------------------------------------------------- 1 | 3.12.0 2 | 3 | # The version string is the first line of this file. 4 | # It must be in the format described in stdlib/sys.mli 5 | 6 | # $Id: VERSION 10641 2010-08-02 13:10:35Z doligez $ 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/byterun/.cvsignore: -------------------------------------------------------------------------------- 1 | jumptbl.h 2 | primitives 3 | prims.c 4 | opnames.h 5 | version.h 6 | ocamlrun 7 | ocamlrund 8 | ld.conf 9 | libcamlrun.x 10 | libcamlrun-gui.x 11 | *.c.x 12 | ocamlrun.xcoff 13 | ocamlrun.dbg 14 | interp.a.lst 15 | *.[sd]obj 16 | *.lib 17 | .gdb_history 18 | *.so 19 | *.a 20 | .depend.nt 21 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/byterun/compare.h: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Damien Doligez, Projet Moscova, INRIA Rocquencourt */ 6 | /* */ 7 | /* Copyright 2003 Institut National de Recherche en Informatique et */ 8 | /* en Automatique. All rights reserved. This file is distributed */ 9 | /* under the terms of the GNU Library General Public License, with */ 10 | /* the special exception on linking described in file ../LICENSE. */ 11 | /* */ 12 | /***********************************************************************/ 13 | 14 | /* $Id: compare.h 6044 2003-12-31 14:20:40Z doligez $ */ 15 | 16 | #ifndef CAML_COMPARE_H 17 | #define CAML_COMPARE_H 18 | 19 | CAMLextern int caml_compare_unordered; 20 | 21 | #endif /* CAML_COMPARE_H */ 22 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/byterun/weak.h: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */ 6 | /* */ 7 | /* Copyright 1997 Institut National de Recherche en Informatique et */ 8 | /* en Automatique. All rights reserved. This file is distributed */ 9 | /* under the terms of the GNU Library General Public License, with */ 10 | /* the special exception on linking described in file ../LICENSE. */ 11 | /* */ 12 | /***********************************************************************/ 13 | 14 | /* $Id: weak.h 6045 2004-01-01 16:42:43Z doligez $ */ 15 | 16 | /* Operations on weak arrays */ 17 | 18 | #ifndef CAML_WEAK_H 19 | #define CAML_WEAK_H 20 | 21 | #include "mlvalues.h" 22 | 23 | extern value caml_weak_list_head; 24 | extern value caml_weak_none; 25 | 26 | #endif /* CAML_WEAK_H */ 27 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/.cvsignore: -------------------------------------------------------------------------------- 1 | m.h 2 | s.h 3 | Makefile 4 | config.sh 5 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/.cvsignore: -------------------------------------------------------------------------------- 1 | camlp4_config.ml 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/ansi.c: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ 6 | /* */ 7 | /* Copyright 1997 Institut National de Recherche en Informatique et */ 8 | /* en Automatique. All rights reserved. This file is distributed */ 9 | /* under the terms of the GNU Library General Public License, with */ 10 | /* the special exception on linking described in file ../../LICENSE. */ 11 | /* */ 12 | /***********************************************************************/ 13 | 14 | int main() 15 | { 16 | #ifdef __STDC__ 17 | return 0; 18 | #else 19 | return 1; 20 | #endif 21 | } 22 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/elf.c: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ 6 | /* */ 7 | /* Copyright 1999 Institut National de Recherche en Informatique et */ 8 | /* en Automatique. All rights reserved. This file is distributed */ 9 | /* under the terms of the GNU Library General Public License, with */ 10 | /* the special exception on linking described in file ../../LICENSE. */ 11 | /* */ 12 | /***********************************************************************/ 13 | 14 | /* $Id: elf.c 4144 2001-12-07 13:41:02Z xleroy $ */ 15 | 16 | #include 17 | 18 | int main(int argc, char ** argv) 19 | { 20 | #ifdef __ELF__ 21 | printf("elf\n"); 22 | #else 23 | printf("aout\n"); 24 | #endif 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/hasgot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | opts="" 4 | libs="$cclibs" 5 | args=$* 6 | rm -f hasgot.c 7 | var="x" 8 | while : ; do 9 | case "$1" in 10 | -i) echo "#include <$2>" >> hasgot.c; shift;; 11 | -t) echo "$2 $var;" >> hasgot.c; var="x$var"; shift;; 12 | -l*|-L*|-F*) libs="$libs $1";; 13 | -framework) libs="$libs $1 $2"; shift;; 14 | -*) opts="$opts $1";; 15 | *) break;; 16 | esac 17 | shift 18 | done 19 | 20 | (echo "main() {" 21 | for f in $*; do echo " $f();"; done 22 | echo "}") >> hasgot.c 23 | 24 | if test "$verbose" = yes; then 25 | echo "hasgot $args: $cc $opts -o tst hasgot.c $libs" >&2 26 | exec $cc $opts -o tst hasgot.c $libs > /dev/null 27 | else 28 | exec $cc $opts -o tst hasgot.c $libs > /dev/null 2>/dev/null 29 | fi 30 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/ia32sse2.c: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ 6 | /* */ 7 | /* Copyright 2003 Institut National de Recherche en Informatique et */ 8 | /* en Automatique. All rights reserved. This file is distributed */ 9 | /* under the terms of the GNU Library General Public License, with */ 10 | /* the special exception on linking described in file ../../LICENSE. */ 11 | /* */ 12 | /***********************************************************************/ 13 | 14 | /* $Id: ia32sse2.c 6824 2005-03-24 17:20:54Z doligez $ */ 15 | 16 | /* Test whether IA32 assembler supports SSE2 instructions */ 17 | 18 | int main() 19 | { 20 | asm("pmuludq %mm1, %mm0"); 21 | asm("paddq %mm1, %mm0"); 22 | asm("psubq %mm1, %mm0"); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/initgroups.c: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Copyright 2009 Institut National de Recherche en Informatique et */ 6 | /* en Automatique. All rights reserved. This file is distributed */ 7 | /* under the terms of the GNU Library General Public License, with */ 8 | /* the special exception on linking described in file ../../LICENSE. */ 9 | /* */ 10 | /***********************************************************************/ 11 | 12 | /* Contributed by Stephane Glondu */ 13 | 14 | /* $Id: initgroups.c 9220 2009-04-01 16:50:10Z xleroy $ */ 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | int main(void) 23 | { 24 | if (initgroups("root", 0) == -1 && errno != EPERM) return 1; 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/runtest: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test "$verbose" = yes; then 3 | echo "runtest: $cc -o tst $* $cclibs" >&2 4 | $cc -o tst $* $cclibs || exit 100 5 | else 6 | $cc -o tst $* $cclibs 2> /dev/null || exit 100 7 | fi 8 | exec ./tst 9 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/schar.c: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ 6 | /* */ 7 | /* Copyright 1996 Institut National de Recherche en Informatique et */ 8 | /* en Automatique. All rights reserved. This file is distributed */ 9 | /* under the terms of the GNU Library General Public License, with */ 10 | /* the special exception on linking described in file ../../LICENSE. */ 11 | /* */ 12 | /***********************************************************************/ 13 | 14 | /* $Id: schar.c 4144 2001-12-07 13:41:02Z xleroy $ */ 15 | 16 | char foo[]="\377"; 17 | 18 | int main(int argc, char ** argv) 19 | { 20 | int i; 21 | i = foo[0]; 22 | exit(i != -1); 23 | } 24 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/schar2.c: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ 6 | /* */ 7 | /* Copyright 1996 Institut National de Recherche en Informatique et */ 8 | /* en Automatique. All rights reserved. This file is distributed */ 9 | /* under the terms of the GNU Library General Public License, with */ 10 | /* the special exception on linking described in file ../../LICENSE. */ 11 | /* */ 12 | /***********************************************************************/ 13 | 14 | /* $Id: schar2.c 4144 2001-12-07 13:41:02Z xleroy $ */ 15 | 16 | signed char foo[]="\377"; 17 | 18 | int main(int argc, char ** argv) 19 | { 20 | int i; 21 | i = foo[0]; 22 | exit(i != -1); 23 | } 24 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/searchpath: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Find a program in the path 3 | 4 | IFS=':' 5 | for dir in $PATH; do 6 | if test -z "$dir"; then dir=.; fi 7 | if test -f $dir/$1; then exit 0; fi 8 | done 9 | exit 1 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/setgroups.c: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Copyright 2009 Institut National de Recherche en Informatique et */ 6 | /* en Automatique. All rights reserved. This file is distributed */ 7 | /* under the terms of the GNU Library General Public License, with */ 8 | /* the special exception on linking described in file ../../LICENSE. */ 9 | /* */ 10 | /***********************************************************************/ 11 | 12 | /* Contributed by Stephane Glondu */ 13 | 14 | /* $Id: setgroups.c 9220 2009-04-01 16:50:10Z xleroy $ */ 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | int main(void) 23 | { 24 | gid_t gidset[1]; 25 | gidset[0] = 0; 26 | if (setgroups(1, gidset) == -1 && errno != EPERM) return 1; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/sharpbang: -------------------------------------------------------------------------------- 1 | #! /bin/cat 2 | exit 1 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/sharpbang2: -------------------------------------------------------------------------------- 1 | #! /usr/bin/cat 2 | exit 1 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/sighandler.c: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ 6 | /* */ 7 | /* Copyright 1996 Institut National de Recherche en Informatique et */ 8 | /* en Automatique. All rights reserved. This file is distributed */ 9 | /* under the terms of the GNU Library General Public License, with */ 10 | /* the special exception on linking described in file ../../LICENSE. */ 11 | /* */ 12 | /***********************************************************************/ 13 | 14 | /* $Id: sighandler.c 4144 2001-12-07 13:41:02Z xleroy $ */ 15 | 16 | #include 17 | 18 | int main(void) 19 | { 20 | SIGRETURN (*old)(); 21 | old = signal(SIGQUIT, SIG_DFL); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/sizes.c: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ 6 | /* */ 7 | /* Copyright 1996 Institut National de Recherche en Informatique et */ 8 | /* en Automatique. All rights reserved. This file is distributed */ 9 | /* under the terms of the GNU Library General Public License, with */ 10 | /* the special exception on linking described in file ../../LICENSE. */ 11 | /* */ 12 | /***********************************************************************/ 13 | 14 | /* $Id: sizes.c 4144 2001-12-07 13:41:02Z xleroy $ */ 15 | 16 | #include 17 | 18 | int main(int argc, char **argv) 19 | { 20 | printf("%d %d %d %d\n", 21 | sizeof(int), sizeof(long), sizeof(long *), sizeof(short)); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/solaris-ld: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Determine if gcc calls the Solaris ld or the GNU ld 3 | # Exit code is 0 for Solaris ld, 1 for GNU ld 4 | 5 | echo "int main() { return 0; }" > hasgot.c 6 | $cc -v -o tst hasgot.c 2>&1 | grep -s '^ld:' > /dev/null 7 | exit $? 8 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/tclversion.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | main () 6 | { 7 | puts(TCL_VERSION); 8 | } 9 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/auto-aux/trycompile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test "$verbose" = yes; then 3 | echo "trycompile: $cc -o tst $* $cclibs" >&2 4 | $cc -o tst $* $cclibs || exit 100 5 | else 6 | $cc -o tst $* $cclibs 2> /dev/null || exit 100 7 | fi 8 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/config/m.h: -------------------------------------------------------------------------------- 1 | #undef ARCH_SIXTYFOUR 2 | #define SIZEOF_INT 4 3 | #define SIZEOF_LONG 4 4 | #define SIZEOF_PTR 4 5 | #define SIZEOF_SHORT 2 6 | #define ARCH_INT64_TYPE long long 7 | #define ARCH_UINT64_TYPE unsigned long long 8 | #define ARCH_INT64_PRINTF_FORMAT "ll" 9 | #undef ARCH_BIG_ENDIAN 10 | #undef ARCH_ALIGN_DOUBLE 11 | #undef ARCH_ALIGN_INT64 12 | #undef NONSTANDARD_DIV_MOD 13 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/otherlibs/num/.cvsignore: -------------------------------------------------------------------------------- 1 | libnums.x 2 | *.c.x 3 | so_locations 4 | *.so 5 | *.a 6 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/otherlibs/num/bignum/.cvsignore: -------------------------------------------------------------------------------- 1 | libbignum.x 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/otherlibs/num/libnums.clib: -------------------------------------------------------------------------------- 1 | bng.o nat_stubs.o 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/otherlibs/num/nat.h: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Objective Caml */ 4 | /* */ 5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ 6 | /* */ 7 | /* Copyright 1999 Institut National de Recherche en Informatique et */ 8 | /* en Automatique. All rights reserved. This file is distributed */ 9 | /* under the terms of the GNU Library General Public License, with */ 10 | /* the special exception on linking described in file ../../LICENSE. */ 11 | /* */ 12 | /***********************************************************************/ 13 | 14 | /* $Id: nat.h 9547 2010-01-22 12:48:24Z doligez $ */ 15 | 16 | /* Nats are represented as unstructured blocks with tag Custom_tag. */ 17 | 18 | #define Digit_val(nat,pos) (((bng) Data_custom_val(nat))[pos]) 19 | -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/otherlibs/num/nat.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/bigint-3.12/otherlibs/num/nat.ml -------------------------------------------------------------------------------- /lib/bap-0.4/bigint-3.12/otherlibs/num/nums.mllib: -------------------------------------------------------------------------------- 1 | Int_misc Nat Big_int Arith_flags Ratio Num Arith_status 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/configure: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/configure -------------------------------------------------------------------------------- /lib/bap-0.4/doc/Makefile: -------------------------------------------------------------------------------- 1 | PAPERNAME=main 2 | TEXFILES = *.tex 3 | 4 | TEXFILES = $(wildcard *.tex) $(wildcard *.sty)\ 5 | $(wildcard chap-intro/*.tex) $(wildcard chap-intro/*.sty)\ 6 | $(wildcard chap-formalism/*.tex) $(wildcard chap-formalism/*.sty)\ 7 | $(wildcard chap-tools/*.tex) $(wildcard chap-tools/*.sty)\ 8 | $(wildcard chap-examples/*.tex) $(wildcard chap-examples/*.sty)\ 9 | $(wildcard fig/*.pdf) 10 | 11 | 12 | BIBFILES = $(wildcard bibtex/*.bib) 13 | 14 | all: $(PAPERNAME).pdf 15 | 16 | $(PAPERNAME).pdf : $(TEXFILES) $(BIBFILES) $(PAPERNAME).tex 17 | pdflatex $(PAPERNAME) 18 | bibtex $(PAPERNAME) 19 | pdflatex $(PAPERNAME) 20 | pdflatex $(PAPERNAME) 21 | 22 | clean: 23 | rm -f *.ps *.pdf *.dvi *.aux *.log *.blg *.bbl *~ *.ilg *.idx *.out *.in $(PROGS) 24 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-developer.tex: -------------------------------------------------------------------------------- 1 | \chapter{\bap Development Guide} 2 | 3 | \input{chap-developer/overview} 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-examples.tex: -------------------------------------------------------------------------------- 1 | \chapter{Examples} 2 | 3 | In this chapter, we present some hands-on examples that may be useful 4 | to become familiar with BAP's capabilities. 5 | 6 | \input{chap-examples/il} 7 | \input{chap-examples/functions} 8 | \input{chap-examples/conceval} 9 | \input{chap-examples/traces} 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-examples/basic.S: -------------------------------------------------------------------------------- 1 | add %eax, %ebx 2 | shl %cl, %ebx 3 | jc target 4 | jmp elsewhere 5 | 6 | target: 7 | nop 8 | 9 | elsewhere: 10 | nop -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-examples/cdg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/chap-examples/cdg.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-examples/cfg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/chap-examples/cfg.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-examples/cfg_simp.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/chap-examples/cfg_simp.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-examples/ddg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/chap-examples/ddg.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-examples/functions.tex: -------------------------------------------------------------------------------- 1 | \section{Functions} 2 | 3 | In this tutorial, we show how to use the get\_functions command to 4 | extract functions from a binary with debugging symbols. Specifically, 5 | we will look at the \cmdline{/bin/ls} command. First, make sure you 6 | are using a 32-bit executable; BAP does not support x86-64 yet. If we 7 | know the name of a function we want to extract, such as 8 | \cmdline{hash\_table\_ok}, we can extract it using 9 | \cmdline{get\_functions -unroll /bin/ls bap hash\_table\_ok}. This 10 | will produce a file called baphash\_table\_ok.il. We used the 11 | \cmdline{-unroll} option to remove loops by unrolling; this is 12 | important when generating VCs, because generating VCs is generally 13 | only possible for acyclic programs. If we wanted to see if the 14 | function can return zero, we could use topredicate: 15 | \cmdline{topredicate -q -il baphash\_table\_ok.il -post 'R\_EAX:u32 == 16 | 0:u32' -stp-out /tmp/f -solve}. 17 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-examples/test.c: -------------------------------------------------------------------------------- 1 | int g(int y) { 2 | if (y == 42) { return 42; } else { return -1; } 3 | } 4 | 5 | int main(char **argv, int argc) { 6 | return g(42); 7 | } 8 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-formalism.tex: -------------------------------------------------------------------------------- 1 | \chapter{Formalization of \bil} 2 | 3 | At the core of \bap is the \bap intermediate language, called \bil. In 4 | this chapter we present a formalization of \bil. The formalization is 5 | intended to provide an exact description of what we mean by statements 6 | in the IL. 7 | 8 | {\it Note:} In our implementation, as discussed elsewhere, there are 9 | actually several IL's. Throughout this chapter we discuss the IL as 10 | implemented in {\tt ast.ml}. The other IL's differ in uninteresting 11 | ways and are variants of the IL discussed here. In particular, 12 | developers will be interested in {\tt ssa.ml}, which defines the IL in 13 | SSA form, and also does not allow recursively defined expressions 14 | (i.e., it is an SSA three-address code). Thus, this chapter can be 15 | viewed as a specification for the actual code. 16 | 17 | 18 | 19 | \input{chap-formalism/language} 20 | % subsection 21 | 22 | %\input{running-example} 23 | % subsection 24 | %\input{derived} 25 | % subsection 26 | %\input{typecheck} 27 | % subsection 28 | \input{chap-formalism/operational-semantics} 29 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-intro.tex: -------------------------------------------------------------------------------- 1 | \chapter{Introduction} 2 | \input{chap-intro/intro} 3 | \input{chap-intro/overview} -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-tools.tex: -------------------------------------------------------------------------------- 1 | \chapter{The \bap Toolkit} 2 | \input{chap-tools/overview} 3 | \input{chap-tools/obtaining} 4 | \input{chap-tools/toil} 5 | \input{chap-tools/iltrans} 6 | \input{chap-tools/other-utils} 7 | \input{chap-tools/discussion} 8 | %\input{chap-tools/translate} 9 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-tools/obtaining.tex: -------------------------------------------------------------------------------- 1 | \section{Obtaining \bap} 2 | BAP can be found at \url{http://bap.ece.cmu.edu}. 3 | 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/chap-tools/overview.tex: -------------------------------------------------------------------------------- 1 | \section{Toolkit Overview} 2 | 3 | \begin{figure} 4 | \centering 5 | \includegraphics[scale=.8]{fig/toolchain} 6 | \caption{High-level view of tools provided with \bap.} 7 | \label{fig:toolchain-overview} 8 | \end{figure} 9 | 10 | There are several tools built and distributed with \bap. First, we 11 | provide a tool called {\tt toil} which lifts binary code to \bil. 12 | Second, we provide a tool called {\tt iltrans} which takes as input 13 | \bil code, transforms it, and then outputs the resulting \bil 14 | code. Thus, {\tt iltrans} is a mapping from \bil to \bil. Finally, we 15 | provide a set of additional utilities such as one that evaluates \bil 16 | programs, and another that calculates the weakest precondition for a 17 | \bil program. Figure~\ref{fig:toolchain-overview} shows the 18 | relationship of these tools. Different output options include 19 | optimizing the IL, generating CFG's, PDG's, DDG's, and CDG's, 20 | calculating the weakest precondition, and several other options. We 21 | describe these tools at a high level in this chapter. 22 | 23 | {\tt Note:} Each tool provides a {\tt -help} option, which provides 24 | the latest set of command-line options. 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/credits.tex: -------------------------------------------------------------------------------- 1 | \chapter{Credits} 2 | \bap is currently maintained mostly by Ivan Jager. \bap is a complete 3 | rewrite of work David Brumley conducted for his thesis. That work was 4 | called \vine. Contributors to the original Vine code include: Juan 5 | Caballero, Cody Hartwig, Ivan Jager, Eric Li, James Newsome, Pongsin 6 | Poosankam, and Heng Yin. Dawn Song was David's advisor, and provided 7 | funds, food, support, and many other things that made Vine (thus \bap) 8 | possible. 9 | 10 | 11 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/Makefile: -------------------------------------------------------------------------------- 1 | FIGS = $(wildcard *.fig) 2 | 3 | all: $(FIGS:.fig=.pdf) 4 | 5 | %.pdf : %.fig 6 | fig2dev -L pdf $< $@ 7 | 8 | clean: 9 | rm -f $(FIGS:.fig=.pdf) -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/add-shl.dot: -------------------------------------------------------------------------------- 1 | digraph shladd { 2 | labelfontsize=12; 3 | margin=0; 4 | nodesep=.15; 5 | ranksep=.25; 6 | 1 -> 2; 7 | 2 -> 3; 8 | 3 -> 5; 9 | 2 -> 4; 10 | 4 -> 5; 11 | 5 -> 6; 12 | 6 -> 7; 13 | 6 -> 8; 14 | 7 -> 9; 15 | 8 -> 9; 16 | 9 -> 10; 17 | 9 -> 11; 18 | 1 [shape=box,label="eax:=eax+ebx mod 0x100000000"]; 19 | 2 [shape=box,label="if eax+ebx >= 0x100000000"]; 20 | 3 [shape=box,label="OF:=1"]; 21 | 4 [shape=box,label="OF:=0"]; 22 | 5 [shape=box,label="a := a << c"]; 23 | 6 [shape=box,label="if (c == 1) && (bit 32 of eax == bit 31 of eax)"]; 24 | 7 [shape=box,label="OF:=0"]; 25 | 8 [shape=box,label="OF:=1"]; 26 | 9 [shape=box,label="if OF == 1"]; 27 | 10 [shape=box,label=""]; 28 | 11 [shape=box,label = ""]; 29 | } 30 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/add-shl.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/fig/add-shl.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/components.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/fig/components.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/memvsarray-1.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 11 | 900 750 1650 750 12 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 13 | 900 1050 1650 1050 14 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 15 | 900 1350 1650 1350 16 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 17 | 900 375 1650 375 1650 1950 900 1950 900 375 18 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 19 | 900 1650 1650 1650 20 | 4 0 0 50 -1 0 12 0.0000 4 150 720 975 300 memory\001 21 | 4 0 0 50 -1 0 12 0.0000 4 150 420 1050 675 0xdd\001 22 | 4 0 0 50 -1 0 12 0.0000 4 150 420 1050 975 0xcc\001 23 | 4 0 0 50 -1 0 12 0.0000 4 150 420 1050 1575 0xaa\001 24 | 4 0 0 50 -1 0 12 0.0000 4 150 420 1050 1275 0xbb\001 25 | 4 0 0 50 -1 0 12 0.0000 4 150 675 150 375 address\001 26 | 4 0 0 50 -1 0 12 0.0000 4 150 540 300 975 eax+1\001 27 | 4 0 0 50 -1 0 12 0.0000 4 150 540 300 1275 eax+2\001 28 | 4 0 0 50 -1 0 12 0.0000 4 150 540 300 1575 eax+3\001 29 | 4 0 0 50 -1 0 12 0.0000 4 105 315 450 600 eax\001 30 | 4 0 0 50 -1 0 12 0.0000 4 150 540 300 1875 eax+4\001 31 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/memvsarray-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/fig/memvsarray-1.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/memvsarray-2.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 11 | 900 750 1650 750 12 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 13 | 900 1050 1650 1050 14 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 15 | 900 1350 1650 1350 16 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 17 | 900 375 1650 375 1650 1950 900 1950 900 375 18 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 19 | 900 1650 1650 1650 20 | 4 0 0 50 -1 0 12 0.0000 4 150 720 975 300 memory\001 21 | 4 0 0 50 -1 0 12 0.0000 4 150 420 1050 675 0xdd\001 22 | 4 0 0 50 -1 0 12 0.0000 4 150 420 1050 975 0xcc\001 23 | 4 0 0 50 -1 0 12 0.0000 4 150 420 1050 1275 0xbb\001 24 | 4 0 0 50 -1 0 12 0.0000 4 150 675 150 375 address\001 25 | 4 0 0 50 -1 0 12 0.0000 4 150 540 300 975 eax+1\001 26 | 4 0 0 50 -1 0 12 0.0000 4 150 540 300 1275 eax+2\001 27 | 4 0 0 50 -1 0 12 0.0000 4 150 540 300 1575 eax+3\001 28 | 4 0 0 50 -1 0 12 0.0000 4 105 315 450 600 eax\001 29 | 4 0 0 50 -1 0 12 0.0000 4 150 540 300 1875 eax+4\001 30 | 4 0 0 50 -1 0 12 0.0000 4 150 420 1050 1875 0x11\001 31 | 4 0 0 50 -1 0 12 0.0000 4 150 420 1050 1575 0x22\001 32 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/memvsarray-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/fig/memvsarray-2.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/running-example-patch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/fig/running-example-patch.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/running-example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/fig/running-example.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/fig/toolchain.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/doc/fig/toolchain.pdf -------------------------------------------------------------------------------- /lib/bap-0.4/doc/just-formals/Makefile: -------------------------------------------------------------------------------- 1 | PAPERNAME=vine 2 | TEXFILES = *.tex 3 | 4 | TEXFILES = $(wildcard ../*.tex) $(wildcard *.sty) 5 | BIBFILES = $(wildcard bibtex/*.bib) 6 | 7 | all: $(PAPERNAME).pdf 8 | 9 | $(PAPERNAME).pdf : $(TEXFILES) $(BIBFILES) $(PAPERNAME).tex 10 | pdflatex $(PAPERNAME) 11 | pdflatex $(PAPERNAME) 12 | 13 | clean: 14 | rm -f *.ps *.pdf *.dvi *.aux *.log *.blg *.bbl *~ *.ilg *.idx *.out *.in $(PROGS) 15 | -------------------------------------------------------------------------------- /lib/bap-0.4/doc/just-formals/vine.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt,twoside]{article} 2 | 3 | \usepackage[draft]{djb} 4 | \usepackage{shortcuts} 5 | \usepackage{fullpage} 6 | \usepackage{fancyhdr} 7 | \pagestyle{fancyplain} 8 | \usepackage{code} 9 | \usepackage{subfig} 10 | \usepackage{listings} 11 | 12 | \newcommand{\doctitle}{\vine Binary Analysis Infrastructure} 13 | \lhead[\fancyplain{}{\bfseries \thepage}]% 14 | {\fancyplain{}{\bfseries\doctitle}} 15 | \chead[]{} 16 | \rhead[\fancyplain{}{\bfseries\doctitle}]% 17 | {\fancyplain{}{\bfseries \thepage}} 18 | %\lfoot[{\small\scshape Lecture Notes}]{{\small\scshape Lecture Notes}} 19 | \cfoot[]{} 20 | \rfoot[{\small\scshape\date}]{{\small\scshape\date}} 21 | 22 | \title{\doctitle} 23 | \author{David Brumley and Ivan Jager} 24 | \date{} 25 | 26 | 27 | \begin{document} 28 | 29 | \maketitle 30 | 31 | \input{../syntax-table} 32 | \input{../operational-semantics-table} 33 | \end{document} 34 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/Makefile.am: -------------------------------------------------------------------------------- 1 | # Owned and copyright BitBlaze, 2007. All rights reserved. 2 | # Do not copy, disclose, or distribute without explicit written 3 | # permission. 4 | 5 | SUBDIRS= src apps 6 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/TAGS: -------------------------------------------------------------------------------- 1 | 2 | config.h.in,937 3 | #undef HAVE_BZERO4,126 4 | #undef HAVE_FCNTL_H7,202 5 | #undef HAVE_INTTYPES_H10,283 6 | #undef HAVE_LIBBFD13,364 7 | #undef HAVE_LIBIBERTY16,447 8 | #undef HAVE_LIBVEX19,527 9 | #undef HAVE_MALLOC23,648 10 | #undef HAVE_MEMORY_H26,726 11 | #undef HAVE_MEMSET29,801 12 | #undef HAVE_STDBOOL_H32,869 13 | #undef HAVE_STDINT_H35,950 14 | #undef HAVE_STDLIB_H38,1030 15 | #undef HAVE_STRINGS_H41,1111 16 | #undef HAVE_STRING_H44,1192 17 | #undef HAVE_STRSTR47,1267 18 | #undef HAVE_STRTOUL50,1341 19 | #undef HAVE_SYS_STAT_H53,1422 20 | #undef HAVE_SYS_TYPES_H56,1507 21 | #undef HAVE_UNISTD_H59,1590 22 | #undef HAVE__BOOL62,1666 23 | #undef PACKAGE65,1707 24 | #undef PACKAGE_BUGREPORT68,1802 25 | #undef PACKAGE_NAME71,1875 26 | #undef PACKAGE_STRING74,1955 27 | #undef PACKAGE_TARNAME77,2037 28 | #undef PACKAGE_URL80,2109 29 | #undef PACKAGE_VERSION83,2174 30 | #undef SIZEOF_BFD_VMA86,2250 31 | #undef STDC_HEADERS89,2328 32 | #undef VERSION92,2381 33 | #undef VEX_VERSION95,2423 34 | #undef const98,2504 35 | #undef malloc101,2589 36 | #undef size_t104,2669 37 | 38 | /home/p/ropc-repo/bap-0.4/libasmir/src/TAGS,include 39 | 40 | /home/p/ropc-repo/bap-0.4/libasmir/apps/TAGS,include 41 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/apps/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = \ 2 | print-ir \ 3 | lifttrace 4 | 5 | # these executables should depend on libasmir, since they link it in 6 | # statically. 7 | #print-ir_DEPENDENCIES = ../src/libasmir.a 8 | #lifttrace_DEPENDENCIES = ../src/libasmir.a 9 | 10 | print_ir_SOURCES = print-ir.cpp ir_printer.cpp 11 | lifttrace_SOURCES = lifttrace.cpp 12 | LDADD = @ASMIR_DIR@/src/libasmir.a @VEX_DIR@/libvex.a -lbfd -ldl -liberty -lopcodes 13 | # AM_LDFLAGS = -L../src -L@VEX_DIR@ -L@BINUTILS_DIR@ 14 | AM_LDFLAGS = -L@BINUTILS_DIR@ 15 | AM_CXXFLAGS = \ 16 | -I../include \ 17 | -I../src/traces \ 18 | -I@VEX_DIR@/pub -I@BINUTILS_DIR@ 19 | 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/apps/TAGS: -------------------------------------------------------------------------------- 1 | 2 | print-ir.cpp,124 3 | void usage(39,810 4 | void print_prog_insns(54,1294 5 | void print_vex_ir(72,1751 6 | void print_prog_ir(98,2266 7 | int main(113,2642 8 | 9 | lifttrace.cpp,94 10 | static const string help_message 9,201 11 | void help(17,505 12 | void Usage(22,547 13 | int main(28,647 14 | 15 | ir_printer.cpp,26 16 | void print_bap_ir(31,659 17 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/apps/ir_printer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Owned and copyright David Brumley, 2007. All rights reserved. 3 | Do not copy, disclose, or distribute without explicit written 4 | permission. 5 | */ 6 | #ifndef _IR_PRINTER_H 7 | #define _IR_PRINTER_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "asm_program.h" 16 | //#include "disasm-pp.h" 17 | 18 | #include "ir_printer.h" 19 | 20 | extern "C" 21 | { 22 | #include "libvex.h" 23 | } 24 | 25 | #include "irtoir.h" 26 | //#include "typecheck_ir.h" 27 | //#include "irdeendianizer.h" 28 | //#include "ir2xml.h" 29 | 30 | using namespace std; 31 | 32 | // Uncomment to enable typechecking. 33 | //#define NOTYPECHECKING 34 | void print_globals(); 35 | void print_bap_ir(asm_program_t *prog, vector vblocks ); 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/include/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Owned and copyright BitBlaze, 2007. All rights reserved. 3 | Do not copy, disclose, or distribute without explicit written 4 | permission. 5 | */ 6 | #ifndef _COMMON_H 7 | #define _COMMON_H 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | 15 | #include 16 | 17 | #define DEFAULT_IRMAPFILE "./asm2re.map" 18 | #define DEFAULT_TRACEFILE "proctrace.out" 19 | #define DEFAULT_UNROLL 2 20 | #define LIBASMIR_VERSION "0.1" 21 | typedef bfd_vma address_t; 22 | 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/include/info.h: -------------------------------------------------------------------------------- 1 | /* 2 | Owned and copyright BitBlaze, 2007. All rights reserved. 3 | Do not copy, disclose, or distribute without explicit written 4 | permission. 5 | */ 6 | #ifndef _INFO_H 7 | #define _INFO_H 8 | char *libasmir_version(void); 9 | #endif 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/include/jumpbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef __JUMPBUF_H 2 | #define __JUMPBUF_H 3 | 4 | #include 5 | 6 | /* Jump buffer used to return from VEX errors */ 7 | extern jmp_buf vex_error; 8 | extern char jmp_buf_set; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/include/vexmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Owned and copyright BitBlaze, 2007. All rights reserved. 3 | Do not copy, disclose, or distribute without explicit written 4 | permission. 5 | */ 6 | //====================================================================== 7 | // 8 | // Vexmem is a memory management module created for Vexir. See Notes 9 | // for more details. 10 | // 11 | //====================================================================== 12 | 13 | #ifndef __VEXMEM_H 14 | #define __VEXMEM_H 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | #include "libvex.h" 23 | 24 | void *vx_Alloc( Int nbytes ); 25 | void vx_FreeAll(); 26 | IRSB* vx_dopyIRSB ( IRSB* bb ); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/makefile.inc: -------------------------------------------------------------------------------- 1 | VEX_DIR=/home/p/ropc-repo/bap-0.4/VEX 2 | LIBASMIR_CXXFLAGS=-I/home/p/ropc-repo/bap-0.4/VEX/pub -I/home/p/ropc-repo/bap-0.4/src/include -g -O2 3 | LIBASMIR_LDFLAGS=-L/home/p/ropc-repo/bap-0.4/VEX -L/home/p/ropc-repo/bap-0.4/src 4 | LIBASMIR_LIBS=-lasmir -lvex -lbfd -ldl -liberty 5 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | RANLIB = @RANLIB@ 3 | lib_LIBRARIES = libasmir.a 4 | #lib_LTLIBRARIES = libasmir.la 5 | AM_CFLAGS = -I@VEX_DIR@/pub -I../include -Itraces -fPIC -DGET_OPERANDS 6 | AM_CXXFLAGS = $(AM_CFLAGS) 7 | 8 | 9 | libasmir_a_SOURCES = \ 10 | ./old_ir/stmt.cpp \ 11 | ./old_ir/stmt_c.cpp \ 12 | ./old_ir/exp.cpp \ 13 | ./old_ir/exp_c.cpp \ 14 | asm_program.c \ 15 | symbols.c \ 16 | memory_data.cpp \ 17 | irtoir_c.cpp \ 18 | irtoir.cpp \ 19 | irtoir-i386.cpp \ 20 | irtoir-arm.cpp \ 21 | vexir.c \ 22 | vexmem.c \ 23 | ocaml_helpers.c \ 24 | ./traces/readtrace.cpp \ 25 | ./traces/trace.cpp \ 26 | ./traces/trace_v40.cpp \ 27 | ./traces/trace_v41.cpp \ 28 | ./traces/trace_v50.cpp \ 29 | ./traces/reg_mapping.cpp \ 30 | ./traces/pin_frame.h ./traces/pin_frame.cpp \ 31 | ./traces/pin_trace.h ./traces/pin_trace.cpp 32 | libasmir_a_LIBADD = @VEX_DIR@/libvex.a 33 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/ocaml_helpers.c: -------------------------------------------------------------------------------- 1 | #include "asm_program.h" 2 | #include "vexmem.h" 3 | #include 4 | 5 | asection* bfd_sections( bfd *abfd) { 6 | return abfd->sections; 7 | } 8 | 9 | asection* bfd_next_section( asection *s) { 10 | return s->next; 11 | } 12 | 13 | 14 | // bfd_get_section_contents(abfd, section, data, 0, datasize); 15 | 16 | bfd* asmir_get_bfd(asm_program_t *p) { 17 | return p->abfd; 18 | } 19 | 20 | address_t bfd_section_get_vma(asection *s) { 21 | return s->vma; 22 | } 23 | 24 | bfd_size_type bfd_section_get_size(asection *s) { 25 | return s->size; 26 | } 27 | 28 | const char* bfd_section_get_name(asection *s) { 29 | return s->name; 30 | } 31 | 32 | int64_t bfd_section_get_flags(asection *s) { 33 | return s->flags; 34 | } 35 | 36 | void asmir_free_vex_buffers(void) { 37 | vx_FreeAll(); 38 | } 39 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/traces/pin_common.h: -------------------------------------------------------------------------------- 1 | #ifndef _PIN_COMMON_H 2 | #define _PIN_COMMON_H 3 | 4 | // Size of temporary buffers 5 | #define BUFSIZE 128 6 | 7 | #define MAX_INSN_BYTES 15 8 | 9 | #define MAX_VALUES_COUNT 0x30 10 | 11 | #define MAX_CACHEMASK_BTYES 2 12 | 13 | // TODO: Make these values something proper. 14 | #define MAX_FRAME_MEMSIZE sizeof(StdFrame) 15 | #define MAX_FRAME_DISKSIZE 1024 16 | 17 | /** Total syscall args */ 18 | #define MAX_SYSCALL_ARGS 9 19 | /** Number to record on this platform */ 20 | #ifdef _WIN32 21 | #define PLAT_SYSCALL_ARGS MAX_SYSCALL_ARGS 22 | #else 23 | #define PLAT_SYSCALL_ARGS 5 24 | #endif 25 | 26 | 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/traces/readtrace.h: -------------------------------------------------------------------------------- 1 | #ifndef _READTRACE_H_ 2 | #define _READTRACE_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "trace.h" 10 | #include "trace_v40.h" 11 | #include "trace_v41.h" 12 | #include "trace_v50.h" 13 | #include "irtoir.h" 14 | #include "pin_trace.h" 15 | 16 | 17 | extern "C" { 18 | 19 | trace_frames_t* read_frames_from_file(const string &filename, 20 | uint64_t offset, 21 | uint64_t numisns); 22 | 23 | bap_blocks_t * read_trace_from_file(const string &filename, 24 | uint64_t offset, 25 | uint64_t numisns, 26 | bool print, 27 | bool atts, 28 | bool pintrace); 29 | 30 | void destroy_trace_frames(trace_frames_t *v); 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/traces/trace_v40.cpp: -------------------------------------------------------------------------------- 1 | #include "trace_v40.h" 2 | 3 | 4 | Trace_v40::Trace_v40(ifstream * tracefile) : Trace(tracefile) { } 5 | 6 | void Trace_v40::read_taint_record(taint_record_t * rec) 7 | { 8 | trace->read(BLOCK(*rec), TAINT_RECORD_FIXED_SIZE); 9 | int i; 10 | // the number of records is unused in version 40 11 | for ( i = 0 ; i < 3 ; i ++ ) 12 | read_taint_byte_record(&rec->taintBytes[i]); 13 | } 14 | 15 | void Trace_v40::read_operand(OperandVal * operand) 16 | { 17 | trace->read(BLOCK(*operand), OPERAND_VAL_FIXED_SIZE); 18 | int i; 19 | for (i = 0 ; i < 4 ; i ++) 20 | read_taint_record(&operand->records[i]); 21 | } 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/traces/trace_v40.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRACE_V40_H_ 2 | #define _TRACE_V40_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "readtrace.h" 10 | #include "trace_vXX.h" 11 | 12 | class Trace_v40 : public Trace 13 | { 14 | 15 | public: 16 | 17 | Trace_v40(ifstream * tracefile); 18 | void read_taint_record(taint_record_t * rec); 19 | void read_operand(OperandVal * operand); 20 | 21 | 22 | } ; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/traces/trace_v41.cpp: -------------------------------------------------------------------------------- 1 | #include "trace_v41.h" 2 | 3 | Trace_v41::Trace_v41(ifstream * tracefile) : Trace(tracefile) { } 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/traces/trace_v41.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRACE_V41_H_ 2 | #define _TRACE_V41_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "readtrace.h" 10 | #include "trace_vXX.h" 11 | 12 | class Trace_v41 : public Trace 13 | { 14 | 15 | public: 16 | 17 | Trace_v41(ifstream * tracefile); 18 | 19 | } ; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/traces/trace_v50.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRACE_V50_H_ 2 | #define _TRACE_V50_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "readtrace.h" 10 | #include "trace_vXX.h" 11 | 12 | #define ENTRY_HEADER_FIXED_SIZE_v50 24 13 | #define PROC_RECORD_FIXED_SIZE_v50 44 14 | 15 | class Trace_v50 : public Trace 16 | { 17 | 18 | public: 19 | 20 | Trace_v50(ifstream * tracefile); 21 | void read_process(); 22 | void read_entry_header(EntryHeader * eh); 23 | void read_taint_record(taint_record_t * rec); 24 | void read_records(taint_record_t records[MAX_OPERAND_LEN], uint32_t length, uint64_t tainted); 25 | void read_operand(OperandVal * operand); 26 | void consume_header(TraceHeader * hdr); 27 | 28 | } ; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/traces/trace_vXX.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TRACE_VXX_H_ 3 | #define _TRACE_VXX_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "trace.h" 13 | #include "reg_mapping.h" 14 | 15 | class Trace 16 | { 17 | 18 | public: 19 | Trace(ifstream * tracefile); 20 | virtual void read_entry_header(EntryHeader * eh); 21 | virtual void read_taint_record(taint_record_t * rec); 22 | virtual void read_records(taint_record_t records[MAX_OPERAND_LEN], uint32_t length, uint64_t tainted); 23 | virtual void read_operand(OperandVal * operand); 24 | virtual void consume_header(TraceHeader * hdr); 25 | conc_map_vec * operand_status(EntryHeader * eh); 26 | private: 27 | cval_type_t opsize_to_type(int size); 28 | protected: 29 | ifstream * trace; 30 | void read_taint_byte_record(TaintByteRecord * byte_rec); 31 | void read_operands(OperandVal operand[MAX_NUM_OPERANDS], uint8_t num); 32 | void read_module(); 33 | virtual void read_process(); 34 | void read_procs(TraceHeader * hdr); 35 | 36 | } ; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/src/traces/winsyscalls.h: -------------------------------------------------------------------------------- 1 | #ifndef _WINSYSCALLS_H 2 | #define _WINSYSCALLS_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | enum os_t { 9 | OS_NT_SP3, 10 | OS_NT_SP4, 11 | OS_NT_SP5, 12 | OS_NT_SP6, 13 | OS_2K_SP0, 14 | OS_2K_SP1, 15 | OS_2K_SP2, 16 | OS_2K_SP3, 17 | OS_2K_SP4, 18 | OS_XP_SP0, 19 | OS_XP_SP1, 20 | OS_XP_SP2, 21 | OS_XP_SP3, 22 | OS_2003_SP0, 23 | OS_2003_SP1, 24 | OS_VISTA_SP0, 25 | OS_SEVEN_SP0, 26 | }; 27 | 28 | struct SCENTRY { 29 | const char* name; 30 | unsigned int x[17]; 31 | }; 32 | 33 | extern struct SCENTRY syscalls[]; 34 | 35 | // generated by pnf, added xp-sp3 and seven-sp0 to the tables from the ms project 36 | 37 | /* Functions */ 38 | std::auto_ptr get_name(uint32_t, os_t = OS_SEVEN_SP0); 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /lib/bap-0.4/libasmir/stamp-h1: -------------------------------------------------------------------------------- 1 | timestamp for libasmir/config.h 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/m4/ac_ocaml.m4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programa-stic/ropc-llvm/b47668338b66c25c6bad1327ac33d4a4827e66a3/lib/bap-0.4/m4/ac_ocaml.m4 -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml-proj.example/Makefile: -------------------------------------------------------------------------------- 1 | # Project specific source file Makefile 2 | # $Id: Makefile 4076 2010-07-02 17:12:05Z edmcman $ 3 | 4 | export BAP_PROJ_OCAMLDIR=$(BAP_DIR)/../ocaml-proj 5 | 6 | export PROJSOURCES = \ 7 | $(BAP_PROJ_OCAMLDIR)/test.ml 8 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml-proj.example/README: -------------------------------------------------------------------------------- 1 | This is an example project-specific directory. To add it to bap, 2 | move it to bap-dir/../ocaml-proj. -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml-proj.example/test.ml: -------------------------------------------------------------------------------- 1 | let testf () = 2 | "Hooray!\n";; 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/BatListFull.ml: -------------------------------------------------------------------------------- 1 | (** Opening this module will put a more tail-recursive List module 2 | into scope. *) 3 | 4 | (** A complete list module that uses Batteries functions when 5 | possible. 6 | 7 | Why is this not in batteries itself? 8 | *) 9 | 10 | module List = struct 11 | include List 12 | include BatList 13 | end 14 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/asmirconsts.ml: -------------------------------------------------------------------------------- 1 | (** Constants for asmir.ml. These could go in asmir.ml, but then we'd 2 | need an entry in asmir.mli for each one, and well, I'm just lazy. 3 | *) 4 | 5 | (* bfd defs *) 6 | 7 | let (<<) = (lsl) 8 | 9 | let bsf_debugging = 1 << 2 10 | let bsf_function = 1 << 3 11 | 12 | (** no flags *) 13 | let bsec_no_flags = 0x000 14 | (** allocate space when loading *) 15 | let bsec_alloc = 0x001 16 | (** load the section during loading *) 17 | let bsec_load = 0x002 18 | (** section has reloc info *) 19 | let bsec_reloc = 0x004 20 | (** read only *) 21 | let bsec_readonly = 0x008 22 | (** code *) 23 | let bsec_code = 0x010 24 | (** data *) 25 | let bsec_data = 0x020 26 | (** ROM *) 27 | let bsec_rom = 0x040 28 | (* others .... *) 29 | 30 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/cfg_ast.mli: -------------------------------------------------------------------------------- 1 | val v2s : Cfg.AST.G.V.t -> string 2 | 3 | val of_prog : ?special_error:bool -> Ast.program -> Cfg.AST.G.t 4 | 5 | val to_prog : Cfg.AST.G.t -> Ast.program 6 | 7 | val find_entry : Cfg.AST.G.t -> Cfg.AST.G.t * Cfg.AST.G.V.t 8 | val find_error : Cfg.AST.G.t -> Cfg.AST.G.t * Cfg.AST.G.V.t 9 | val find_exit : Cfg.AST.G.t -> Cfg.AST.G.t * Cfg.AST.G.V.t 10 | val find_indirect : Cfg.AST.G.t -> Cfg.AST.G.t * Cfg.AST.G.V.t 11 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/cfg_ssa.mli: -------------------------------------------------------------------------------- 1 | (** 2 | Static Single Assignment translation 3 | 4 | @todo Export trans_cfg, after finding a good name for it. 5 | 6 | @author Ivan Jager 7 | *) 8 | 9 | 10 | val of_astcfg : Cfg.AST.G.t -> Cfg.SSA.G.t 11 | 12 | val of_ast : Ast.program -> Cfg.SSA.G.t 13 | 14 | val to_astcfg : ?remove_temps:bool -> ?dsa:bool -> Cfg.SSA.G.t -> Cfg.AST.G.t 15 | 16 | val to_ast : ?remove_temps:bool -> Cfg.SSA.G.t -> Ast.program 17 | 18 | 19 | type translation_results = { 20 | cfg : Cfg.SSA.G.t; 21 | to_astvar: Var.t -> Var.t; (* Maps SSA vars back to the variable they came from *) 22 | to_ssavar: Var.t -> Var.t; (* Maps AST vars to SSA at end of exit node. *) 23 | } 24 | 25 | val trans_cfg : Cfg.AST.G.t -> translation_results 26 | 27 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/cvc3_grammar.mly: -------------------------------------------------------------------------------- 1 | %{ 2 | let cond_append l = function 3 | | None -> l 4 | | Some(e) -> e ::l 5 | %} 6 | 7 | %token VAR 8 | %token VAL 9 | 10 | %token SEMICOLON 11 | %token LBRACKET RBRACKET 12 | %token EQUAL 13 | %token ASSERT 14 | %token INVALID 15 | %token VALID 16 | %token SAT 17 | %token DASH 18 | %token MODEL 19 | %token COMMA 20 | %token PERIOD 21 | %token EOF 22 | 23 | %start main 24 | %type <(string * int64) list option> main 25 | 26 | %% 27 | 28 | main: 29 | goodresult assertions EOF { Some($2) } 30 | | badresult EOF { None } 31 | ; 32 | 33 | assertions: 34 | /* empty */ { [] } 35 | | assertion assertions { cond_append $2 $1 } 36 | ; 37 | 38 | assertion: 39 | ASSERT LBRACKET VAR EQUAL VAL RBRACKET SEMICOLON { Some($3, $5) } /* BV */ 40 | | ASSERT LBRACKET VAR EQUAL VAR RBRACKET SEMICOLON { None } /* Memory */ 41 | ; 42 | 43 | goodresult: 44 | INVALID PERIOD { } 45 | | SAT MODEL { } 46 | ; 47 | 48 | badresult: 49 | VALID PERIOD { } 50 | ; 51 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/deadcode.mli: -------------------------------------------------------------------------------- 1 | val do_dce : ?globals:Var.t list -> Cfg.SSA.G.t -> Cfg.SSA.G.t * bool 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/debug.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * debug.mli 3 | * 4 | * Made by (David Brumley) 5 | *) 6 | 7 | module type DEBUG = 8 | sig 9 | val debug : bool 10 | val warn : bool 11 | val pdebug : string -> unit 12 | val dprintf : ('a, unit, string, unit) format4 -> 'a 13 | val dtrace : 14 | before:('a -> unit) -> f:('a -> 'b) -> after:('b -> unit) -> 'a -> 'b 15 | val pwarn : string -> unit 16 | val wprintf : ('a, unit, string, unit) format4 -> 'a 17 | end 18 | module type DEBUG_MOD_INFO = 19 | sig 20 | val name : string 21 | val default : [ `Debug | `NoDebug ] 22 | end 23 | module NoDebug : DEBUG 24 | module Make : functor (Module : DEBUG_MOD_INFO) -> DEBUG 25 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/debug_snippets.ml: -------------------------------------------------------------------------------- 1 | (** 2 | Snippets of debugging code 3 | *) 4 | 5 | module D = Debug.Make(struct let name = "Debug_snippets" and default=`Debug end) 6 | open D 7 | 8 | (** AST debugging visitor *) 9 | 10 | let v = object(self) 11 | inherit Ast_visitor.nop 12 | (* Add each variable to definedvars *) 13 | method visit_stmt stmt = 14 | dprintf "Stmt: %s" (Pp.ast_stmt_to_string stmt); 15 | `SkipChildren 16 | end 17 | 18 | let print_astcfg p = 19 | ignore(Ast_visitor.cfg_accept v p) 20 | 21 | let print_ast p = 22 | ignore(Ast_visitor.prog_accept v p) 23 | 24 | let intv_to_string (i,t) = 25 | let e = Ast.Int(i,t) in 26 | Printf.sprintf "%s" (Pp.ast_exp_to_string e) 27 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/disasm.ml: -------------------------------------------------------------------------------- 1 | (** General disassembly stuff *) 2 | 3 | exception Unimplemented 4 | 5 | let disasm_instr arch = 6 | match arch with 7 | | Libbfd.Bfd_arch_i386 -> Disasm_i386.disasm_instr 8 | | _ -> raise Unimplemented 9 | 10 | (** is_temp v returns true iff v is used as a temporary, based on its 11 | name. A temporary is a variable introduced by BAP's lifting process 12 | that is only referenced inside one assembly block. 13 | 14 | The evaluator uses this information to throw away any state stored 15 | for these temporaries once control passes out of an assembly block. 16 | *) 17 | let is_temp (Var.V(_, s, t)) = 18 | (* First try VEX style vars *) 19 | ((String.length s > 2) && (String.sub s 0 2 = "T_")) 20 | || s = "ra" 21 | || s = "t1" 22 | || s = "tmpDEST" 23 | || s = "src1" 24 | || s = "src2" 25 | || s = "tmp" 26 | || s = "t" 27 | 28 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/gcl.mli: -------------------------------------------------------------------------------- 1 | open Ast 2 | type t = 3 | | Assume of exp 4 | | Assign of Var.t * exp 5 | | Assert of exp 6 | | Choice of t * t 7 | | Seq of t * t 8 | | Skip 9 | 10 | (*val of_straightline : ?acc:t -> Ast.stmt list -> t*) 11 | val of_astcfg : ?entry:Cfg.AST.G.V.t -> ?exit:Cfg.AST.G.V.t -> Cfg.AST.G.t -> t 12 | val of_ast : Ast.program -> t 13 | val remove_skips : t -> t 14 | 15 | val passified_of_ssa : 16 | ?entry:Cfg.SSA.G.V.t -> ?exit:Cfg.SSA.G.V.t -> Cfg.SSA.G.t -> t * var list 17 | val passified_of_astcfg : 18 | ?entry:Cfg.AST.G.V.t -> ?exit:Cfg.AST.G.V.t -> Cfg.AST.G.t -> t * var list * (Var.t->Var.t) 19 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/grammar.mly.mli: -------------------------------------------------------------------------------- 1 | (* grammar.mly.mli 2 | This is a fake .mli file to be appended to that produced by ocamlyacc 3 | There doesn't seem to be a good way to say what gets exposed from the 4 | .mly file, so I cobbled this together. 5 | Of course, this requires some hacking of the build system... 6 | --Ivan 7 | *) 8 | 9 | 10 | type scope 11 | 12 | val scope_create : Var.t list -> scope 13 | let scope_set : scope -> unit 14 | let scope_default : scope 15 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/input.mli: -------------------------------------------------------------------------------- 1 | (** Use this to read in a program. 2 | 3 | TODO: Add convenience functions to get SSA directly, and maybe more input 4 | options. 5 | *) 6 | 7 | open Arg 8 | open Grammar_scope 9 | 10 | (** A speclist suitable to pass to Arg.parse. 11 | Add this to the speclist for your program. *) 12 | val speclist : (key * spec * doc) list 13 | 14 | val stream_speclist : (key * spec * doc) list 15 | 16 | (** Get the program as specified by the commandline. *) 17 | val get_program : unit -> Ast.program * Scope.t 18 | 19 | val get_stream_program : unit -> (Ast.program) Stream.t 20 | 21 | val init_ro : bool ref 22 | 23 | (* This really should go elsewhere! *) 24 | val set_gc : unit -> unit 25 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/parser.ml: -------------------------------------------------------------------------------- 1 | (** Bap interface to the parser. *) 2 | 3 | open Grammar_scope 4 | 5 | let program_from_lexbuf ?(scope=default_scope ()) l = 6 | set_scope scope; 7 | let p = Grammar.program Lexer.token l in 8 | Parsing.clear_parser(); 9 | p, get_scope() 10 | 11 | let program_from_file ?(scope=default_scope ()) f = 12 | let ic = open_in f in 13 | let lb = Lexing.from_channel ic in 14 | lb.Lexing.lex_curr_p <- { lb.Lexing.lex_curr_p with Lexing.pos_fname = f }; 15 | let p = program_from_lexbuf lb ~scope in 16 | close_in ic; 17 | p 18 | 19 | 20 | let exp_from_lexbuf ?(scope=default_scope ()) l = 21 | set_scope scope; 22 | let e = Grammar.expr Lexer.token l in 23 | Parsing.clear_parser(); 24 | e, get_scope() 25 | 26 | let exp_from_string ?(scope=default_scope ()) s = 27 | exp_from_lexbuf (Lexing.from_string s) ~scope 28 | 29 | let exp_from_file ?(scope=default_scope ()) f = 30 | let ic = open_in f in 31 | let lb = Lexing.from_channel ic in 32 | lb.Lexing.lex_curr_p <- { lb.Lexing.lex_curr_p with Lexing.pos_fname = f }; 33 | let e = exp_from_lexbuf lb ~scope in 34 | close_in ic; 35 | e 36 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/prune_unreachable.ml: -------------------------------------------------------------------------------- 1 | (** Code for removing unreachable nodes in a CFG. *) 2 | 3 | module D = Debug.Make(struct let name = "Prune_unreachable" and default=`Debug end) 4 | module R = Reachable 5 | 6 | let prune_unreachable_ast g = 7 | R.AST.remove_unreachable g (Cfg.AST.G.V.create Cfg.BB_Entry) 8 | 9 | let prune_unreachable_ssa g = 10 | R.SSA.remove_unreachable g (Cfg.SSA.G.V.create Cfg.BB_Entry) 11 | 12 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/prune_unreachable.mli: -------------------------------------------------------------------------------- 1 | val prune_unreachable_ast : Cfg.AST.G.t -> Cfg.AST.G.t 2 | 3 | val prune_unreachable_ssa : Cfg.SSA.G.t -> Cfg.SSA.G.t 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/reachable.mli: -------------------------------------------------------------------------------- 1 | (** Reachability analysis 2 | 3 | $Id: reachable.mli 5241 2011-09-21 23:20:19Z edmcman $ 4 | *) 5 | module type B = 6 | sig 7 | module G : Graph.Traverse.G 8 | 9 | val remove_vertex : G.t -> G.V.t -> G.t 10 | 11 | end 12 | 13 | module type Reach = 14 | sig 15 | 16 | type gt 17 | type vt 18 | 19 | val iter_reachable : (vt -> unit) -> gt -> vt -> unit 20 | val iter_unreachable : (vt -> unit) -> gt -> vt -> unit 21 | 22 | val fold_reachable : (vt -> 'a -> 'a) -> gt -> vt -> 'a -> 'a 23 | val fold_unreachable : (vt -> 'a -> 'a) -> gt -> vt -> 'a -> 'a 24 | 25 | val reachable : gt -> vt -> vt list 26 | val unreachable : gt -> vt -> vt list 27 | 28 | val remove_unreachable : gt -> vt -> gt 29 | end 30 | 31 | module Make : 32 | functor (BI : B) -> 33 | Reach with type gt = BI.G.t and type vt = BI.G.V.t 34 | 35 | module AST : (Reach with type gt = Cfg.AST.G.t and type vt = Cfg.AST.G.V.t) 36 | module SSA : (Reach with type gt = Cfg.SSA.G.t and type vt = Cfg.SSA.G.V.t) 37 | 38 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/sccvn.mli: -------------------------------------------------------------------------------- 1 | val replacer : ?opt:bool -> Cfg.SSA.G.t -> Cfg.SSA.G.t * bool 2 | val aliased : Cfg.SSA.G.t -> Ssa.value -> Ssa.value -> bool option 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/ssa_simp.ml: -------------------------------------------------------------------------------- 1 | (** SSA simplifications 2 | 3 | This uses all supported simplifications to try to optimize as much as possible. 4 | *) 5 | 6 | let simp_cfg ?(liveout=[]) ?(usedc=true) ?(usesccvn=true) ?(usemisc=true) cfg = 7 | let cfgref = ref cfg in 8 | let changed = ref true in 9 | while !changed do 10 | let (cfg,c1) = if usesccvn then Sccvn.replacer ~opt:true !cfgref else (!cfgref,false) in 11 | let (cfg,c2) = if usedc then Deadcode.do_dce ~globals:liveout cfg else (cfg,false) in 12 | let (cfg,c3) = if usemisc then Ssa_simp_misc.cfg_jumpelim cfg else (cfg,false) in 13 | cfgref := cfg; 14 | changed := c1 || c2 || c3 15 | done; 16 | !cfgref 17 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/stp_grammar.mly: -------------------------------------------------------------------------------- 1 | 2 | %token VAR 3 | %token VAL 4 | 5 | %token SEMICOLON 6 | %token LBRACKET RBRACKET 7 | %token EQUAL 8 | %token ASSERT 9 | %token INVALID 10 | %token VALID 11 | %token COMMA 12 | %token PERIOD 13 | %token EOF 14 | 15 | %start main 16 | %type <(string * int64) list option> main 17 | 18 | %% 19 | 20 | main: 21 | /* The result comes before or after the assertions depending on version. */ 22 | assertions goodresult EOF { Some($1) } 23 | | goodresult assertions EOF { Some($2) } 24 | | badresult EOF { None } 25 | ; 26 | 27 | assertions: 28 | /* empty */ { [] } 29 | | assertion SEMICOLON assertions { $1 :: $3 } 30 | ; 31 | 32 | assertion: 33 | ASSERT LBRACKET VAR EQUAL VAL RBRACKET { ($3, $5) } 34 | ; 35 | 36 | goodresult: 37 | INVALID PERIOD { } 38 | ; 39 | 40 | badresult: 41 | VALID PERIOD { } 42 | ; 43 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/stp_lexer.mll: -------------------------------------------------------------------------------- 1 | { 2 | open Stp_grammar 3 | (* TODO: add support for memories *) 4 | } 5 | 6 | let digit = ['0'-'9''A'-'F''a'-'f'] 7 | let varname = ['A'-'Z''a'-'z']['A'-'Z''a'-'z''0'-'9''_''['']']* 8 | 9 | rule token = parse 10 | | [' ' '\t' '\n'] { token lexbuf } 11 | | '=' { EQUAL } 12 | | ',' { COMMA } 13 | | '.' { PERIOD } 14 | | ';' { SEMICOLON } 15 | | '(' { LBRACKET } 16 | | ')' { RBRACKET } 17 | | "ASSERT" { ASSERT } 18 | | "Invalid" { INVALID } 19 | | "Valid" { VALID } 20 | | "0hex" { read_num lexbuf } 21 | | "0x" { read_num lexbuf } 22 | | "0b" { read_num lexbuf } 23 | | varname as var { VAR var } 24 | | eof { EOF } 25 | | _ { token lexbuf } 26 | 27 | and read_num = parse 28 | | digit+ as n { VAL(Int64.of_string ("0x"^n)) } 29 | | _ { token lexbuf } 30 | 31 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/type.ml: -------------------------------------------------------------------------------- 1 | type.mli -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/typesig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ocamlfind ocamlc -package str,ocamlgraph,extlib,unix,sqlite3 -c -i -for-pack Bap -for-pack Bap $1 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/utils_common.ml: -------------------------------------------------------------------------------- 1 | (** Functions that are used by utilities and tests *) 2 | 3 | open Ast 4 | open Type 5 | 6 | 7 | (* For solving predicates *) 8 | let rename_astexp f = 9 | let vis = object 10 | inherit Ast_visitor.nop 11 | method visit_rvar v = 12 | try `ChangeTo(f v) 13 | with Not_found -> `DoChildren 14 | end in 15 | Ast_visitor.exp_accept vis;; 16 | 17 | 18 | let to_ssagcl cfg post = 19 | let cfg = Hacks.remove_backedges cfg in 20 | let cfg = Coalesce.AST_Coalesce.coalesce cfg in 21 | let {Cfg_ssa.cfg=cfg; to_ssavar=tossa} = Cfg_ssa.trans_cfg cfg in 22 | let p = rename_astexp tossa post in 23 | let cfg = 24 | let vars = Formulap.freevars p in 25 | Ssa_simp.simp_cfg ~liveout:vars ~usedc:true ~usesccvn:true cfg 26 | in 27 | let cfg = Cfg_ssa.to_astcfg cfg in 28 | let gcl = Gcl.of_astcfg cfg in 29 | (gcl, p);; 30 | 31 | 32 | (* For type checking. Temporary home. *) 33 | let typecheck p = 34 | let v = object(self) 35 | inherit Ast_visitor.nop 36 | method visit_exp e = ignore(Typecheck.infer_ast ~check:true e); `DoChildren 37 | end 38 | in 39 | ignore(Ast_visitor.prog_accept v p); 40 | p 41 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/var.mli: -------------------------------------------------------------------------------- 1 | type t = private V of int * string * Type.typ 2 | 3 | val newvar : string -> Type.typ -> t 4 | val renewvar : t -> t 5 | 6 | val typ : t -> Type.typ 7 | val name : t -> string 8 | 9 | 10 | val hash : t -> int 11 | val equal : t -> t -> bool 12 | val compare : t -> t -> int 13 | 14 | module VarHash : Hashtbl.S with type key = t 15 | module VarMap : Map.S with type key = t 16 | module VarSet : Set.S with type elt = t 17 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/yices_grammar.mly: -------------------------------------------------------------------------------- 1 | 2 | %token VAR 3 | %token VAL 4 | 5 | %token SEMICOLON 6 | %token LBRACKET RBRACKET 7 | %token EQUAL 8 | %token MODEL 9 | %token ASSERT 10 | %token DASHES 11 | %token INVALID 12 | %token VALID 13 | %token COMMA 14 | %token PERIOD 15 | %token EOF 16 | 17 | %start main 18 | %type <(string * int64) list option> main 19 | 20 | %% 21 | 22 | main: 23 | /* The result comes before or after the assertions depending on version. */ 24 | goodresult MODEL assertions DASHES EOF { Some($3) } 25 | | badresult EOF { None } 26 | ; 27 | 28 | assertions: 29 | /* empty */ { [] } 30 | | assertion assertions { $1 :: $2 } 31 | ; 32 | 33 | assertion: 34 | LBRACKET EQUAL VAR VAL RBRACKET { ($3, $4) } 35 | ; 36 | 37 | goodresult: 38 | INVALID { } 39 | ; 40 | 41 | badresult: 42 | VALID { } 43 | ; 44 | -------------------------------------------------------------------------------- /lib/bap-0.4/ocaml/yices_lexer.mll: -------------------------------------------------------------------------------- 1 | { 2 | open Yices_grammar 3 | (* TODO: add support for memories *) 4 | } 5 | 6 | let digit = ['0'-'9''A'-'F''a'-'f'] 7 | let varname = ['A'-'Z''a'-'z']['A'-'Z''a'-'z''0'-'9''_''['']']* 8 | 9 | rule token = parse 10 | | [' ' '\t' '\n'] { token lexbuf } 11 | | '=' { EQUAL } 12 | | ',' { COMMA } 13 | | '.' { PERIOD } 14 | | ';' { SEMICOLON } 15 | | '(' { LBRACKET } 16 | | ')' { RBRACKET } 17 | | "----" { DASHES } 18 | | "MODEL" { MODEL } 19 | | "ASSERT" { ASSERT } 20 | | "sat" { INVALID } 21 | | "unsat" { VALID } 22 | | "0hex" { read_num lexbuf } 23 | | "0x" { read_num lexbuf } 24 | | "0b" { read_num lexbuf } 25 | | varname as var { VAR var } 26 | | eof { EOF } 27 | | _ { token lexbuf } 28 | 29 | and read_num = parse 30 | | digit+ as n { VAL(Int64.of_string ("0b"^n)) } 31 | | _ { token lexbuf } 32 | 33 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/AUTHORS.txt: -------------------------------------------------------------------------------- 1 | (* OASIS_START *) 2 | (* DO NOT EDIT (digest: 2915822545ee2a6c6708508e9418550d) *) 3 | Authors of ounit 4 | Maas-Maarten Zeeman 5 | Sylvain Le Gall 6 | (* OASIS_STOP *) 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/INSTALL.txt: -------------------------------------------------------------------------------- 1 | (* OASIS_START *) 2 | (* DO NOT EDIT (digest: 627d51f68b9605a93c539a6c449eb1d4) *) 3 | This is the INSTALL file for the ounit distribution. 4 | 5 | This package uses OASIS to generate its build system. See section OASIS for 6 | full information. 7 | 8 | Dependencies 9 | ============ 10 | 11 | In order to compile this package, you will need: 12 | * ocaml for all, test main, doc api-ounit 13 | * findlib 14 | 15 | Installing 16 | ========== 17 | 18 | 1. Uncompress source directory and got to the root of the package 19 | 2. Run 'ocaml setup.ml -configure' 20 | 3. Run 'ocaml setup.ml -build' 21 | 4. Run 'ocaml setup.ml -install' 22 | 23 | Uninstalling 24 | ============ 25 | 26 | 1. Go to the root of the package 27 | 2. Run 'ocaml setup.ml -uninstall' 28 | 29 | OASIS 30 | ===== 31 | 32 | OASIS is a software that helps to write setup.ml using a simple '_oasis' 33 | configuration file. The generated setup only depends on standard OCaml 34 | installation, no additional library is required. 35 | 36 | (* OASIS_STOP *) 37 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/Makefile: -------------------------------------------------------------------------------- 1 | #TESTFLAGS=-only-test "OUnit:1" 2 | default: test 3 | 4 | # OASIS_START 5 | # DO NOT EDIT (digest: bc1e05bfc8b39b664f29dae8dbd3ebbb) 6 | 7 | SETUP = ocaml setup.ml 8 | 9 | build: setup.data 10 | $(SETUP) -build $(BUILDFLAGS) 11 | 12 | doc: setup.data build 13 | $(SETUP) -doc $(DOCFLAGS) 14 | 15 | test: setup.data build 16 | $(SETUP) -test $(TESTFLAGS) 17 | 18 | all: 19 | $(SETUP) -all $(ALLFLAGS) 20 | 21 | install: setup.data 22 | $(SETUP) -install $(INSTALLFLAGS) 23 | 24 | uninstall: setup.data 25 | $(SETUP) -uninstall $(UNINSTALLFLAGS) 26 | 27 | reinstall: setup.data 28 | $(SETUP) -reinstall $(REINSTALLFLAGS) 29 | 30 | clean: 31 | $(SETUP) -clean $(CLEANFLAGS) 32 | 33 | distclean: 34 | $(SETUP) -distclean $(DISTCLEANFLAGS) 35 | 36 | setup.data: 37 | $(SETUP) -configure $(CONFIGUREFLAGS) 38 | 39 | .PHONY: build doc test all install uninstall reinstall clean distclean configure 40 | 41 | # OASIS_STOP 42 | 43 | doc-test: doc 44 | ocamldoc -g ../ocaml-tmp/odoc-extract-code/odoc_extract_code.cmo \ 45 | -load _build/src/oUnit.odoc -intro doc/manual.txt > _build/src/tmp.ml; 46 | ocamlc -c -I _build/src/ _build/src/tmp.ml 47 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/README.txt: -------------------------------------------------------------------------------- 1 | (* OASIS_START *) 2 | (* DO NOT EDIT (digest: ac260da3dc5dbc8b63343daec02e41ac) *) 3 | This is the README file for the ounit distribution. 4 | 5 | (C) 2002-2008 Maas-Maarten Zeeman 6 | 7 | (C) 2010 OCamlCore SARL 8 | 9 | Unit testing framework 10 | 11 | OUnit is a unit testing framework for OCaml, inspired by the JUnit tool for 12 | Java, and the HUnit tool for Haskell. 13 | 14 | More information on [HUnit](http://hunit.sourceforge.net) 15 | 16 | See the files INSTALL.txt for building and installation instructions. See the 17 | file LICENSE.txt for copying conditions. 18 | 19 | Home page: http://ounit.forge.ocamlcore.org 20 | 21 | 22 | (* OASIS_STOP *) 23 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/_tags: -------------------------------------------------------------------------------- 1 | # OASIS_START 2 | # DO NOT EDIT (digest: 0088b53de37859f3fccc66e8de54b35e) 3 | # Library oUnit 4 | "src": include 5 | : oasis_library_ounit_byte 6 | : oasis_library_ounit_byte 7 | : oasis_library_ounit_native 8 | : oasis_library_ounit_native 9 | : pkg_unix 10 | # Executable test 11 | "test/test.byte": use_oUnit 12 | "test/test.byte": pkg_unix 13 | : use_oUnit 14 | : pkg_unix 15 | # OASIS_STOP 16 | "src/oUnit.ml": syntax_camlp4o, pkg_camlp4.macro 17 | "src/oUnit.odoc": oasis_document_api_ounit 18 | "src/oUnit.ml": oasis_document_api_ounit 19 | "src/api-ounit.docdir": oasis_document_api_ounit 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/configure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # OASIS_START 4 | # DO NOT EDIT (digest: ed33e59fe00e48bc31edf413bbc8b8d6) 5 | set -e 6 | 7 | ocaml setup.ml -configure $* 8 | # OASIS_STOP 9 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/examples/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | 4 | TESTS = test_list.ml test_list2.ml test_stack.ml 5 | 6 | test: test_suite 7 | ./test_suite 8 | 9 | test_suite: $(TESTS) test_suite.ml 10 | ocamlfind ocamlc -o test_suite -package oUnit -linkpkg \ 11 | test_list.ml test_list2.ml test_stack.ml test_suite.ml 12 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/examples/example.ml: -------------------------------------------------------------------------------- 1 | open OUnit 2 | 3 | let empty_list = [] 4 | let list_a = [1;2;3] 5 | 6 | let test_list_length _ = 7 | assert_equal 1 (List.length empty_list); 8 | assert_equal 3 (List.length list_a) 9 | (* etc, etc *) 10 | 11 | let test_list_append _ = 12 | let list_b = List.append empty_list [1;2;3] in 13 | assert_equal list_b list_a 14 | 15 | let suite = "OUnit Example" >::: ["test_list_length" >:: test_list_length; 16 | "test_list_append" >:: test_list_append] 17 | let _ = 18 | let verbose = ref false in 19 | let set_verbose _ = verbose := true in 20 | Arg.parse 21 | [("-verbose", Arg.Unit set_verbose, "Run the test in verbose mode.");] 22 | (fun x -> raise (Arg.Bad ("Bad argument : " ^ x))) 23 | ("usage: " ^ Sys.argv.(0) ^ " [-verbose]"); 24 | if not (was_successful (run_test_tt ~verbose:!verbose suite)) then 25 | exit 1 26 | 27 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/examples/test_list.ml: -------------------------------------------------------------------------------- 1 | open OUnit 2 | 3 | let empty_list = [] 4 | let list_a = [1;2;3] 5 | 6 | let test_list_length _ = 7 | assert_equal 1 (List.length empty_list); 8 | assert_equal 3 (List.length list_a) 9 | (* etc, etc *) 10 | 11 | let test_list_append _ = 12 | let list_b = List.append empty_list [1;2;3] in 13 | assert_equal list_b list_a 14 | 15 | let suite = "OUnit Example" >::: ["test_list_length" >:: test_list_length; 16 | "test_list_append" >:: test_list_append] 17 | 18 | (* 19 | let _ = 20 | run_test_tt_main suite 21 | *) 22 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/examples/test_list2.ml: -------------------------------------------------------------------------------- 1 | open OUnit 2 | 3 | let empty_list = [] 4 | let list_a = [1;2;3] 5 | 6 | let test_list_length _ = 7 | assert_equal 1 (List.length empty_list); 8 | assert_equal 3 (List.length list_a) 9 | (* etc, etc *) 10 | 11 | let test_list_append _ = 12 | let list_b = List.append empty_list [1;2;3] in 13 | assert_equal list_b list_a 14 | 15 | let suite = "Test_list2" >::: ["test_list_length2" >:: test_list_length; 16 | "test_list_append2" >:: test_list_append] 17 | 18 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/examples/test_stack.ml: -------------------------------------------------------------------------------- 1 | open OUnit 2 | 3 | (* 4 | * This test shows how brackets can be used. They are handy to create 5 | * a so called fixture, which can be used for multiple tests 6 | *) 7 | 8 | (* prepare a stack for test *) 9 | let setup _ = 10 | let s = Stack.create () in 11 | Stack.push 1 s; 12 | Stack.push 2 s; 13 | Stack.push 3 s; 14 | s 15 | 16 | let teardown _ = 17 | () 18 | 19 | let test_top stack = 20 | assert_equal 3 (Stack.top stack) 21 | 22 | let test_clear stack = 23 | Stack.clear stack; 24 | assert_raises Stack.Empty (fun _ -> Stack.top stack) 25 | 26 | let test_pop stack = 27 | assert_equal 3 (Stack.pop stack); 28 | assert_equal 2 (Stack.pop stack); 29 | assert_equal 1 (Stack.pop stack); 30 | assert_raises Stack.Empty (fun _ -> Stack.pop stack) 31 | 32 | let suite = "Test Stack" >::: 33 | ["test_top" >:: (bracket setup test_top teardown); 34 | "test_clear" >:: (bracket setup test_clear teardown); 35 | "test_pop" >:: (bracket setup test_pop teardown)] 36 | 37 | 38 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/examples/test_suite.ml: -------------------------------------------------------------------------------- 1 | open OUnit 2 | 3 | (* Collect the tests of different modules into one test suite *) 4 | let suite = "OUnit Example" >::: 5 | [Test_list.suite; 6 | Test_list2.suite; 7 | Test_stack.suite] 8 | 9 | let _ = 10 | run_test_tt_main suite 11 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/src/META: -------------------------------------------------------------------------------- 1 | # OASIS_START 2 | # DO NOT EDIT (digest: 2c7c46bf19549023a15c452c2d9077bc) 3 | version = "1.1.0" 4 | description = "Unit testing framework" 5 | requires = "unix" 6 | archive(byte) = "oUnit.cma" 7 | archive(native) = "oUnit.cmxa" 8 | exists_if = "oUnit.cma" 9 | # OASIS_STOP 10 | 11 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/src/api-ounit.odocl: -------------------------------------------------------------------------------- 1 | # OASIS_START 2 | # DO NOT EDIT (digest: badb307dc88ab237e46550b25a383039) 3 | OUnit 4 | OUnitDiff 5 | # OASIS_STOP 6 | -------------------------------------------------------------------------------- /lib/bap-0.4/ounit-1.1.0/src/oUnit.mllib: -------------------------------------------------------------------------------- 1 | # OASIS_START 2 | # DO NOT EDIT (digest: badb307dc88ab237e46550b25a383039) 3 | OUnit 4 | OUnitDiff 5 | # OASIS_STOP 6 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/.hg_archival.txt: -------------------------------------------------------------------------------- 1 | repo: 1062d19ece6f075dbc2fff3238732629f8005eb1 2 | node: 853c8a72818fdb44b4268bbe27228af44843f7d3 3 | branch: default 4 | tag: release-6.2.5 5 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/.hgignore: -------------------------------------------------------------------------------- 1 | (^|/)\.bzr($|/) 2 | (^|/)\.hg($|/) 3 | (^|/)\.hgtags($|/) 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/.hgtags: -------------------------------------------------------------------------------- 1 | 6d8dd1e9604e23e1566e75293eef56dcde305a7e release 5.15.0 2 | 16e59144fcff07bea0f0920eb095a5970a331aef release 5.15.1 3 | 0000000000000000000000000000000000000000 release 5.15.1 4 | 0000000000000000000000000000000000000000 release 5.15.0 5 | 6d8dd1e9604e23e1566e75293eef56dcde305a7e release-5.15.0 6 | 16e59144fcff07bea0f0920eb095a5970a331aef release-5.15.1 7 | e58db995479b47db970a02e3cd3a57bf36716d8c release-5.16.0 8 | f9d914eaef5b8c68ed5d835e4098f7d3285fda19 release-5.16.1 9 | 231d62c5d66e187f810222976f92e9aa27958eab release-5.16.2 10 | 1ff0346e6cca02d4aa3d4aae1aa6ff266b1adab0 release-5.16.3 11 | 7500100fe2d7c42e7687231fd7ababcbee5abfbd release-5.16.4 12 | adf5cb6ffff604dadd2e299750a028a6af2ccc70 release-5.16.5 13 | 9f768785f76ab3f3e4d44fe11f6de7797f476a93 release-6.0.0 14 | b3f3e6899e80a86acc7037548f3226596e76782f release-6.0.1 15 | 3dd5b45ff8448beba17d9a1ecec47661d69d15e1 release-6.1.0 16 | fb29e7be9814fd4c835d56631509916d8d76c9c5 release-6.1.1 17 | 216aa5cc997b85f8c0784b6a9cc530f1961391aa release-6.2.2 18 | d3debcff192d7911d1c11fc9c148146099ec125d release-6.2.3 19 | ec6cbe5b8c3bcbe85e50df42afdd3b0583ae6c72 release-6.2.4 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/Makefile: -------------------------------------------------------------------------------- 1 | -include Makefile.conf 2 | 3 | EXAMPLES = $(filter-out examples/OMakefile examples/CVS, $(wildcard examples/*)) 4 | 5 | .PHONY: all 6 | all: 7 | @cd lib && $(MAKE) byte-code-library native-code-library 8 | 9 | .PHONY: examples 10 | examples: 11 | @for dir in $(EXAMPLES); do (cd $$dir && $(MAKE)); done 12 | 13 | .PHONY: doc 14 | doc: 15 | @cd lib && $(MAKE) $@ 16 | ln -sf lib/doc 17 | 18 | .PHONY: htdoc 19 | htdoc: 20 | @cd lib && $(MAKE) $@ 21 | 22 | .PHONY: install 23 | install: 24 | @cd lib && $(MAKE) $@ 25 | 26 | .PHONY: uninstall 27 | uninstall: 28 | @cd lib && $(MAKE) $@ 29 | 30 | .PHONY: clean 31 | clean: 32 | @cd lib && $(MAKE) clean 33 | @for dir in $(EXAMPLES); do (cd $$dir && $(MAKE) $@); done 34 | @rm -f doc 35 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/Makefile.conf: -------------------------------------------------------------------------------- 1 | # export STATIC = yes 2 | # export INCDIRS := /usr/include/pcre 3 | # export LIBDIRS := 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/OMakefile: -------------------------------------------------------------------------------- 1 | Subdirs() 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/OMakefile: -------------------------------------------------------------------------------- 1 | OCAML_LIBRARIES = pcre 2 | 3 | Subdirs() 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/cloc/Makefile: -------------------------------------------------------------------------------- 1 | OCAMLMAKEFILE = ../../OCamlMakefile 2 | 3 | SOURCES = cloc.ml 4 | INCDIRS = ../../lib 5 | LIBDIRS = ../../lib 6 | LIBS = pcre 7 | RESULT = cloc 8 | 9 | -include $(OCAMLMAKEFILE) 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/cloc/OMakefile: -------------------------------------------------------------------------------- 1 | OCamlMakeProjDefaults(cloc.exe) 2 | 3 | InstantiateOCamlEnv() 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/cloc/README: -------------------------------------------------------------------------------- 1 | This program reads C-sources from stdin and prints them to stdout with 2 | comments and empty lines removed. - A very primitive way of counting LOCs. 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/cloc/cloc.ml: -------------------------------------------------------------------------------- 1 | open Pcre 2 | 3 | let read_whole_channel ch = 4 | let size = 4096 in 5 | let strbuf = String.create size 6 | and buf = Buffer.create 65536 7 | and len = ref size in 8 | while !len <> 0 do 9 | len := input ch strbuf 0 size; 10 | Buffer.add_substring buf strbuf 0 !len; done; 11 | Buffer.contents buf 12 | 13 | let _ = 14 | let str = read_whole_channel stdin in 15 | let str = qreplace ~pat:"/\\*(.|\n)*?\\*/" str in 16 | let str = qreplace_first ~pat:"^(\n|\\s)+" str in 17 | let str = qreplace ~pat:"\n+((\n|\\s)\n)*" ~templ:"\n" str in 18 | print_string str 19 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/cloc/make_win32_cloc.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set OCAMLC=ocamlc -g 4 | set OCAMLOPT=ocamlopt 5 | 6 | set MAIN=cloc 7 | 8 | @echo on 9 | %OCAMLC% -o %MAIN%.exe pcre.cma %MAIN%.ml 10 | %OCAMLOPT% -o %MAIN%.com pcre.cmxa %MAIN%.ml 11 | 12 | @REM Example use: 13 | @REM %MAIN%.exe < ..\..\lib\pcre_stubs.c 14 | @REM %MAIN%.com < ..\..\lib\pcre_stubs.c 15 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/count_hash/Makefile: -------------------------------------------------------------------------------- 1 | OCAMLMAKEFILE = ../../OCamlMakefile 2 | 3 | SOURCES = count_hash.ml 4 | INCDIRS = ../../lib 5 | LIBDIRS = ../../lib 6 | LIBS = pcre 7 | RESULT = count_hash 8 | 9 | -include $(OCAMLMAKEFILE) 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/count_hash/OMakefile: -------------------------------------------------------------------------------- 1 | OCamlMakeProjDefaults(count_hash.exe) 2 | 3 | InstantiateOCamlEnv() 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/count_hash/README: -------------------------------------------------------------------------------- 1 | This program reads in text from stdin, counts all equal words that are 2 | separated by whitespace and prints the result to stdout. 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/count_hash/count_hash.ml: -------------------------------------------------------------------------------- 1 | open Hashtbl 2 | 3 | let hash = create 1973 4 | let add_string s = try incr (find hash s) with Not_found -> add hash s (ref 1);; 5 | Pcre.foreach_line (fun line -> List.iter add_string (Pcre.split line)); 6 | iter (fun k v -> Printf.printf "%4d\t%s\n" !v k) hash 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/pcregrep/Makefile: -------------------------------------------------------------------------------- 1 | OCAMLMAKEFILE = ../../OCamlMakefile 2 | 3 | SOURCES = pcregrep.ml 4 | INCDIRS = ../../lib 5 | LIBDIRS = ../../lib 6 | LIBS = pcre 7 | RESULT = pcregrep 8 | 9 | -include $(OCAMLMAKEFILE) 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/pcregrep/OMakefile: -------------------------------------------------------------------------------- 1 | OCamlMakeProjDefaults(pcregrep.exe) 2 | 3 | InstantiateOCamlEnv() 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/pcregrep/README: -------------------------------------------------------------------------------- 1 | Start the program with argument "-help" to see what it does! 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/subst/Makefile: -------------------------------------------------------------------------------- 1 | OCAMLMAKEFILE = ../../OCamlMakefile 2 | 3 | SOURCES = subst.ml 4 | INCDIRS = ../../lib 5 | LIBDIRS = ../../lib 6 | LIBS = pcre 7 | RESULT = subst 8 | 9 | -include $(OCAMLMAKEFILE) 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/subst/OMakefile: -------------------------------------------------------------------------------- 1 | OCamlMakeProjDefaults(subst.exe) 2 | 3 | InstantiateOCamlEnv() 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/examples/subst/README: -------------------------------------------------------------------------------- 1 | Start the program with argument "-help" to see what it does! 2 | 3 | Example invocation: 4 | 5 | subst '([Tt])ermcap' '$1ermCap' < /etc/termcap 6 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/lib/META: -------------------------------------------------------------------------------- 1 | name="pcre" 2 | version="6.2.5" 3 | description="Perl Compatibility Regular Expressions" 4 | requires="" 5 | archive(byte)="pcre.cma" 6 | archive(native)="pcre.cmxa" 7 | linkopts = "" 8 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/lib/Makefile: -------------------------------------------------------------------------------- 1 | OCAMLMAKEFILE = ../OCamlMakefile 2 | 3 | SOURCES := pcre.mli pcre.ml pcre_stubs.c 4 | CFLAGS := -O2 $(shell pcre-config --cflags) 5 | PCRE_FLAGS := $(shell pcre-config --libs) 6 | OCAMLLDFLAGS := -cclib "$(PCRE_FLAGS)" 7 | OCAMLMKLIB_FLAGS := $(PCRE_FLAGS) 8 | RESULT := pcre 9 | 10 | all: 11 | 12 | install: libinstall 13 | uninstall: libuninstall 14 | 15 | -include $(OCAMLMAKEFILE) 16 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/lib/Makefile.win32: -------------------------------------------------------------------------------- 1 | #LIB_PATH=d:\ocaml\libs 2 | #INC_PATH=d:/ocaml/lib d:/ocaml/includes 3 | INC_PATH=$(shell ocamlc -where) 4 | 5 | 6 | all: pcre.cma 7 | opt: pcre.cmxa 8 | 9 | pcre.cma: pcre.cmo pcre_stubs.lib 10 | ocamlc -a -o pcre.cma pcre.cmo \ 11 | -cclib pcre_stubs.lib -cclib libpcre.lib 12 | 13 | pcre.cmo: pcre.cmi pcre.ml 14 | ocamlc -c pcre.ml -o pcre.cmo 15 | 16 | pcre.cmi: pcre.mli 17 | ocamlc -c pcre.mli -o pcre.cmi 18 | 19 | pcre_stubs.lib: pcre_stubs.c 20 | echo $(INC_PATH) 21 | cl /nologo /c /MT pcre_stubs.c /Fopcre_stubs.s.obj $(addprefix /I,$(INC_PATH)) 22 | lib /nologo /debugtype:CV /OUT:pcre_stubs.lib pcre_stubs.s.obj 23 | 24 | pcre.cmx: pcre.cmi pcre.ml 25 | ocamlopt -c pcre.ml -o pcre.cmx 26 | 27 | pcre.cmxa: pcre.cmx pcre_stubs.lib 28 | ocamlopt -verbose -a -o pcre.cmxa pcre.cmx \ 29 | -cclib pcre_stubs.lib -cclib libpcre.lib 30 | 31 | install: pcre.cmxa pcre.cma 32 | ocamlfind install pcre META pcre.cma pcre.cmxa pcre.cmi pcre.mli \ 33 | pcre.lib pcre_stubs.lib 34 | uninstall: 35 | ocamlfind remove pcre 36 | 37 | clean: 38 | rm *.cm* *.lib *.obj 39 | 40 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2/lib/OMakefile: -------------------------------------------------------------------------------- 1 | OCAML_LIBRARIES = 2 | OCAMLPACKS = 3 | 4 | OCAML_LIB_FLAGS += -cclib -lpcre 5 | 6 | LIB_CNAMES = pcre_stubs 7 | LIB_MLNAMES = pcre 8 | 9 | OCamlMakeLib(pcre) 10 | 11 | 12 | doc: pcre $(OCAMLDOC_PP) 13 | $(OCamlDocs Pcre, *.mli *.ml, \ 14 | "OCaml Pcre bindings.") 15 | 16 | InstantiateOCamlEnv() 17 | 18 | doc: pcre $(OCAMLDOC_PP) 19 | $(OCamlDocs Pcre, *.mli *.ml, "Perl Compatible Regular Expressions.") 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/.hg_archival.txt: -------------------------------------------------------------------------------- 1 | repo: 1062d19ece6f075dbc2fff3238732629f8005eb1 2 | node: 216aa5cc997b85f8c0784b6a9cc530f1961391aa 3 | branch: default 4 | tag: release-6.2.2 5 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/.hgignore: -------------------------------------------------------------------------------- 1 | (^|/)\.bzr($|/) 2 | (^|/)\.hg($|/) 3 | (^|/)\.hgtags($|/) 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/.hgtags: -------------------------------------------------------------------------------- 1 | 6d8dd1e9604e23e1566e75293eef56dcde305a7e release 5.15.0 2 | 16e59144fcff07bea0f0920eb095a5970a331aef release 5.15.1 3 | 0000000000000000000000000000000000000000 release 5.15.1 4 | 0000000000000000000000000000000000000000 release 5.15.0 5 | 6d8dd1e9604e23e1566e75293eef56dcde305a7e release-5.15.0 6 | 16e59144fcff07bea0f0920eb095a5970a331aef release-5.15.1 7 | e58db995479b47db970a02e3cd3a57bf36716d8c release-5.16.0 8 | f9d914eaef5b8c68ed5d835e4098f7d3285fda19 release-5.16.1 9 | 231d62c5d66e187f810222976f92e9aa27958eab release-5.16.2 10 | 1ff0346e6cca02d4aa3d4aae1aa6ff266b1adab0 release-5.16.3 11 | 7500100fe2d7c42e7687231fd7ababcbee5abfbd release-5.16.4 12 | adf5cb6ffff604dadd2e299750a028a6af2ccc70 release-5.16.5 13 | 9f768785f76ab3f3e4d44fe11f6de7797f476a93 release-6.0.0 14 | b3f3e6899e80a86acc7037548f3226596e76782f release-6.0.1 15 | 3dd5b45ff8448beba17d9a1ecec47661d69d15e1 release-6.1.0 16 | fb29e7be9814fd4c835d56631509916d8d76c9c5 release-6.1.1 17 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/Makefile: -------------------------------------------------------------------------------- 1 | -include Makefile.conf 2 | 3 | EXAMPLES = $(filter-out examples/OMakefile examples/CVS, $(wildcard examples/*)) 4 | 5 | .PHONY: all 6 | all: 7 | @cd lib && $(MAKE) byte-code-library native-code-library 8 | 9 | .PHONY: examples 10 | examples: 11 | @for dir in $(EXAMPLES); do (cd $$dir && $(MAKE)); done 12 | 13 | .PHONY: doc 14 | doc: 15 | @cd lib && $(MAKE) $@ 16 | ln -sf lib/doc 17 | 18 | .PHONY: htdoc 19 | htdoc: 20 | @cd lib && $(MAKE) $@ 21 | 22 | .PHONY: install 23 | install: 24 | @cd lib && $(MAKE) $@ 25 | 26 | .PHONY: uninstall 27 | uninstall: 28 | @cd lib && $(MAKE) $@ 29 | 30 | .PHONY: clean 31 | clean: 32 | @cd lib && $(MAKE) clean 33 | @for dir in $(EXAMPLES); do (cd $$dir && $(MAKE) $@); done 34 | @rm -f doc 35 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/Makefile.conf: -------------------------------------------------------------------------------- 1 | # export STATIC = yes 2 | # export INCDIRS := /usr/include/pcre 3 | # export LIBDIRS := 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/OMakefile: -------------------------------------------------------------------------------- 1 | Subdirs() 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/OMakefile: -------------------------------------------------------------------------------- 1 | OCAML_LIBRARIES = pcre 2 | 3 | Subdirs() 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/cloc/._d/cloc.d: -------------------------------------------------------------------------------- 1 | cloc.cmo: 2 | cloc.cmx: 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/cloc/Makefile: -------------------------------------------------------------------------------- 1 | OCAMLMAKEFILE = ../../OCamlMakefile 2 | 3 | SOURCES = cloc.ml 4 | INCDIRS = ../../lib 5 | LIBDIRS = ../../lib 6 | LIBS = pcre 7 | RESULT = cloc 8 | 9 | -include $(OCAMLMAKEFILE) 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/cloc/OMakefile: -------------------------------------------------------------------------------- 1 | OCamlMakeProjDefaults(cloc.exe) 2 | 3 | InstantiateOCamlEnv() 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/cloc/README: -------------------------------------------------------------------------------- 1 | This program reads C-sources from stdin and prints them to stdout with 2 | comments and empty lines removed. - A very primitive way of counting LOCs. 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/cloc/cloc.ml: -------------------------------------------------------------------------------- 1 | open Pcre 2 | 3 | let read_whole_channel ch = 4 | let size = 4096 in 5 | let strbuf = String.create size 6 | and buf = Buffer.create 65536 7 | and len = ref size in 8 | while !len <> 0 do 9 | len := input ch strbuf 0 size; 10 | Buffer.add_substring buf strbuf 0 !len; done; 11 | Buffer.contents buf 12 | 13 | let _ = 14 | let str = read_whole_channel stdin in 15 | let str = qreplace ~pat:"/\\*(.|\n)*?\\*/" str in 16 | let str = qreplace_first ~pat:"^(\n|\\s)+" str in 17 | let str = qreplace ~pat:"\n+((\n|\\s)\n)*" ~templ:"\n" str in 18 | print_string str 19 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/cloc/make_win32_cloc.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set OCAMLC=ocamlc -g 4 | set OCAMLOPT=ocamlopt 5 | 6 | set MAIN=cloc 7 | 8 | @echo on 9 | %OCAMLC% -o %MAIN%.exe pcre.cma %MAIN%.ml 10 | %OCAMLOPT% -o %MAIN%.com pcre.cmxa %MAIN%.ml 11 | 12 | @REM Example use: 13 | @REM %MAIN%.exe < ..\..\lib\pcre_stubs.c 14 | @REM %MAIN%.com < ..\..\lib\pcre_stubs.c 15 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/count_hash/._d/count_hash.d: -------------------------------------------------------------------------------- 1 | count_hash.cmo: 2 | count_hash.cmx: 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/count_hash/Makefile: -------------------------------------------------------------------------------- 1 | OCAMLMAKEFILE = ../../OCamlMakefile 2 | 3 | SOURCES = count_hash.ml 4 | INCDIRS = ../../lib 5 | LIBDIRS = ../../lib 6 | LIBS = pcre 7 | RESULT = count_hash 8 | 9 | -include $(OCAMLMAKEFILE) 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/count_hash/OMakefile: -------------------------------------------------------------------------------- 1 | OCamlMakeProjDefaults(count_hash.exe) 2 | 3 | InstantiateOCamlEnv() 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/count_hash/README: -------------------------------------------------------------------------------- 1 | This program reads in text from stdin, counts all equal words that are 2 | separated by whitespace and prints the result to stdout. 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/count_hash/count_hash.ml: -------------------------------------------------------------------------------- 1 | open Hashtbl 2 | 3 | let hash = create 1973 4 | let add_string s = try incr (find hash s) with Not_found -> add hash s (ref 1);; 5 | Pcre.foreach_line (fun line -> List.iter add_string (Pcre.split line)); 6 | iter (fun k v -> Printf.printf "%4d\t%s\n" !v k) hash 7 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/pcregrep/._d/pcregrep.d: -------------------------------------------------------------------------------- 1 | pcregrep.cmo: 2 | pcregrep.cmx: 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/pcregrep/Makefile: -------------------------------------------------------------------------------- 1 | OCAMLMAKEFILE = ../../OCamlMakefile 2 | 3 | SOURCES = pcregrep.ml 4 | INCDIRS = ../../lib 5 | LIBDIRS = ../../lib 6 | LIBS = pcre 7 | RESULT = pcregrep 8 | 9 | -include $(OCAMLMAKEFILE) 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/pcregrep/OMakefile: -------------------------------------------------------------------------------- 1 | OCamlMakeProjDefaults(pcregrep.exe) 2 | 3 | InstantiateOCamlEnv() 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/pcregrep/README: -------------------------------------------------------------------------------- 1 | Start the program with argument "-help" to see what it does! 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/subst/._d/subst.d: -------------------------------------------------------------------------------- 1 | subst.cmo: 2 | subst.cmx: 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/subst/Makefile: -------------------------------------------------------------------------------- 1 | OCAMLMAKEFILE = ../../OCamlMakefile 2 | 3 | SOURCES = subst.ml 4 | INCDIRS = ../../lib 5 | LIBDIRS = ../../lib 6 | LIBS = pcre 7 | RESULT = subst 8 | 9 | -include $(OCAMLMAKEFILE) 10 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/subst/OMakefile: -------------------------------------------------------------------------------- 1 | OCamlMakeProjDefaults(subst.exe) 2 | 3 | InstantiateOCamlEnv() 4 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/examples/subst/README: -------------------------------------------------------------------------------- 1 | Start the program with argument "-help" to see what it does! 2 | 3 | Example invocation: 4 | 5 | subst '([Tt])ermcap' '$1ermCap' < /etc/termcap 6 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/lib/._bcdi/pcre.di: -------------------------------------------------------------------------------- 1 | pcre.cmi: 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/lib/._d/pcre.d: -------------------------------------------------------------------------------- 1 | pcre.cmo: pcre.cmi 2 | pcre.cmx: pcre.cmi 3 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/lib/._ncdi/pcre.di: -------------------------------------------------------------------------------- 1 | pcre.cmi: 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/lib/META: -------------------------------------------------------------------------------- 1 | name="pcre" 2 | version="6.2.0" 3 | description="Perl Compatibility Regular Expressions" 4 | requires="" 5 | archive(byte)="pcre.cma" 6 | archive(native)="pcre.cmxa" 7 | linkopts = "" 8 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/lib/Makefile: -------------------------------------------------------------------------------- 1 | OCAMLMAKEFILE = ../OCamlMakefile 2 | 3 | SOURCES := pcre.mli pcre.ml pcre_stubs.c 4 | CFLAGS := -O2 $(shell pcre-config --cflags) 5 | PCRE_FLAGS := $(shell pcre-config --libs) 6 | OCAMLLDFLAGS := -cclib "$(PCRE_FLAGS)" 7 | OCAMLMKLIB_FLAGS := $(PCRE_FLAGS) 8 | RESULT := pcre 9 | 10 | all: 11 | 12 | install: libinstall 13 | uninstall: libuninstall 14 | 15 | -include $(OCAMLMAKEFILE) 16 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/lib/Makefile.win32: -------------------------------------------------------------------------------- 1 | #LIB_PATH=d:\ocaml\libs 2 | #INC_PATH=d:/ocaml/lib d:/ocaml/includes 3 | INC_PATH=$(shell ocamlc -where) 4 | 5 | 6 | all: pcre.cma 7 | opt: pcre.cmxa 8 | 9 | pcre.cma: pcre.cmo pcre_stubs.lib 10 | ocamlc -a -o pcre.cma pcre.cmo \ 11 | -cclib pcre_stubs.lib -cclib libpcre.lib 12 | 13 | pcre.cmo: pcre.cmi pcre.ml 14 | ocamlc -c pcre.ml -o pcre.cmo 15 | 16 | pcre.cmi: pcre.mli 17 | ocamlc -c pcre.mli -o pcre.cmi 18 | 19 | pcre_stubs.lib: pcre_stubs.c 20 | echo $(INC_PATH) 21 | cl /nologo /c /MT pcre_stubs.c /Fopcre_stubs.s.obj $(addprefix /I,$(INC_PATH)) 22 | lib /nologo /debugtype:CV /OUT:pcre_stubs.lib pcre_stubs.s.obj 23 | 24 | pcre.cmx: pcre.cmi pcre.ml 25 | ocamlopt -c pcre.ml -o pcre.cmx 26 | 27 | pcre.cmxa: pcre.cmx pcre_stubs.lib 28 | ocamlopt -verbose -a -o pcre.cmxa pcre.cmx \ 29 | -cclib pcre_stubs.lib -cclib libpcre.lib 30 | 31 | install: 32 | ocamlfind install pcre META pcre.cma pcre.cmxa pcre.cmi pcre.mli \ 33 | pcre.lib pcre_stubs.lib 34 | uninstall: 35 | ocamlfind remove pcre 36 | 37 | clean: 38 | rm *.cm* *.lib *.obj 39 | 40 | -------------------------------------------------------------------------------- /lib/bap-0.4/pcre-ocaml-release-6.2.2_/lib/OMakefile: -------------------------------------------------------------------------------- 1 | OCAML_LIBRARIES = 2 | OCAMLPACKS = 3 | 4 | OCAML_LIB_FLAGS += -cclib -lpcre 5 | 6 | LIB_CNAMES = pcre_stubs 7 | LIB_MLNAMES = pcre 8 | 9 | OCamlMakeLib(pcre) 10 | 11 | 12 | doc: pcre $(OCAMLDOC_PP) 13 | $(OCamlDocs Pcre, *.mli *.ml, \ 14 | "OCaml Pcre bindings.") 15 | 16 | InstantiateOCamlEnv() 17 | 18 | doc: pcre $(OCAMLDOC_PP) 19 | $(OCamlDocs Pcre, *.mli *.ml, "Perl Compatible Regular Expressions.") 20 | -------------------------------------------------------------------------------- /lib/bap-0.4/pintraces/README: -------------------------------------------------------------------------------- 1 | Run getpin.sh to download and extract Pin in the proper location. 2 | 3 | If you run an x86_64 host, you will need to install the multilib 4 | version of g++ (and possibly binutils). 5 | 6 | XXX: Add instructions on how to run the tool -------------------------------------------------------------------------------- /lib/bap-0.4/pintraces/ddk-inc/README: -------------------------------------------------------------------------------- 1 | This directory contains include files from the Windows Driver 2 | Development Kit, version 7600.16385.1. They are included here because 3 | 1) WDK is annoying to obtain, 2) there are header file conflicts 4 | between WDK and VC++ that are difficult to resolve. These header 5 | files work on VS 10.0.30319.1. -------------------------------------------------------------------------------- /lib/bap-0.4/pintraces/examples/bof1/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for AEG experiment 2 | 3 | PACKAGES=bof1 4 | 5 | all: $(PACKAGES) 6 | 7 | bof1: bof1.c 8 | gcc -m32 -o $@ -fno-stack-protector -mpreferred-stack-boundary=2 $^ 9 | 10 | .PHONY: clean all 11 | 12 | clean: 13 | rm -rf *.o $(PACKAGES) 14 | -------------------------------------------------------------------------------- /lib/bap-0.4/pintraces/examples/bof1/bof1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | void impossible() 8 | { 9 | printf("Its impossible to execute this function\n"); 10 | } 11 | 12 | void test(char * buf) 13 | { 14 | char local[8]; 15 | int i; 16 | strcpy(local, buf); 17 | } 18 | 19 | int fd; 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | char buf[500]; 24 | size_t count; 25 | fd = open("readme", O_RDONLY); 26 | if(fd == -1) { 27 | perror("open"); 28 | exit(-1); 29 | } 30 | count = read(fd, buf, 500); 31 | if(count == -1) { 32 | perror("read"); 33 | exit(-1); 34 | } 35 | 36 | if(buf[0] != 'h') { 37 | printf("the file contents must start with h\n"); 38 | close(fd); 39 | exit(-1); 40 | } 41 | 42 | close(fd); 43 | 44 | test(buf); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /lib/bap-0.4/pintraces/getpin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # $Id: getpin.sh 5128 2011-09-09 20:39:57Z swhitman $ 4 | # Download and extract Pin 5 | 6 | set -x 7 | 8 | wget 'http://www.cs.virginia.edu/kim/publicity/pin/kits/pin-2.9-39599-gcc.3.4.6-ia32_intel64-linux.tar.gz' -O /tmp/pin.tar.gz 9 | tar -xvzf /tmp/pin.tar.gz -C .. 10 | rm -rf ../pin 11 | mv ../pin-* ../pin 12 | #make 13 | -------------------------------------------------------------------------------- /lib/bap-0.4/pintraces/iltest/TRACE: -------------------------------------------------------------------------------- 1 | ../pin/pin -t obj-ia32/gentrace.so -logone-after -logall-before -taint-start 0x3ffff000 -taint-end 0x3ffff010 -trig_addr 0x3ffff000 -- ./iltest/test -------------------------------------------------------------------------------- /lib/bap-0.4/pintraces/pivot.h: -------------------------------------------------------------------------------- 1 | #ifndef __PIVOT_H 2 | #define __PIVOT_H 3 | /** 4 | @author Edward J. Schwartz 5 | 6 | $Id: pivot.h 5128 2011-09-09 20:39:57Z swhitman $ 7 | */ 8 | 9 | #include "pin.H" 10 | #include "pin_taint.h" 11 | #include 12 | #include 13 | 14 | /** 15 | Types of pivots. 16 | 17 | Switchstack is ESP <- reg + c. 18 | Mempivot is ESP <- M[reg + c]. 19 | */ 20 | typedef enum { UNKNOWN, SWITCHSTACK, MEMPIVOT } pivottype_t; 21 | 22 | /** Pivot objects */ 23 | bool operator<(const struct pivot_s &a, const struct pivot_s &b); 24 | 25 | typedef struct pivot_s { 26 | uint64_t address; /** Gadget address. */ 27 | pivottype_t t; /** Type of pivot. */ 28 | REG base; /** Base register. */ 29 | uint64_t offset; /** Offset */ 30 | } pivot_t; 31 | 32 | /** Sets of pivot objects */ 33 | typedef set pivot_set; 34 | 35 | /** Function headers */ 36 | pivot_set PIVOT_parseinput(istream &f); 37 | void PIVOT_testpivot(pivot_set, CONTEXT *, pintrace::TaintTracker &); 38 | ostream& operator<<(ostream &o, const pivot_s &); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /lib/bap-0.4/pintraces/pivottest.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Tester for pivot parsing. 4 | 5 | */ 6 | 7 | #include "pivot.h" 8 | #include 9 | #include 10 | 11 | int main() { 12 | fstream f; 13 | pivot_set ps; 14 | pivot_set::iterator i; 15 | 16 | f.open("in"); 17 | if (!f.is_open()) { 18 | cerr << "Could not open input file" << endl; 19 | exit(1); 20 | } 21 | 22 | ps = PIVOT_parseinput(f); 23 | 24 | for (i = ps.begin(); i != ps.end(); i++) { 25 | cerr << *i << endl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /lib/bap-0.4/stpwrap/Makefile: -------------------------------------------------------------------------------- 1 | %: 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/tests/Makefile: -------------------------------------------------------------------------------- 1 | %: 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/utils-proj.example/Makefile: -------------------------------------------------------------------------------- 1 | # Project specific utils Makefile 2 | # $Id$ 3 | 4 | # We need to tell the main utils Makefile to include our proj's ocaml 5 | export BAP_PROJ_OCAMLDIR=$(BAP_DIR)/../ocaml-proj 6 | export BAP_PROJ_UTILDIR=$(BAP_DIR)/../utils-proj 7 | 8 | define PROJ_testutil 9 | RESULT=testutil 10 | SOURCES = $(BAP_PROJ_UTILDIR)/testutil.ml 11 | DOC_FILES=$(SOURCES) 12 | endef 13 | export PROJ_testutil 14 | 15 | export PROJUTILS = testutil 16 | -------------------------------------------------------------------------------- /lib/bap-0.4/utils-proj.example/README: -------------------------------------------------------------------------------- 1 | This is an example project-specific directory. To add it to bap, 2 | move it to bap-dir/../utils-proj. -------------------------------------------------------------------------------- /lib/bap-0.4/utils-proj.example/testutil.ml: -------------------------------------------------------------------------------- 1 | print_string (Test.testf ()) ;; 2 | -------------------------------------------------------------------------------- /lib/bap-0.4/utils/add.il: -------------------------------------------------------------------------------- 1 | addr 0x5e @asm "add %ecx,%edx" 2 | label pc_0x5e 3 | t:u32 = R_EDX:u32 4 | initial_edx:u32 = R_EDX:u32 5 | initial_ecx:u32 = R_ECX:u32 6 | R_EDX:u32 = R_EDX:u32 + R_ECX:u32 7 | R_CF:bool = R_EDX:u32 < t:u32 8 | R_AF:bool = 0x10:u32 == (0x10:u32 & (R_EDX:u32 ^ t:u32 ^ R_ECX:u32)) 9 | R_OF:bool = high:bool((t:u32 ^ ~R_ECX:u32) & (t:u32 ^ R_EDX:u32)) 10 | R_PF:bool = 11 | ~low:bool(R_EDX:u32 >> 7:u32 ^ R_EDX:u32 >> 6:u32 ^ R_EDX:u32 >> 5:u32 ^ 12 | R_EDX:u32 >> 4:u32 ^ R_EDX:u32 >> 3:u32 ^ R_EDX:u32 >> 2:u32 ^ 13 | R_EDX:u32 >> 1:u32 ^ R_EDX:u32) 14 | R_SF:bool = high:bool(R_EDX:u32) 15 | R_ZF:bool = 0:u32 == R_EDX:u32 16 | addr 0x60 @asm "ret " 17 | label pc_0x60 18 | ra:u32 = mem:?u32[R_ESP:u32, e_little]:u32 19 | R_ESP:u32 = R_ESP:u32 + 4:u32 20 | final_edx:u32 = R_EDX:u32 21 | 22 | 23 | -------------------------------------------------------------------------------- /lib/bap-0.4/utils/copy_reg.il: -------------------------------------------------------------------------------- 1 | initial_ebx:u32 = R_EBX:u32 2 | addr 0x73 @asm "mov %ebx,%eax" 3 | label pc_0x73 4 | R_EAX:u32 = R_EBX:u32 5 | addr 0x75 @asm "ret " 6 | label pc_0x75 7 | ra:u32 = mem:?u32[R_ESP:u32, e_little]:u32 8 | R_ESP:u32 = R_ESP:u32 + 4:u32 9 | final_eax:u32 = R_EAX:u32 10 | 11 | 12 | -------------------------------------------------------------------------------- /lib/bap-0.4/utils/formula.ml: -------------------------------------------------------------------------------- 1 | 2 | let sort = 3 | let underscore = Str.regexp_string "_" in 4 | let sort_aux (var1, _) (var2,_) = 5 | let ss1 = Str.split underscore var1 6 | and ss2 = Str.split underscore var2 in 7 | let s1 = List.nth ss1 1 8 | and s2 = List.nth ss2 1 in 9 | let s1i = int_of_string s1 10 | and s2i = int_of_string s2 in 11 | compare s1i s2i 12 | in 13 | List.sort sort_aux 14 | 15 | let main () = 16 | let cin = 17 | if Array.length Sys.argv > 1 then open_in Sys.argv.(1) 18 | else stdin 19 | in 20 | let is_input v = String.sub v 0 4 = "symb" in 21 | let lexbuf = Lexing.from_channel cin in 22 | let values = match Stp_grammar.main Stp_lexer.token lexbuf with 23 | | Some(x) -> x 24 | | None -> failwith "Unable to satisfy formula" 25 | in 26 | let values = List.filter (fun (v,_) -> is_input v) values in 27 | let sorted = sort values in 28 | List.iter (fun (_, num) -> Printf.printf "\\x%02Lx" num) sorted 29 | 30 | ;; 31 | 32 | main () 33 | -------------------------------------------------------------------------------- /lib/bap-0.4/utils/formula_add.txt: -------------------------------------------------------------------------------- 1 | % free variables: 2 | R_ECX_7 : BITVECTOR(32); 3 | R_EDX_8 : BITVECTOR(32); 4 | % end free variables. 5 | 6 | ASSERT( 7 | 0bin1 = 8 | (LET initial_edx_76_0 = R_EDX_8 IN 9 | (LET initial_ecx_77_1 = R_ECX_7 IN 10 | (LET R_EDX_78_2 = BVPLUS(32, R_EDX_8,R_ECX_7) IN 11 | (LET final_edx_109_3 = R_EDX_78_2 IN 12 | IF (NOT(final_edx_109_3= 13 | BVPLUS(32, initial_edx_76_0,initial_ecx_77_1))) THEN 0bin1 ELSE 0bin0 ENDIF)))) 14 | ); 15 | QUERY(FALSE); 16 | COUNTEREXAMPLE; 17 | -------------------------------------------------------------------------------- /lib/bap-0.4/utils/formula_copy_reg.txt: -------------------------------------------------------------------------------- 1 | % free variables: 2 | R_EBX_6 : BITVECTOR(32); 3 | % end free variables. 4 | 5 | ASSERT( 6 | 0bin1 = 7 | (LET initial_ebx_73_0 = R_EBX_6 IN 8 | (LET final_eax_77_1 = R_EBX_6 IN 9 | IF (NOT(final_eax_77_1=initial_ebx_73_0)) THEN 0bin1 ELSE 0bin0 ENDIF)) 10 | ); 11 | QUERY(FALSE); 12 | COUNTEREXAMPLE; 13 | -------------------------------------------------------------------------------- /lib/bap-0.4/utils/toil.ml: -------------------------------------------------------------------------------- 1 | 2 | let usage = "Usage: "^Sys.argv.(0)^" [-o output]\n\ 3 | Translate programs to the IL. " 4 | 5 | let out = ref stdout 6 | let speclist = 7 | ("-o", Arg.String (fun f -> out := open_out f), 8 | " Print output to rather than stdout.") 9 | :: Input.speclist 10 | 11 | let anon x = raise(Arg.Bad("Unexpected argument: '"^x^"'")) 12 | let () = Arg.parse speclist anon usage 13 | 14 | 15 | let prog = 16 | try fst (Input.get_program()) 17 | with Arg.Bad s -> 18 | Arg.usage speclist (s^"\n"^usage); 19 | exit 1 20 | 21 | let pp = new Pp.pp_oc !out 22 | ;; 23 | 24 | pp#ast_program prog; 25 | pp#close; 26 | -------------------------------------------------------------------------------- /lib/bap-0.4/utils/tricky.txt: -------------------------------------------------------------------------------- 1 | % free variables: 2 | R_EAX_5 : BITVECTOR(32); 3 | % end free variables. 4 | 5 | ASSERT( 6 | 0bin1 = 7 | (LET R_ECX_117_0 = BVPLUS(32, R_EAX_5,0hex11223344) IN 8 | (LET R_ZF_144_1 = IF (0hex00000000=R_ECX_117_0) THEN 0bin1 ELSE 0bin0 ENDIF IN 9 | (LET R_EBX_147_2 = (0bin0000000000000000000000000000000 @ R_ZF_144_1) IN 10 | IF (R_EBX_147_2=0hex00000001) THEN 0bin1 ELSE 0bin0 ENDIF))) 11 | ); 12 | QUERY(FALSE); 13 | COUNTEREXAMPLE; 14 | -------------------------------------------------------------------------------- /src/TODO.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | -------------------------------------------------------------------------------- /src/common/Makefile: -------------------------------------------------------------------------------- 1 | inc_dir := $(bap_lib_dir) 2 | 3 | inc_params := $(foreach d,$(inc_dir),-I $d) 4 | 5 | sources := common.ml \ 6 | int_utils.ml 7 | objects := $(subst .ml,.cmo,$(sources)) 8 | 9 | all: $(objects) 10 | 11 | %.cmo: %.ml 12 | ocamlc -c $(inc_params) $< 13 | 14 | clean: 15 | rm -f *.o *.cmo *.cmi *.cmx 16 | -------------------------------------------------------------------------------- /src/compile/.gitignore: -------------------------------------------------------------------------------- 1 | llvmLexer.ml 2 | llvmParser.ml 3 | llvmParser.mli 4 | roplLexer.ml 5 | roplParser.ml 6 | roplParser.mli -------------------------------------------------------------------------------- /src/compile/regSets.ml: -------------------------------------------------------------------------------- 1 | open Common 2 | open SsaForm 3 | 4 | module RegOrder = struct 5 | type t = reg 6 | let compare = Pervasives.compare 7 | end 8 | 9 | module RegSet = Set.Make( RegOrder ) 10 | 11 | module SRegOrder = struct 12 | type t = sreg 13 | let compare = Pervasives.compare 14 | end 15 | 16 | module SRegSet = Set.Make( SRegOrder ) 17 | 18 | let set_from_list l = 19 | let f set x = RegSet.add x set in 20 | List.fold_left f RegSet.empty l 21 | 22 | let sreg_set_from_list l = 23 | let f set x = SRegSet.add x set in 24 | List.fold_left f SRegSet.empty l 25 | 26 | let common_reg_set_to_sreg_set set = 27 | let l = RegSet.elements set in 28 | let l = List.map (fun r -> C(r)) l in 29 | let set = sreg_set_from_list l in 30 | set 31 | -------------------------------------------------------------------------------- /src/dumper/Makefile: -------------------------------------------------------------------------------- 1 | libasmir_dir := $(bap_dir)/libasmir/src 2 | pcre_dir := $(bap_dir)/pcre-ocaml-release-6.2.2/lib 3 | 4 | inc_dir := $(bap_lib_dir) $(pcre_dir) $(libasmir_dir) $(common_dir) 5 | inc_params := $(foreach d, $(inc_dir), -I $d) 6 | 7 | libs := $(libasmir_dir)/libasmir.a $(bap_lib_dir)/bap.cma 8 | deps := $(common_dir)/common.cmo $(common_dir)/int_utils.cmo 9 | sources := dumper.ml 10 | objects := $(subst .ml,.cmo,$(sources)) 11 | 12 | packs := bigarray,str,ocamlgraph 13 | ocaml_opts := -package $(packs) -linkpkg -thread 14 | 15 | all: dumper 16 | 17 | dumper: $(objects) 18 | ocamlfind ocamlc $(ocaml_opts) $(inc_params) $(libs) $(deps) $(objects) -o $@ 19 | mv $@ $(bin_dir)/$@-bap-0.4 20 | 21 | %.cmo: %.ml 22 | ocamlc -c -I $(common_dir) $(inc_params) $< 23 | 24 | clean: 25 | rm -f *.o *.cmo *.cmi *.cmx 26 | rm -f $(bin_dir)/dumper-bap-0.4 27 | -------------------------------------------------------------------------------- /src/dumper/dumper.ml: -------------------------------------------------------------------------------- 1 | open Printf 2 | 3 | open Common 4 | 5 | (** Gadget Dumper Tool *) 6 | 7 | let main () = 8 | let argc = Array.length Sys.argv in 9 | 10 | if argc > 1 then 11 | let fn = Sys.argv.(1) in 12 | let container = Common.unmarshal_from_file fn in 13 | let b = dump_container container in 14 | Buffer.output_buffer stdout b 15 | else 16 | (* Print usage message *) 17 | let err = Printf.sprintf "Usage:\n%s \n" Sys.argv.(0) in 18 | print_string err 19 | 20 | let _ = main() 21 | -------------------------------------------------------------------------------- /src/gadget/Makefile: -------------------------------------------------------------------------------- 1 | libasmir_dir := $(bap_dir)/libasmir/src 2 | pcre_dir := $(bap_dir)/pcre-ocaml-release-6.2.2/lib 3 | inc_dir := $(bap_lib_dir) $(pcre_dir) $(libasmir_dir) $(common_dir) 4 | 5 | inc_params := $(foreach d, $(inc_dir), -I $d) 6 | 7 | libs := $(libasmir_dir)/libasmir.a $(bap_lib_dir)/bap.cma 8 | deps := $(common_dir)/common.cmo $(common_dir)/int_utils.cmo 9 | sources := gadgetSet.ml \ 10 | gadgetClassifierHelper.ml \ 11 | gadgetClassifier.ml \ 12 | gadgetFinder.ml \ 13 | gadget.ml 14 | objects := $(subst .ml,.cmo,$(sources)) 15 | 16 | packs := bigarray,str,ocamlgraph 17 | ocaml_opts := -package $(packs) -linkpkg -thread 18 | 19 | all: gadget 20 | 21 | gadget: $(objects) 22 | ocamlfind ocamlc $(ocaml_opts) $(inc_params) $(libs) $(deps) $(objects) -o $@ 23 | mv $@ $(bin_dir)/$@-bap-0.4 24 | 25 | %.cmo: %.ml 26 | ocamlc -c -I $(common_dir) $(inc_params) $< 27 | 28 | clean: 29 | rm -f *.o *.cmo *.cmi *.cmx 30 | 31 | rm -f $(bin_dir)/gadget-bap-0.4 32 | -------------------------------------------------------------------------------- /src/gadget/gadgetSet.ml: -------------------------------------------------------------------------------- 1 | open Common 2 | 3 | module GadgetSet = Set.Make( 4 | struct 5 | let compare = Pervasives.compare 6 | type t = gadget 7 | end 8 | ) 9 | 10 | let gadget_set_of_list = List.fold_left (fun acc x -> GadgetSet.add x acc) GadgetSet.empty 11 | -------------------------------------------------------------------------------- /src/verify/Makefile: -------------------------------------------------------------------------------- 1 | libasmir_dir := $(bap_dir)/libasmir/src 2 | pcre_dir := $(bap_dir)/pcre-ocaml-release-6.2.2/lib 3 | inc_dir := $(bap_lib_dir) $(pcre_dir) $(libasmir_dir) $(common_dir) 4 | 5 | inc_params := $(foreach d, $(inc_dir), -I $d) 6 | 7 | libs := $(libasmir_dir)/libasmir.a $(bap_lib_dir)/bap.cma 8 | deps := $(common_dir)/common.cmo $(common_dir)/int_utils.cmo 9 | sources := verify.ml 10 | objects := $(subst .ml,.cmo,$(sources)) 11 | 12 | packs := bigarray,str,num,unix,ocamlgraph,camomile,threads 13 | ocaml_opts := -package $(packs) -linkpkg -thread 14 | 15 | all: verify 16 | 17 | verify: $(objects) 18 | ocamlfind ocamlc $(ocaml_opts) $(inc_params) $(libs) $(deps) $(objects) -o $@ 19 | mv $@ $(bin_dir)/$@-bap-0.4 20 | 21 | %.cmo: %.ml 22 | ocamlc -c -I $(common_dir) $(inc_params) $< 23 | 24 | clean: 25 | rm -f *.o *.cmo *.cmi 26 | rm -f $(bin_dir)/verify-bap-0.4 -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | bin_dir := ../bin 2 | 3 | all: test-llvm 4 | 5 | asm: test.asm test.c 6 | nasm -felf32 test.asm -o asm.o 7 | gcc -ggdb -m32 asm.o test.c 8 | 9 | gadgets: asm 10 | $(bin_dir)/gadget-bap-0.4 a.out candidates.bin 11 | $(bin_dir)/verify-bap-0.4 candidates.bin verified.bin 12 | rm -rf a.out.formula.txt 13 | 14 | ropc-ropl: gadgets 15 | $(bin_dir)/ropc-bap-0.4 ropl examples-ropl/fib.ropl verified.bin 16 | 17 | ropc-llvm: gadgets 18 | $(bin_dir)/ropc-bap-0.4 llvm examples-llvm/fib.S verified.bin 19 | 20 | test-ropl: ropc-ropl 21 | ./a.out compiled-ropl.bin 22 | 23 | test-llvm: ropc-llvm 24 | ./a.out compiled-llvm.bin 25 | 26 | clean: 27 | rm -rf *.o a.out 28 | rm -rf candidates.bin verified.bin 29 | rm -rf a.out.formula.txt 30 | rm -rf compiled-ropl.bin compiled-llvm.bin 31 | -------------------------------------------------------------------------------- /test/examples-llvm/Makefile: -------------------------------------------------------------------------------- 1 | OPTFLAGS = -O0 2 | CFLAGS = -emit-llvm -S 3 | 4 | EXAMPLES = baz fib foo trivial 5 | 6 | all: $(EXAMPLES) 7 | 8 | baz: baz.c 9 | clang $(OPTFLAGS) $(CFLAGS) baz.c -o baz.S 10 | 11 | fib: fib.c 12 | clang $(OPTFLAGS) $(CFLAGS) fib.c -o fib.S 13 | 14 | foo: foo.c 15 | clang $(OPTFLAGS) $(CFLAGS) foo.c -o foo.S 16 | 17 | trivial: trivial.c 18 | clang $(OPTFLAGS) $(CFLAGS) trivial.c -o trivial.S 19 | 20 | clean: 21 | rm -rf *.S 22 | -------------------------------------------------------------------------------- /test/examples-llvm/baz.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "llvm_intrinsics.h" 3 | 4 | int main() { 5 | char fmt[] = "%d\n"; 6 | int x = 1 + 1 + 1; 7 | 8 | while (x != 10) { 9 | printf(fmt, x); 10 | x = x + 1; 11 | } 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /test/examples-llvm/fib.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "llvm_intrinsics.h" 3 | 4 | void fib(int n, int * out) { 5 | int x = 0; 6 | int y = 0; 7 | 8 | if (n == 0 || n == 1) { 9 | *out = n; 10 | 11 | return; 12 | } 13 | 14 | fib(n-1, &x); 15 | fib(n-2, &y); 16 | 17 | *out = x + y; 18 | 19 | return; 20 | } 21 | 22 | int main() { 23 | char fmt[] = "%d\n"; 24 | int i = 0; 25 | int x = 0; 26 | 27 | while (i != 11) { 28 | fib(i, &x); 29 | printf(fmt, x); 30 | i = i + 1; 31 | } 32 | 33 | return 0; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /test/examples-llvm/foo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void foo() { 4 | int x = 1; 5 | } 6 | 7 | int main() { 8 | int one = 1; 9 | int odd = 0; 10 | int even = 0; 11 | int i = 0; 12 | int n = 10; 13 | int r = 0; 14 | int total = 0; 15 | 16 | sum: 17 | foo(); 18 | r = i & 1; 19 | if (r == 1) goto odd; 20 | even = even + i; 21 | goto skip; 22 | 23 | odd: 24 | odd = odd + i; 25 | 26 | skip: 27 | i = i + 1; 28 | if (i != n) goto sum; 29 | total = odd + even; 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /test/examples-llvm/llvm_intrinsics.h: -------------------------------------------------------------------------------- 1 | #ifndef __INSTRINSIC_H__ 2 | #define __INSTRINSIC_H__ 3 | 4 | void intrinsic_memcpy(char * dst, char * src, int len) { 5 | int i = 0; 6 | 7 | while (i < len) { 8 | *dst = *src; 9 | dst = dst + 1; 10 | src = src + 1; 11 | i = i + 1; 12 | } 13 | } 14 | 15 | #endif /* !__INSTRINSIC_H__ */ -------------------------------------------------------------------------------- /test/examples-llvm/trivial.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int i = 0; 5 | 6 | return 0; 7 | } -------------------------------------------------------------------------------- /test/examples-ropl/baz.ropl: -------------------------------------------------------------------------------- 1 | fun main(){ 2 | fmt = "%d\n" 3 | x = 1+1+1 4 | print: 5 | !printf(fmt, x) 6 | x = x+1 7 | cmp x, 10 8 | jne print 9 | } 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/examples-ropl/fib.ropl: -------------------------------------------------------------------------------- 1 | fun fib(n, out){ 2 | x = 0 3 | y = 0 4 | 5 | cmp n, 0 6 | je copy 7 | cmp n, 1 8 | je copy 9 | 10 | fib(n-1, @x) 11 | fib(n-2, @y) 12 | 13 | [out] = x+y 14 | jmp exit 15 | copy: 16 | [out] = n 17 | exit: 18 | } 19 | 20 | fun main(){ 21 | fmt = "%d\n" 22 | i = 0 23 | x = 0 24 | print: 25 | fib(i, @x) 26 | !printf(fmt, x) 27 | i = i+1 28 | cmp i, 11 29 | jne print 30 | } 31 | 32 | -------------------------------------------------------------------------------- /test/examples-ropl/foo.ropl: -------------------------------------------------------------------------------- 1 | fun foo(){ 2 | x = 1; 3 | } 4 | 5 | fun main(){ 6 | one = 1 7 | odd = 0 8 | even = 0 9 | i = 0 10 | n = 10 11 | sum: 12 | ;foo() 13 | r = i & 1 14 | cmp r, 1 15 | je odd 16 | even = even+i 17 | jmp skip 18 | odd: 19 | odd = odd+i 20 | skip: 21 | i = i+1 22 | cmp i, n 23 | jne sum 24 | total = odd + even 25 | } 26 | 27 | -------------------------------------------------------------------------------- /test/examples-ropl/trivial.ropl: -------------------------------------------------------------------------------- 1 | fun main(){ 2 | i = 0 3 | } 4 | 5 | -------------------------------------------------------------------------------- /test/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define SZ 0x10000 6 | #define BUF_SIZE 2*SZ 7 | int data[1000000]; //make a big data section 8 | 9 | void start_rop(char *); 10 | 11 | int main (int argc, char *argv[]) { 12 | FILE * pFile; 13 | long lSize; 14 | char * buffer; 15 | size_t result; 16 | 17 | if(argc<2){ 18 | printf("Usage: %s \n", argv[0]); 19 | return 1; 20 | } 21 | 22 | pFile = fopen (argv[1], "rb" ); 23 | if (pFile==NULL) {fputs ("File error",stderr); exit (1);} 24 | 25 | fseek (pFile , 0 , SEEK_END); 26 | lSize = ftell (pFile); 27 | rewind (pFile); 28 | 29 | assert(lSize < BUF_SIZE/2); 30 | buffer = (char*) malloc (BUF_SIZE); 31 | if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);} 32 | 33 | printf("buf=0x%08x\n", (unsigned int)buffer); 34 | buffer = (char*)((((unsigned int)buffer+SZ-1)/SZ)*SZ); 35 | printf("roundup buf=0x%08x\n", (unsigned int)buffer); 36 | 37 | result = fread (buffer,1,lSize,pFile); 38 | if (result != lSize) {fputs ("Reading error",stderr); exit (3);} 39 | 40 | //pass the shellcode 41 | start_rop(buffer); 42 | 43 | // terminate 44 | fclose (pFile); 45 | free (buffer); 46 | return 0; 47 | } 48 | --------------------------------------------------------------------------------