@@ -75,7 +75,8 @@ let stackvar_intro_to_string (svi: stackvar_intro_t) =
7575 match svi.svi_vartype with
7676 | Some t -> " (" ^ (btype_to_string t) ^ " )"
7777 | _ -> " " in
78- (string_of_int svi.svi_offset) ^ " : " ^ svi.svi_name ^ ptype
78+ let lc_p = if svi.svi_loopcounter then " (lc)" else " " in
79+ (string_of_int svi.svi_offset) ^ " : " ^ svi.svi_name ^ ptype ^ lc_p
7980
8081
8182let reachingdef_spec_to_string (rds : reachingdef_spec_t ) =
@@ -374,6 +375,11 @@ object (self)
374375 else
375376 BCHSystemSettings. system_settings#is_typing_rule_enabled name
376377
378+ method is_const_global_variable (name : string ): bool =
379+ match self#get_function_annotation with
380+ | None -> false
381+ | Some a -> List. mem name a.constglobalvars
382+
377383 method filter_deflocs
378384 (iaddr : string ) (v : variable_t ) (deflocs : symbol_t list ): symbol_t list =
379385 match self#get_function_annotation with
@@ -689,6 +695,7 @@ let read_xml_stackvar_intro (node: xml_element_int): stackvar_intro_t traceresul
689695 else
690696 let svi_offset = (- (geti " offset" )) in
691697 let svi_name = get " name" in
698+ let svi_loopcounter = has " loopcounter" && (get " loopcounter" ) = " yes" in
692699 let (svi_vartype, svi_cast) =
693700 if has " typename" then
694701 let typename = get " typename" in
@@ -712,6 +719,7 @@ let read_xml_stackvar_intro (node: xml_element_int): stackvar_intro_t traceresul
712719 (None , false ) in
713720 Ok {svi_offset = svi_offset;
714721 svi_name = svi_name;
722+ svi_loopcounter = svi_loopcounter;
715723 svi_vartype = svi_vartype;
716724 svi_cast = svi_cast}
717725
@@ -757,6 +765,66 @@ let read_xml_reachingdef_spec
757765 }
758766
759767
768+ let read_xml_stackvarintros (node : xml_element_int ): stackvar_intro_t list =
769+ List. fold_left
770+ (fun acc n ->
771+ TR. tfold
772+ ~ok: (fun svi -> svi :: acc)
773+ ~error: (fun e ->
774+ begin
775+ log_error_result __FILE__ __LINE__ e;
776+ acc
777+ end )
778+ (read_xml_stackvar_intro n))
779+ []
780+ (node#getTaggedChildren " vintro" )
781+
782+
783+ let read_xml_regvarintros (node : xml_element_int ): regvar_intro_t list =
784+ List. fold_left
785+ (fun acc n ->
786+ TR. tfold
787+ ~ok: (fun rvi -> rvi :: acc)
788+ ~error: (fun e ->
789+ begin
790+ log_error_result __FILE__ __LINE__ e;
791+ acc
792+ end )
793+ (read_xml_regvar_intro n))
794+ []
795+ (node#getTaggedChildren " vintro" )
796+
797+
798+ let read_xml_typingrules (node : xml_element_int ): typing_rule_t list =
799+ List. fold_left
800+ (fun acc n ->
801+ TR. tfold
802+ ~ok: (fun tr -> tr :: acc)
803+ ~error: (fun e ->
804+ begin
805+ log_error_result __FILE__ __LINE__ e;
806+ acc
807+ end )
808+ (read_xml_typing_rule n))
809+ []
810+ (node#getTaggedChildren " typingrule" )
811+
812+
813+ let read_xml_removerdefs (node : xml_element_int ): reachingdef_spec_t list =
814+ List. fold_left
815+ (fun acc n ->
816+ TR. tfold
817+ ~ok: (fun rds -> rds :: acc)
818+ ~error: (fun e ->
819+ begin
820+ log_error_result __FILE__ __LINE__ e;
821+ acc
822+ end )
823+ (read_xml_reachingdef_spec n))
824+ []
825+ (node#getTaggedChildren " remove-var-rdefs" )
826+
827+
760828let read_xml_function_annotation (node : xml_element_int ) =
761829 let get = node#getAttribute in
762830 let getc = node#getTaggedChild in
@@ -771,77 +839,37 @@ let read_xml_function_annotation (node: xml_element_int) =
771839 functions_data#add_function dw in
772840 let stackvintros =
773841 if hasc " stackvar-intros" then
774- let svintros = getc " stackvar-intros" in
775- List. fold_left
776- (fun acc n ->
777- TR. tfold
778- ~ok: (fun svi -> svi :: acc)
779- ~error: (fun e ->
780- begin
781- log_error_result __FILE__ __LINE__ e;
782- acc
783- end )
784- (read_xml_stackvar_intro n))
785- []
786- (svintros#getTaggedChildren " vintro" )
842+ read_xml_stackvarintros (getc " stackvar-intros" )
787843 else
788844 [] in
789845 let regvintros =
790846 if hasc " regvar-intros" then
791- let rvintros = getc " regvar-intros" in
792- List. fold_left
793- (fun acc n ->
794- TR. tfold
795- ~ok: (fun rvi -> rvi :: acc)
796- ~error: (fun e ->
797- begin
798- log_error_result __FILE__ __LINE__ e;
799- acc
800- end )
801- (read_xml_regvar_intro n))
802- []
803- (rvintros#getTaggedChildren " vintro" )
847+ read_xml_regvarintros (getc " regvar-intros" )
804848 else
805849 [] in
806850 let typingrules =
807851 if hasc " typing-rules" then
808- let trules = getc " typing-rules" in
809- List. fold_left
810- (fun acc n ->
811- TR. tfold
812- ~ok: (fun tr -> tr :: acc)
813- ~error: (fun e ->
814- begin
815- log_error_result __FILE__ __LINE__ e;
816- acc
817- end )
818- (read_xml_typing_rule n))
819- []
820- (trules#getTaggedChildren " typingrule" )
852+ read_xml_typingrules (getc " typing-rules" )
821853 else
822854 [] in
823855 let rdefspecs =
824856 if hasc " remove-rdefs" then
825- let rrds = getc " remove-rdefs" in
826- List. fold_left
827- (fun acc n ->
828- TR. tfold
829- ~ok: (fun rds -> rds :: acc)
830- ~error: (fun e ->
831- begin
832- log_error_result __FILE__ __LINE__ e;
833- acc
834- end )
835- (read_xml_reachingdef_spec n))
836- []
837- (rrds#getTaggedChildren " remove-var-rdefs" )
857+ read_xml_removerdefs (getc " remove-rdefs" )
858+ else
859+ [] in
860+ let constglobals =
861+ if hasc " const-global-variables" then
862+ let gnode = getc " const-global-variables" in
863+ List. map
864+ (fun n -> n#getAttribute " name" ) (gnode#getTaggedChildren " gvar" )
838865 else
839866 [] in
840867 fndata#set_function_annotation
841868 {regvarintros = regvintros;
842869 stackvarintros = stackvintros;
843870 typingrules = typingrules;
844- reachingdefspecs = rdefspecs
871+ reachingdefspecs = rdefspecs;
872+ constglobalvars = constglobals
845873 })
846874 ~error: (fun e -> log_error_result __FILE__ __LINE__ e)
847875 (string_to_doubleword faddr)
0 commit comments