123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117(**************************************************************************)(* 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). *)(* *)(**************************************************************************)includeCli.Make_from_logger(Logger)(structletname="A stake to support the exploration and sanitize the unwanted \
non-determinism from missing initializations."letshortname=shortnameend)moduleFix=Builder.Variant_list(structletname="fix"letdoc="Fixed elements will be enforced to have a single value along the \
execution (rvalue, load, address, test, jump-target)."letaccept_empty=truetypet=watchpointletof_string=Watchpoint.of_stringend)moduleInterrupt=Builder.Variant_list(structletname="interrupt"letdoc="Interrupt the program when non-determinism is found (rvalue, load, \
address, test, jump-target)."letaccept_empty=truetypet=watchpointletof_string=Watchpoint.of_stringend)moduleRegInit=Builder.No(structletname="reg-init"letdoc="Initialize undefined registers (including flags) to zero."end)moduleMemInit=Builder.No(structletname="mem-init"letdoc=Format.sprintf"Try to initialize memory cells with either the value from the process \
image or zero. May fail if the address is non-deterministic (use \
'-%s-fix address')"shortnameend)letmake_options:unit->(moduleOPTIONS)=fun()->(modulestructletcheck=ifInterrupt.is_set()thenInterrupt.get()else[]letfix=ifFix.is_set()thenFix.get()else[Rvalue;Load;Address;Test;Target]letrval=ifList.memqRvaluecheckthenCheckelseifList.memRvaluefixthenFixelseIgnoreletload=ifList.memqLoadcheckthenCheckelseifList.memLoadfixthenFixelseIgnoreletaddr=ifList.memqAddresscheckthenCheckelseifList.memAddressfixthenFixelseIgnorelettest=ifList.memqTestcheckthenCheckelseifList.memTestfixthenFixelseIgnorelettarget=ifList.memqTargetcheckthenCheckelseifList.memTargetfixthenFixelseIgnoreletreg_init=RegInit.get()letmem_init=MemInit.get()end)let()=Sse.register_plugin~is_enabled(fun()->(modulePlugin((valmake_options()))))