From 564b6813b5c1d130ad662ff2ffd57b38eb399636 Mon Sep 17 00:00:00 2001 From: Ricardo Baratto Date: Wed, 28 Oct 2026 21:54:44 -0400 Subject: [PATCH 1/3] XML: Remove duplicate get_bch_root Most of the CHB code uses the method defined in CHB/bchlib/bCHPreFileIO.ml but the code in CHB/bchanalyze/bCHFileIO.ml was using its own version. The differences are: - The standard puts the binary information in the header itself whereas this one adds an application node under the header, and adds the binary information there. - The standard one includes chb-date and chb-version fields. - The standard one calls the root node "codehawk-binary-analyzer" whereas this one calls it "codehawk-binary-analysis". As an example, the header for xml generated from within bCHFileIO.ml used to be: ```
...
``` And now it is: ```
... ``` --- CodeHawk/CHB/bchanalyze/bCHFileIO.ml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/CodeHawk/CHB/bchanalyze/bCHFileIO.ml b/CodeHawk/CHB/bchanalyze/bCHFileIO.ml index 2812d780..eafb6d68 100644 --- a/CodeHawk/CHB/bchanalyze/bCHFileIO.ml +++ b/CodeHawk/CHB/bchanalyze/bCHFileIO.ml @@ -78,21 +78,6 @@ let xml_error (filename: string) (line: int) (column: int) (p: pretty_t) = p] -let get_bch_root (info:string):xml_element_int = - let exename = system_info#get_filename in - let root = xmlElement "codehawk-binary-analysis" in - let hNode = xmlElement "header" in - let aNode = xmlElement "application" in - begin - aNode#setAttribute "name" exename ; - aNode#setAttribute "info" info ; - aNode#setAttribute "time" (current_time_to_string ()) ; - root#appendChildren [ hNode ] ; - hNode#appendChildren [ aNode ] ; - root - end - - (* applies to x86 only *) let save_functions_list () = let filename = get_functions_filename () in From d8b974ba972b8c28ff59479ce3e49e0470e9360e Mon Sep 17 00:00:00 2001 From: Ricardo Baratto Date: Wed, 28 Oct 2026 22:09:03 -0400 Subject: [PATCH 2/3] CHB:CMD: Save disassembly metrics on disassembly-only mode The metrics are saved to s/_disassembly.xml. The change to CHB/bchanalyze/bCHFileIO.ml is needed, otherwise the metrics will always be overwritten by the ones from x86 (even if you're not analyzing x86). I went ahead and did this for all architectures. We decided not to gate this by -save_disassembly_status_in_xml since that is only used for X86/PE and the python side of things never passes this command line argument. --- CodeHawk/CHB/bchanalyze/bCHFileIO.ml | 1 - CodeHawk/CHB/bchcmdline/bCHXBinaryAnalyzer.ml | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CodeHawk/CHB/bchanalyze/bCHFileIO.ml b/CodeHawk/CHB/bchanalyze/bCHFileIO.ml index eafb6d68..943deca8 100644 --- a/CodeHawk/CHB/bchanalyze/bCHFileIO.ml +++ b/CodeHawk/CHB/bchanalyze/bCHFileIO.ml @@ -261,7 +261,6 @@ let save_disassembly_status () = let root = get_bch_root "disassembly-status" in let fnode = xmlElement "disassembly-status" in begin - disassembly_summary#set_disassembly_metrics (get_disassembly_metrics ()) ; disassembly_summary#write_xml fnode ; doc#setNode root ; root#appendChildren [ fnode ] ; diff --git a/CodeHawk/CHB/bchcmdline/bCHXBinaryAnalyzer.ml b/CodeHawk/CHB/bchcmdline/bCHXBinaryAnalyzer.ml index b6d7f1aa..864e6890 100644 --- a/CodeHawk/CHB/bchcmdline/bCHXBinaryAnalyzer.ml +++ b/CodeHawk/CHB/bchcmdline/bCHXBinaryAnalyzer.ml @@ -397,6 +397,7 @@ let main () = ((Unix.gettimeofday ()) -. !t) in if !save_xml then begin + disassembly_summary#set_disassembly_metrics (get_disassembly_metrics ()) ; save_disassembly_status () ; exit 0 end @@ -447,6 +448,7 @@ let main () = let _ = disassembly_summary#set_disassembly_metrics (get_disassembly_metrics ()) in let _ = pr_debug [disassembly_summary#toPretty; NL] in + let _ = save_disassembly_status () in begin file_output#saveFile (get_asm_listing_filename ()) @@ -491,6 +493,7 @@ let main () = disassembly_summary#set_disassembly_metrics (get_mips_disassembly_metrics ()) in let _ = pr_debug [disassembly_summary#toPretty; NL] in + let _ = save_disassembly_status () in (* let _ = pr_debug [ @@ -548,6 +551,7 @@ let main () = let _ = disassembly_summary#set_disassembly_metrics (get_pwr_disassembly_metrics ()) in let _ = pr_debug [NL; NL; disassembly_summary#toPretty; NL] in + let _ = save_disassembly_status () in let instrs = !BCHPowerAssemblyInstructions.pwr_assembly_instructions in begin pverbose [STR "Saving asm file ..."; NL]; @@ -585,6 +589,7 @@ let main () = let _ = disassembly_summary#set_disassembly_metrics (get_arm_disassembly_metrics ()) in let _ = pr_debug [NL; NL; disassembly_summary#toPretty; NL] in + let _ = save_disassembly_status () in let _ = save_bc_files () in (* let _ = From fe4e7fa31bf8e7ac458eddfd6189ccabea0c65b2 Mon Sep 17 00:00:00 2001 From: Ricardo Baratto Date: Mon, 2 Nov 2026 09:14:35 -0500 Subject: [PATCH 3/3] CHB: Update version after modifications to XML format and addition of disassembly stats --- CodeHawk/CHB/bchlib/bCHVersion.ml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CodeHawk/CHB/bchlib/bCHVersion.ml b/CodeHawk/CHB/bchlib/bCHVersion.ml index f0fe0c57..eb9d8553 100644 --- a/CodeHawk/CHB/bchlib/bCHVersion.ml +++ b/CodeHawk/CHB/bchlib/bCHVersion.ml @@ -1,9 +1,9 @@ (* ============================================================================= - CodeHawk Binary Analyzer + CodeHawk Binary Analyzer Author: Henny Sipma ------------------------------------------------------------------------------ The MIT License (MIT) - + Copyright (c) 2005-2019 Kestrel Technology LLC Copyright (c) 2020 Henny Sipma Copyright (c) 2021-2026 Aarno Labs LLC @@ -14,10 +14,10 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -43,7 +43,7 @@ object end -class version_info_t +class version_info_t ?(maxfilesize=None) ?(licensee=None) ~(version:string) @@ -94,9 +94,9 @@ object (self) end -let version = new version_info_t - ~version:"0.6.0_20261001" - ~date:"2026-10-01" +let version = new version_info_t + ~version:"0.6.0_20261102" + ~date:"2026-11-02" ~licensee: None ~maxfilesize: None ()