Skip to content

Commit ed9f129

Browse files
committed
CHB:ARM: collect new function entry points from function pointer arguments
1 parent 2e2387d commit ed9f129

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

CodeHawk/CHB/bchlibarm32/bCHFnARMDictionary.ml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@ open BCHDoubleword
5454
open BCHFloc
5555
open BCHLocation
5656
open BCHFtsParameter
57+
open BCHFunctionData
5758
open BCHFunctionInterface
5859
open BCHFunctionSummaryLibrary
5960
open BCHLibTypes
6061
open BCHLocation
6162
open BCHSystemInfo
6263

64+
(* bchlibelf *)
65+
open BCHELFHeader
66+
6367
(* bchlibarm32 *)
6468
open BCHARMAssemblyInstructions
6569
open BCHARMConditionalExpr
@@ -419,8 +423,32 @@ object (self)
419423
"function prototype registration"
420424
(LBLOCK [STR "No function summary found for "; STR name]) in
421425

426+
let check_for_functionptr_args callargs =
427+
List.iter (fun (p, x) ->
428+
let ptype = get_parameter_type p in
429+
if is_function_type ptype then
430+
match x with
431+
| XConst (IntConst n) ->
432+
(match numerical_to_doubleword n with
433+
| Error _ -> ()
434+
| Ok dw ->
435+
if elf_header#is_code_address dw then
436+
begin
437+
ignore (functions_data#add_function dw);
438+
chlog#add
439+
"add function entry point"
440+
(LBLOCK [
441+
floc#l#toPretty;
442+
STR ": function addr: ";
443+
dw#toPretty])
444+
end)
445+
| _ -> ()
446+
else
447+
()) callargs in
448+
422449
let callinstr_key (): (string list * int list) =
423450
let callargs = floc#get_call_arguments in
451+
let _ = check_for_functionptr_args callargs in
424452
let (xprs, xvars, rdefs) =
425453
List.fold_left (fun (xprs, xvars, rdefs) (p, x) ->
426454
let xvar =
@@ -746,8 +774,8 @@ object (self)
746774
let (tags, args) = add_optional_instr_condition tagstring args c in
747775
(tags, args)
748776

749-
| Branch (_, tgt, _)
750-
when tgt#is_absolute_address && floc#has_call_target ->
777+
| Branch _
778+
| BranchExchange _ when floc#has_call_target ->
751779
callinstr_key ()
752780

753781
| Branch _ when instr#is_aggregate_anchor ->

0 commit comments

Comments
 (0)