66
77 Copyright (c) 2005-2020 Kestrel Technology LLC
88 Copyright (c) 2020 Henny Sipma
9- Copyright (c) 2021-2024 Aarno Labs LLC
9+ Copyright (c) 2021-2025 Aarno Labs LLC
1010
1111 Permission is hereby granted, free of charge, to any person obtaining a copy
1212 of this software and associated documentation files (the "Software"), to deal
@@ -155,7 +155,6 @@ object (self)
155155 val initialized_memory = H. create 3
156156
157157 val function_call_targets = H. create 13 (* (faddr, iaddr) -> call_target_t *)
158- val variable_intros = H. create 13 (* iaddr#index -> name *)
159158
160159 val esp_adjustments = H. create 3 (* indexed with faddr, iaddr *)
161160 val esp_adjustments_i = H. create 3 (* indexed with iaddr *)
@@ -611,6 +610,18 @@ object (self)
611610 set_functions_file_path ()
612611 end
613612
613+ method initialize_function_annotations =
614+ match load_userdata_system_file () with
615+ | Some node ->
616+ let getc = node#getTaggedChild in
617+ let hasc = node#hasOneTaggedChild in
618+ begin
619+ (if hasc " function-annotations" then
620+ BCHFunctionData. read_xml_function_annotations
621+ (getc " function-annotations" ))
622+ end
623+ | _ -> ()
624+
614625 method private initialize_system_file =
615626 try
616627 match load_system_file () with
@@ -832,13 +843,6 @@ object (self)
832843 (if hasc " symbolic-addresses" then
833844 BCHGlobalMemoryMap. read_xml_symbolic_addresses (getc " symbolic-addresses" ));
834845
835- (if hasc " function-annotations" then
836- BCHFunctionData. read_xml_function_annotations
837- (getc " function-annotations" ));
838-
839- (if hasc " variable-introductions" then
840- self#read_xml_variable_introductions (getc " variable-introductions" ));
841-
842846 (if hasc " userdeclared-codesections" then
843847 self#read_xml_userdeclared_codesections
844848 (getc " userdeclared-codesections" ));
@@ -1413,39 +1417,6 @@ object (self)
14131417 let name = get n " n" in
14141418 (functions_data#add_function fa)#add_name name) (getcc " fn" )
14151419
1416- method private read_xml_variable_introductions (node : xml_element_int ) =
1417- let geta n =
1418- fail_tvalue
1419- (trerror_record
1420- (LBLOCK [
1421- STR " read_xml_variable_introductions" ;
1422- STR (n#getAttribute " ia" )]))
1423- (string_to_doubleword (n#getAttribute " ia" )) in
1424- let getcc = node#getTaggedChildren in
1425- begin
1426- List. iter (fun n ->
1427- let iaddr = geta n in
1428- let name = n#getAttribute " name" in
1429- H. add variable_intros iaddr#index name) (getcc " vintro" );
1430- chlog#add
1431- " initialization"
1432- (LBLOCK [
1433- STR " system-info: read " ;
1434- INT (H. length variable_intros);
1435- STR " variable introductions" ])
1436- end
1437-
1438- method private write_xml_variable_introductions (node : xml_element_int ) =
1439- let vintros = H. fold (fun k v a -> (k, v)::a) variable_intros [] in
1440- List. iter (fun (dwindex , name ) ->
1441- let vnode = xmlElement " vintro" in
1442- begin
1443- vnode#setAttribute
1444- " ia" (TR. tget_ok (int_to_doubleword dwindex))#to_hex_string;
1445- vnode#setAttribute " name" name;
1446- node#appendChildren [vnode];
1447- end ) vintros
1448-
14491420 method private read_xml_user_nonreturning_functions (node :xml_element_int ) =
14501421 let geta n =
14511422 fail_tvalue
@@ -1555,8 +1526,6 @@ object (self)
15551526 self#read_xml_thread_start_functions (getc " thread-start-functions" )) ;
15561527 (if hasc " goto-returns" then
15571528 self#read_xml_goto_returns (getc " goto-returns" ));
1558- (if hasc " variable-introductions" then
1559- self#read_xml_variable_introductions (getc " variable-introductions" ));
15601529 (if hasc " so-imports" then
15611530 self#read_xml_so_imports (getc " so-imports" ));
15621531 end
@@ -1714,19 +1683,6 @@ object (self)
17141683 dNode
17151684 end ) data_blocks#toList)
17161685
1717- method has_variable_intro (iaddr : doubleword_int ) =
1718- H. mem variable_intros iaddr#index
1719-
1720- method has_variable_intros : bool = (H. length variable_intros) > 0
1721-
1722- method get_variable_intro_name (iaddr : doubleword_int ): string =
1723- if self#has_variable_intro iaddr then
1724- H. find variable_intros iaddr#index
1725- else
1726- raise
1727- (BCH_failure
1728- (LBLOCK [STR " No variable intro found for address " ; iaddr#toPretty]))
1729-
17301686 (* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
17311687 * stage 2: function entry points *
17321688 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *)
@@ -2152,7 +2108,6 @@ object (self)
21522108 let gNode = xmlElement " goto-returns" in
21532109 let cbNode = xmlElement " call-back-tables" in
21542110 let stNode = xmlElement " struct-tables" in
2155- let viNode = xmlElement " variable-introductions" in
21562111 let soNode = xmlElement " so-imports" in
21572112 begin
21582113 functions_data#write_xml fNode;
@@ -2163,11 +2118,10 @@ object (self)
21632118 self#write_xml_goto_returns gNode;
21642119 self#write_xml_call_back_tables cbNode;
21652120 self#write_xml_struct_tables stNode;
2166- self#write_xml_variable_introductions viNode;
21672121 string_table#write_xml sNode;
21682122 self#write_xml_so_imports soNode;
21692123 append [
2170- fNode; lNode; dNode; jNode; sNode; tNode; gNode; cbNode; stNode; viNode;
2124+ fNode; lNode; dNode; jNode; sNode; tNode; gNode; cbNode; stNode;
21712125 soNode]
21722126 end
21732127
0 commit comments