@@ -37,7 +37,6 @@ open CHXmlDocument
3737(* bchlib *)
3838open BCHBasicTypes
3939open BCHByteUtilities
40- open BCHConstantDefinitions
4140open BCHDataBlock
4241open BCHDoubleword
4342open BCHFunctionData
@@ -264,7 +263,7 @@ let get_instruction (addr: doubleword_int): arm_assembly_instruction_result =
264263 ^ " : "
265264 ^ (pretty_to_string p)]
266265
267- (* Return the addresses of valid instructions in the given address range
266+ (* Return the addresses of valid instructions in the given address range
268267 (inclusive) *)
269268let get_range_instruction_addrs
270269 (startaddr : doubleword_int ) (endaddr : doubleword_int ): doubleword_int list =
@@ -586,6 +585,7 @@ object (self)
586585 let firstNew = ref true in
587586 let datareftable = H. create (List. length datarefs) in
588587 let _ = List. iter (fun (a , refs ) -> H. add datareftable a refs) datarefs in
588+ let memorymap = BCHGlobalMemoryMap. global_memory_map in
589589 let not_code_to_string nc =
590590 match nc with
591591 | JumpTable jt ->
@@ -657,6 +657,19 @@ object (self)
657657 (List. map
658658 (fun (a , v ) ->
659659 let addr = a#to_hex_string in
660+ let datarefstr =
661+ if H. mem datareftable addr then
662+ let datarefs = H. find datareftable addr in
663+ " "
664+ ^ " (refs: "
665+ ^ (String. concat
666+ " , "
667+ (List. map
668+ (fun instr ->
669+ instr#get_address#to_hex_string) datarefs))
670+ ^ " )"
671+ else
672+ " " in
660673 if a#lt ! stringend then
661674 " "
662675 ^ (fixed_length_string addr 10 )
@@ -671,66 +684,89 @@ object (self)
671684 " "
672685 ^ (fixed_length_string addr 10 )
673686 ^ " <0xffffffff>"
674- else if H. mem datareftable addr then
675- let datarefs = H. find datareftable addr in
687+ else if functions_data#is_function_entry_point v then
688+ let name =
689+ if functions_data#has_function_name v then
690+ let fndata = functions_data#get_function v in
691+ " :" ^ fndata#get_function_name
692+ else
693+ " " in
676694 " "
677695 ^ (fixed_length_string addr 10 )
678- ^ " "
679- ^ (fixed_length_string v#to_hex_string 12 )
680- ^ (" referenced by: "
681- ^ (String. concat
682- " , "
683- (List. map
684- (fun instr ->
685- instr#get_address#to_hex_string) datarefs)))
696+ ^ " Faddr:<"
697+ ^ v#to_hex_string
698+ ^ name
699+ ^ " >"
700+ ^ 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
711+ else if elf_header#is_code_address v then
712+ " "
713+ ^ (fixed_length_string addr 10 )
714+ ^ " Code:<"
715+ ^ v#to_hex_string
716+ ^ " >"
717+ ^ datarefstr
718+ else if elf_header#is_data_address v then
719+ let s =
720+ match elf_header#get_string_at_address v with
721+ | Some s ->
722+ let len = String. length s in
723+ if len < 50 then
724+ " :\" " ^ s ^ " \" "
725+ else
726+ " :\" " ^ (String. sub s 0 50 ) ^ " ...\" "
727+ | _ -> " " in
728+ " "
729+ ^ (fixed_length_string addr 10 )
730+ ^ " Data:<"
731+ ^ v#to_hex_string
732+ ^ s
733+ ^ " >"
734+ ^ datarefstr
735+ else if elf_header#is_uninitialized_data_address v then
736+ " "
737+ ^ (fixed_length_string addr 10 )
738+ ^ " Bss:<"
739+ ^ v#to_hex_string
740+ ^ " >"
741+ ^ datarefstr
742+ else if Option. is_some
743+ (elf_header#get_string_at_address a) then
744+ let s =
745+ Option. get (elf_header#get_string_at_address a) in
746+ begin
747+ (" "
748+ ^ (fixed_length_string addr 10 )
749+ ^ " String:<"
750+ ^ (fixed_length_string v#to_hex_string 12 )
751+ ^ " >: \" "
752+ ^ s
753+ ^ " \" " )
754+ ^ datarefstr
755+ end
756+ else if (String. length datarefstr) > 0 then
757+ " "
758+ ^ (fixed_length_string addr 10 )
759+ ^ " Value<"
760+ ^ v#to_hex_string
761+ ^ " >"
762+ ^ datarefstr
686763 else
687- match elf_header#get_string_at_address a with
688- | Some s ->
689- stringend := a#add_int ((String. length s) + 1 );
690- begin
691- (" "
692- ^ (fixed_length_string addr 10 )
693- ^ " String:<"
694- ^ (fixed_length_string v#to_hex_string 12 )
695- ^ " >: \" "
696- ^ s
697- ^ " \" " )
698- end
699- | _ ->
700- if functions_data#is_function_entry_point v then
701- " "
702- ^ (fixed_length_string addr 10 )
703- ^ " Faddr:<"
704- ^ v#to_hex_string
705- ^ " >"
706- else if has_symbolic_address_name v then
707- let name = get_symbolic_address_name v in
708- " "
709- ^ (fixed_length_string addr 10 )
710- ^ " Sym:<"
711- ^ v#to_hex_string
712- ^ " :"
713- ^ name
714- ^ " >"
715- else if elf_header#is_code_address v then
716- " "
717- ^ (fixed_length_string addr 10 )
718- ^ " Code:<"
719- ^ v#to_hex_string
720- ^ " >"
721- else if elf_header#is_data_address v then
722- " "
723- ^ (fixed_length_string addr 10 )
724- ^ " Data:<"
725- ^ v#to_hex_string
726- ^ " >"
727- else
728- " "
729- ^ (fixed_length_string addr 10 )
730- ^ " "
731- ^ (fixed_length_string v#to_hex_string 14 )
732- ^ " "
733- ^ (opcode_string a v))
764+ " "
765+ ^ (fixed_length_string addr 10 )
766+ ^ " "
767+ ^ (fixed_length_string v#to_hex_string 14 )
768+ ^ " "
769+ ^ (opcode_string a v))
734770 (List. rev ! contents)))
735771 ^ " \n " ^ (string_repeat " =" 80 ) ^ " \n " )
736772 end
0 commit comments