12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667(**************************************************************************)(* 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). *)(* *)(**************************************************************************)moduleH=Hashtbl.Make(Virtual_address)letdo_disasmentry=lethtbl=H.create257inletcallees=H.create17inletlo,hi=Loader_utils.(section_slice_by_name".text"(Kernel_functions.get_img()))inletcfg=Disasm_core.fold(funcfgwlstinstset->H.addhtblinst.Instruction.addressinst;Instr_cfg.add_instcfginst.Instruction.addressinst;letset=Virtual_address.Set.filter(funins->ins>=lo&&ins<=hi)setinVirtual_address.Set.iter(Instr_cfg.add_edge_acfginst.Instruction.address)set;letblock_callees=Dhunk.calleesinst.Instruction.dba_blockinVirtual_address.Set.iter(funvaddr->H.addcalleesvaddr())block_callees;letset=Virtual_address.Set.filter(funins->not(H.memhtblins))setin(cfg,Disasm_core.W.add_setwlstset))(Instr_cfg.create257)(Disasm_core.W.singletonentry)in(cfg,H.fold(func_l->c::l)callees[])letrun()=letventry=matchKernel_functions.get_ep()with|Somee->e|None->Kernel_functions.get_img()|>Loader.Img.entryinletentry=Instr_cfg.V.of_addrventryintryletcfg,callees=do_disasmventryinletchannel=open_out"cfg.dot"inInstr_cfg.output_graphchannelcfg~entrycallees;close_outchannelwithUnix.Unix_error(e,_,_)->Disasm_options.Logger.error"%s"(Unix.error_messagee)