Skip to content

Commit 153fa9c

Browse files
committed
CHB: retain user entered function entry points
1 parent e2ae06a commit 153fa9c

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

CodeHawk/CHB/bchlib/bCHFunctionData.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,21 @@ object (self)
223223
H.clear nametable
224224
end
225225

226-
method add_function (fa:doubleword_int) =
226+
method add_function (fa:doubleword_int): function_data_int =
227227
let ix = fa#index in
228228
if H.mem table ix then
229229
H.find table ix
230230
else
231231
let fe = new function_data_t fa in
232232
begin
233-
H.add table ix fe ;
233+
H.add table ix fe;
234234
fe
235235
end
236236

237237
method remove_function (fa: doubleword_int) =
238238
H.remove table fa#index
239239

240-
method get_function (fa: doubleword_int) =
240+
method get_function (fa: doubleword_int): function_data_int =
241241
if self#is_function_entry_point fa then
242242
H.find table fa#index
243243
else
@@ -249,20 +249,21 @@ object (self)
249249
method has_function (fa: doubleword_int) =
250250
self#is_function_entry_point fa
251251

252-
method get_functions = H.fold (fun _ v a -> v::a) table []
252+
method get_functions: function_data_int list =
253+
H.fold (fun _ v a -> v::a) table []
253254

254-
method get_inlined_function_entry_points =
255+
method get_inlined_function_entry_points: doubleword_int list =
255256
self#retrieve_addresses (fun f -> f#is_inlined)
256257

257-
method get_function_entry_points =
258+
method get_function_entry_points: doubleword_int list =
258259
let inlinedfns = self#get_inlined_function_entry_points in
259260
let otherfns = self#retrieve_addresses (fun f -> not f#is_inlined) in
260261
(* List inlined functions before other functions, so they are guaranteed
261262
to have been constructed before the functions that inline them are
262263
being constructed.*)
263264
inlinedfns @ otherfns
264265

265-
method get_library_stubs =
266+
method get_library_stubs: doubleword_int list =
266267
self#retrieve_addresses (fun f -> f#is_library_stub)
267268

268269
method is_function_entry_point (fa:doubleword_int) = H.mem table fa#index

CodeHawk/CHB/bchlib/bCHSystemInfo.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,12 @@ object (self)
984984
method private read_xml_user_function_entry_points (node:xml_element_int) =
985985
List.iter (fun n ->
986986
let fa = geta_fail "read_xml_user_function_entry_points" n "a" in
987-
if functions_data#is_function_entry_point fa then () else
988-
ignore (functions_data#add_function fa))
989-
(node#getTaggedChildren "fe")
987+
let fndata =
988+
if functions_data#is_function_entry_point fa then
989+
functions_data#get_function fa
990+
else
991+
functions_data#add_function fa in
992+
fndata#set_user_provided) (node#getTaggedChildren "fe")
990993

991994
method private read_xml_call_target(node: xml_element_int): call_target_t =
992995
let get = node#getAttribute in

CodeHawk/CHB/bchlibarm32/bCHARMAssemblyFunctions.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ object (self)
628628
if functions_data#is_function_entry_point tgtaddr then
629629
let fndata = functions_data#get_function tgtaddr in
630630
let remaining = fndata#remove_callsite in
631-
if remaining = 0 then
631+
if remaining = 0 && not fndata#is_user_provided then
632632
begin
633633
functions_data#remove_function tgtaddr;
634634
self#remove_function tgtaddr;
@@ -748,10 +748,11 @@ object (self)
748748
| BranchLink (_, op)
749749
| BranchLinkExchange (_, op) when op#is_absolute_address ->
750750
let tgtaddr = op#get_absolute_address in
751-
if functions_data#is_function_entry_point tgtaddr && !notcode then
751+
if functions_data#is_function_entry_point tgtaddr
752+
&& !notcode then
752753
let fndata = functions_data#get_function tgtaddr in
753754
let remaining = fndata#remove_callsite in
754-
if remaining = 0 then
755+
if remaining = 0 && not fndata#is_user_provided then
755756
begin
756757
functions_data#remove_function tgtaddr;
757758
self#remove_function tgtaddr;

0 commit comments

Comments
 (0)