@@ -44,6 +44,7 @@ open BCHBCTypes
4444open BCHBCTypeUtil
4545open BCHDoubleword
4646open BCHLibTypes
47+ open BCHMemoryReference
4748
4849module H = Hashtbl
4950module TR = CHTraceResult
@@ -62,6 +63,8 @@ let optty2s (ty: btype_t option) =
6263
6364let bcd = BCHBCDictionary. bcdictionary
6465
66+ let eloc (line : int ): string = __FILE__ ^ " :" ^ (string_of_int line)
67+ let elocm (line : int ): string = (eloc line) ^ " : "
6568
6669let globalvalue_to_pretty (gv : globalvalue_t ): pretty_t =
6770 match gv with
@@ -71,13 +74,12 @@ let globalvalue_to_pretty (gv: globalvalue_t): pretty_t =
7174
7275let _global_location_ref_to_pretty (gref : global_location_ref_t ): pretty_t =
7376 match gref with
74- | GLoad (gaddr , iaddr , gxpr , size , signed ) ->
77+ | GLoad (gaddr , iaddr , offset , size , signed , _vtype ) ->
7578 LBLOCK [
7679 STR " load: " ;
7780 gaddr#toPretty; STR " , " ;
7881 STR iaddr; STR " " ;
79- x2p gxpr;
80- STR " " ;
82+ STR (memory_offset_to_string offset); STR " " ;
8183 INT size;
8284 (if signed then STR " (signed)" else STR " " )
8385 ]
@@ -87,7 +89,7 @@ let _global_location_ref_to_pretty (gref: global_location_ref_t): pretty_t =
8789 gaddr#toPretty; STR " , " ;
8890 STR iaddr;
8991 STR " " ;
90- x2p gxpr;
92+ STR (x2s gxpr) ;
9193 STR " " ;
9294 INT size]
9395 | GAddressArgument (gaddr , iaddr , argindex , gxpr , btype , memoff ) ->
@@ -706,42 +708,74 @@ object (self)
706708 [] in
707709 H. replace unconnectedreferences faddr#index (gref :: entry)
708710
711+ method add_location_gload
712+ (faddr : doubleword_int )
713+ (iaddr : ctxt_iaddress_t )
714+ (gaddr : doubleword_int )
715+ (offset : memory_offset_t )
716+ (size : int )
717+ (signed : bool )
718+ (vtype : btype_t ) =
719+ let gload = GLoad (gaddr, iaddr, offset, size, signed, vtype) in
720+ self#add_global_ref faddr gload
721+
722+ (*
709723 method add_gload
710724 (faddr: doubleword_int)
711725 (iaddr: ctxt_iaddress_t)
712726 (gxpr: xpr_t)
713727 (size: int)
714- (signed : bool ) =
728+ (signed: bool): unit traceresult =
715729 match self#xpr_containing_location gxpr with
716730 | Some gloc ->
717731 let gload = GLoad (gloc#address, iaddr, gxpr, size, signed) in
718- self#add_global_ref faddr gload
732+ begin
733+ self#add_global_ref faddr gload;
734+ Ok ()
735+ end
719736 | _ ->
720737 (match gxpr with
721738 | XConst (IntConst n) ->
722739 let gaddr = numerical_mod_to_doubleword n in
723740 let gload = GLoad (gaddr, iaddr, gxpr, size, signed) in
724- self#add_unconnected_ref faddr gload
741+ begin
742+ self#add_unconnected_ref faddr gload;
743+ Error [(elocm __LINE__);
744+ "Unable to match address " ^ (gaddr#to_hex_string)
745+ ^ " with a global location. Unconnected reference "
746+ ^ "recorded for this address"]
747+ end
725748 | _ ->
726- () )
727-
749+ Error [(elocm __LINE__);
750+ "Unable to match address " ^ (x2s gxpr)
751+ ^ " with a global location: No load recorded"])
752+ *)
728753 method add_gstore
729754 (faddr : doubleword_int )
730755 (iaddr : ctxt_iaddress_t )
731756 (gxpr : xpr_t )
732757 (size : int )
733- (optvalue : CHNumerical.numerical_t option ) =
758+ (optvalue : CHNumerical.numerical_t option ): unit traceresult =
734759 match self#xpr_containing_location gxpr with
735760 | Some gloc ->
736761 let gstore = GStore (gloc#address, iaddr, gxpr, size, optvalue) in
737- self#add_global_ref faddr gstore
762+ Ok ( self#add_global_ref faddr gstore)
738763 | _ ->
739- (match gxpr with
740- | XConst (IntConst n ) ->
741- let gaddr = numerical_mod_to_doubleword n in
742- let gstore = GStore (gaddr, iaddr, gxpr, size, optvalue) in
743- self#add_unconnected_ref faddr gstore
744- | _ -> () )
764+ match gxpr with
765+ | XConst (IntConst n ) ->
766+ let gaddr = numerical_mod_to_doubleword n in
767+ let gstore = GStore (gaddr, iaddr, gxpr, size, optvalue) in
768+ begin
769+ self#add_unconnected_ref faddr gstore;
770+ Error [(elocm __LINE__);
771+ " Unable to match address " ^ (gaddr#to_hex_string)
772+ ^ " with a global location. Unconnected reference "
773+ ^ " recorded for this address" ]
774+ end
775+ | _ ->
776+ Error [elocm __LINE__;
777+ " Unable to match address " ^ (faddr#to_hex_string)
778+ ^ " with a global location." ]
745779
746780 method add_gaddr_argument
747781 (faddr : doubleword_int )
@@ -873,13 +907,14 @@ object (self)
873907 | Some off -> seti " mix" (vard#index_memory_offset off)
874908 | _ -> () in
875909 match gref with
876- | GLoad (gaddr , iaddr , gxpr , size , signed ) ->
910+ | GLoad (gaddr , iaddr , offset , size , signed , vtype ) ->
877911 begin
878912 set " t" " L" ;
913+ seti " mix" (vard#index_memory_offset offset);
879914 set_gaddr gaddr;
880- set_gxpr gxpr;
881915 set_iaddr iaddr;
882916 set_size size;
917+ set_btype vtype;
883918 (if signed then set " sg" " yes" )
884919 end
885920 | GStore (gaddr , iaddr , gxpr , size , optvalue ) ->
0 commit comments