Skip to content

Liftingsupport #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CodeHawk/CHB/bchlib/bCHVersion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
()
9 changes: 6 additions & 3 deletions CodeHawk/CHB/bchlibarm32/bCHARMOpcodeRecords.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
^ ":"
Expand Down
16 changes: 15 additions & 1 deletion CodeHawk/CHB/bchlibarm32/bCHConstructARMFunction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, _)
Expand Down
7 changes: 7 additions & 0 deletions CodeHawk/CHB/bchlibarm32/bCHDisassembleARM.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
25 changes: 24 additions & 1 deletion CodeHawk/CHB/bchlibarm32/bCHFnARMDictionary.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading