diff --git a/CodeHawk/CHB/bchlib/bCHVersion.ml b/CodeHawk/CHB/bchlib/bCHVersion.ml index 99ecfc29..4403b540 100644 --- a/CodeHawk/CHB/bchlib/bCHVersion.ml +++ b/CodeHawk/CHB/bchlib/bCHVersion.ml @@ -95,8 +95,8 @@ end let version = new version_info_t - ~version:"0.6.0_20250521" - ~date:"2025-05-21" + ~version:"0.6.0_20250608" + ~date:"2025-06-08" ~licensee: None ~maxfilesize: None () diff --git a/CodeHawk/CHB/bchlibarm32/bCHARMOpcodeRecords.ml b/CodeHawk/CHB/bchlibarm32/bCHARMOpcodeRecords.ml index be8b1962..e6d0d1d2 100644 --- a/CodeHawk/CHB/bchlibarm32/bCHARMOpcodeRecords.ml +++ b/CodeHawk/CHB/bchlibarm32/bCHARMOpcodeRecords.ml @@ -4,7 +4,7 @@ ------------------------------------------------------------------------------ The MIT License (MIT) - Copyright (c) 2021-2024 Aarno Labs, LLC + Copyright (c) 2021-2025 Aarno Labs, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -1667,11 +1667,14 @@ let arm_opcode_to_string ?(width=12) (opc:arm_opcode_t) = let default () = (get_record opc).ida_asm formatter in let fnsdata = BCHFunctionData.functions_data in match opc with - | BranchLink (ACCAlways, tgt) when tgt#is_absolute_address -> + | BranchLink (ACCAlways, tgt) + | BranchLinkExchange (ACCAlways, tgt) + | BranchLinkExchange (ACCUnconditional, tgt) when tgt#is_absolute_address -> let tgtaddr = tgt#get_absolute_address in if fnsdata#has_function_name tgtaddr then let name = (fnsdata#get_function tgtaddr)#get_function_name in - (fixed_length_string "BL" width) + let popc = match opc with BranchLink _ -> "BL" | _ -> "BLX" in + (fixed_length_string popc width) ^ " <" ^ tgtaddr#to_hex_string ^ ":" diff --git a/CodeHawk/CHB/bchlibarm32/bCHConstructARMFunction.ml b/CodeHawk/CHB/bchlibarm32/bCHConstructARMFunction.ml index 99e86ff6..6c6ab00d 100644 --- a/CodeHawk/CHB/bchlibarm32/bCHConstructARMFunction.ml +++ b/CodeHawk/CHB/bchlibarm32/bCHConstructARMFunction.ml @@ -4,7 +4,7 @@ ------------------------------------------------------------------------------ The MIT License (MIT) - Copyright (c) 2022-2024 Aarno Labs LLC + Copyright (c) 2022-2025 Aarno Labs LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -126,6 +126,20 @@ let get_successors | Pop (_, _, rl, _) when rl#includes_pc -> (next ()) @ [wordmax] + | Adr (ACCAlways, dst, src) + when dst#is_pc_register && dst#is_absolute_address -> + if src#get_absolute_address#equal iaddr then + [] + else + [src#get_absolute_address] + + | Adr (_, dst, src) + when dst#is_pc_register && dst#is_absolute_address -> + if src#get_absolute_address#equal iaddr then + (next ()) + else + (next ()) @ [src#get_absolute_address] + (* return via LDM/LDMDB/LDMDA/LDMIB *) | LoadMultipleDecrementBefore (_, ACCAlways, _, rl, _) | LoadMultipleDecrementAfter (_, ACCAlways, _, rl, _) diff --git a/CodeHawk/CHB/bchlibarm32/bCHDisassembleARM.ml b/CodeHawk/CHB/bchlibarm32/bCHDisassembleARM.ml index 0b08abae..6629a11c 100644 --- a/CodeHawk/CHB/bchlibarm32/bCHDisassembleARM.ml +++ b/CodeHawk/CHB/bchlibarm32/bCHDisassembleARM.ml @@ -696,6 +696,13 @@ let set_block_boundaries () = when is_nr_call_instruction instr -> set_block_entry (va#add_int 4) + | Adr (_, dst, src) when dst#is_pc_register -> + begin + set_block_entry (va#add_int 4); + if src#is_absolute_address then + set_block_entry src#get_absolute_address + end + | _ -> ()) with | BCH_failure p -> diff --git a/CodeHawk/CHB/bchlibarm32/bCHFnARMDictionary.ml b/CodeHawk/CHB/bchlibarm32/bCHFnARMDictionary.ml index 8534f970..95d48570 100644 --- a/CodeHawk/CHB/bchlibarm32/bCHFnARMDictionary.ml +++ b/CodeHawk/CHB/bchlibarm32/bCHFnARMDictionary.ml @@ -144,6 +144,14 @@ object (self) else None in + let is_tail_call (): bool = + match instr#get_opcode with + | Branch (ACCAlways, tgt, _) + | BranchExchange (ACCAlways, tgt) when tgt#is_absolute_address -> + let tgtaddr = tgt#get_absolute_address in + functions_data#is_function_entry_point tgtaddr + | _ -> false in + let log_dc_error_result (file: string) (line: int) (e: string list) = if BCHSystemSettings.system_settings#collect_data then log_error_result ~msg:(p2s floc#l#toPretty) file line e @@ -397,7 +405,11 @@ object (self) (LBLOCK [ STR __FILE__; STR ":"; INT __LINE__; STR ": "; STR "Empty tag list"])) in - let rdefs = [get_rdef_r rv] @ (get_all_rdefs_r rrv) in + let rdefs = + if is_tail_call () then + [] + else + [get_rdef_r rv] @ (get_all_rdefs_r rrv) in let xtag = (List.hd tags) ^ "xxc" ^ (string_repeat "r" (List.length rdefs)) in let argslen = List.length args in let returntag = "return:" ^ (string_of_int argslen) in @@ -704,7 +716,18 @@ object (self) else tagstring :: ["call"; "argcount:" ^ (string_of_int (List.length callargs))] in + let (tags, args) = + if is_tail_call () then + (* we cannot use R0 here, because its invariant value at this point + will be the value at the start of the instruction, which is the + value of the first argument *) + let rvar = floc#env#mk_return_value floc#cia in + let xr0_r = Ok (XVar rvar) in + add_return_value tags args xr0_r xr0_r xr0_r + else + (tags, args) in let args = + (* the call-target should always stay in last position *) args @ [ixd#index_call_target floc#get_call_target#get_target] in (tags, args) in