2626 ============================================================================= *)
2727
2828(* chlib *)
29+ open CHNumerical
2930open CHPretty
3031
3132(* chutil *)
@@ -34,8 +35,13 @@ open CHPrettyUtil
3435open CHTraceResult
3536open CHXmlDocument
3637
38+ (* xprlib *)
39+ open Xprt
40+ open XprTypes
41+
3742(* bchlib *)
3843open BCHBasicTypes
44+ open BCHBCTypePretty
3945open BCHByteUtilities
4046open BCHDataBlock
4147open BCHDoubleword
@@ -61,6 +67,9 @@ open BCHDisassembleThumbInstruction
6167module H = Hashtbl
6268module TR = CHTraceResult
6369
70+ let x2p = XprToPretty. xpr_formatter#pr_expr
71+ let p2s = CHPrettyUtil. pretty_to_string
72+ let x2s x = p2s (x2p x)
6473
6574let numArrays = 1000
6675let arrayLength = 100000
@@ -676,6 +685,67 @@ object (self)
676685 ^ " String:<"
677686 ^ (fixed_length_string v#to_hex_string 12 )
678687 ^ " > ... (cont'd)"
688+
689+ else if Option. is_some (memorymap#containing_location a) then
690+ match memorymap#containing_location a with
691+ | None -> " "
692+ | Some gloc ->
693+ let xprv = num_constant_expr a#to_numerical in
694+ let offset_r = gloc#address_offset xprv in
695+ TR. tfold_default
696+ (fun offset ->
697+ match offset with
698+ | XConst (IntConst n ) when n#equal numerical_zero ->
699+ " "
700+ ^ (fixed_length_string addr 10 )
701+ ^ " Global variable:<"
702+ ^ gloc#name
703+ ^ " : "
704+ ^ (btype_to_string gloc#btype)
705+ ^ " >"
706+ ^ " \n "
707+ ^ (fixed_length_string addr 10 )
708+ ^ " GV:<"
709+ ^ gloc#name
710+ ^ " :0 >: "
711+ ^ v#to_hex_string
712+ | XConst (IntConst n ) ->
713+ " "
714+ ^ (fixed_length_string addr 10 )
715+ ^ " GV:<"
716+ ^ gloc#name
717+ ^ " :"
718+ ^ (fixed_length_string n#toString 3 )
719+ ^ " >: "
720+ ^ v#to_hex_string
721+ | _ ->
722+ " "
723+ ^ (fixed_length_string addr 10 )
724+ ^ " GV:<"
725+ ^ gloc#name
726+ ^ " :"
727+ ^ (x2s offset)
728+ ^ " >: "
729+ ^ v#to_hex_string)
730+ (" "
731+ ^ (fixed_length_string addr 10 )
732+ ^ " GV:<"
733+ ^ gloc#name
734+ ^ " :?>: "
735+ ^ v#to_hex_string)
736+ offset_r
737+
738+ else if memorymap#has_elf_symbol v then
739+ let name = memorymap#get_elf_symbol v in
740+ " "
741+ ^ (fixed_length_string addr 10 )
742+ ^ " Sym:<"
743+ ^ v#to_hex_string
744+ ^ " :"
745+ ^ name
746+ ^ " >"
747+ ^ datarefstr
748+
679749 else if v#equal wordzero then
680750 " "
681751 ^ (fixed_length_string addr 10 )
@@ -684,6 +754,7 @@ object (self)
684754 " "
685755 ^ (fixed_length_string addr 10 )
686756 ^ " <0xffffffff>"
757+
687758 else if functions_data#is_function_entry_point v then
688759 let name =
689760 if functions_data#has_function_name v then
@@ -698,16 +769,7 @@ object (self)
698769 ^ name
699770 ^ " >"
700771 ^ datarefstr
701- else if memorymap#has_elf_symbol v then
702- let name = memorymap#get_elf_symbol v in
703- " "
704- ^ (fixed_length_string addr 10 )
705- ^ " Sym:<"
706- ^ v#to_hex_string
707- ^ " :"
708- ^ name
709- ^ " >"
710- ^ datarefstr
772+
711773 else if elf_header#is_code_address v then
712774 " "
713775 ^ (fixed_length_string addr 10 )
0 commit comments