123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116(**************************************************************************)(* This file is part of BINSEC. *)(* *)(* Copyright (C) 2016-2026 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)openOptionsletregister_plugin=Plugins.registerlet()=register_plugin~is_enabled:Options.KillFlagsAtReturn.get(fun()->(moduleOpt.Flags));register_plugin~is_enabled:QMerge.get(fun()->(moduleBinsec_sse_quick_merge.Plugin))letget_worklist:unit->(moduleWorklist.S)=fun()->matchSearch_heuristics.get()with|Dfs->(moduleWorklist.Dfs)|Bfs->(moduleWorklist.Bfs)|Nurs->letseed=matchSeed.get_opt()with|Somes->s|None->letv=Random.bits()inLogger.info"Random search seed is %d"v;Seed.setv;vinRandom.initseed;(moduleWorklist.Nurs)letrun()=ifis_enabled()&&Kernel_options.ExecFile.is_set()thenletmoduleR=Exec.Run(structletfilename=Kernel_options.ExecFile.get()letisa=Some(Kernel_options.Machine.get())letimg=Kernel_functions.get_img()letfs=letmap=Option.fold~none:Fun.id~some:(funrootpath->Filename.concatrootpath)(Options.Sysroot.get_opt())infunpath->matchUnix.openfile(mappath)[Unix.O_RDONLY]0with|exceptionUnix.Unix_error_->raiseNot_found|file_descr->letbuffer=Bigarray.array1_of_genarray(Unix.map_filefile_descrInt8_unsignedC_layoutfalse[|-1|])inUnix.closefile_descr;bufferletassembler:(moduleCompiler.ASSEMBLER)=ifCse.get()then(moduleCompiler.Cse)else(moduleCompiler.Default)lettrace:Compiler.trace=letdebug_level=Options.Logger.get_debug_level()inifdebug_level>=40thenIrelseifdebug_level>=2thenAssemblyelseNolettransient_enum=Options.TransientEnum.get()letmax_depth=Options.MaxDepth.get()letenumeration_limit=Options.JumpEnumDepth.get()letsmt_backend=Smt_options.backend(Smt_options.Solver.get())letsmt_timeout=matchSmt_options.Timeout.get_opt()with|Some0.->None|opt->optletsmt_multichecks=Smt_options.Multichecks.get()letsmt_dumpdir=Smt_options.DumpDir.get_opt()letmissing_symbols=Options.MissingSymbol.get()lettimeout=Options.Timeout.get_opt()letentry=Kernel_functions.get_ep()letscript=matchScriptFiles.get()with|[]->Fun.const[]|files->Fun.flipScript.read_filesfilesletplugins=Plugins.list()end)((valEngine.get_factory()))((valget_worklist()))()inR.unitlet_=Cli.Boot.enlist~name:"SSE"~f:run