From 4eb3efa2ccbf58c59a8d181c7d616b3d0c06e02b Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 10 Nov 2016 10:35:35 +0100 Subject: Use 64 bit address in debug information. Address constants need to be 64bit also in the debug information. Bug 20335 --- arm/TargetPrinter.ml | 2 ++ backend/PrintAsm.ml | 1 + backend/PrintAsmaux.ml | 1 + debug/DwarfPrinter.ml | 41 ++++++++++++++++++++++------------------- debug/DwarfTypes.mli | 1 + powerpc/TargetPrinter.ml | 7 +++++++ x86/TargetPrinter.ml | 2 ++ 7 files changed, 36 insertions(+), 19 deletions(-) diff --git a/arm/TargetPrinter.ml b/arm/TargetPrinter.ml index 6d194369..eb1a7c4c 100644 --- a/arm/TargetPrinter.ml +++ b/arm/TargetPrinter.ml @@ -870,6 +870,8 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET = let label = elf_label let new_label = new_label + + let address = if Archi.ptr64 then ".quad" else ".4byte" end let sel_target () = diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml index 8e43a050..9292745d 100644 --- a/backend/PrintAsm.ml +++ b/backend/PrintAsm.ml @@ -113,6 +113,7 @@ module Printer(Target:TARGET) = let section = Target.section let symbol = Target.symbol let comment = Target.comment + let address = Target.address end module DebugPrinter = DwarfPrinter (DwarfTarget) diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index b220659c..ff276af1 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -45,6 +45,7 @@ module type TARGET = val default_falignment: int val new_label: unit -> int val label: out_channel -> int -> unit + val address: string end (* On-the-fly label renaming *) diff --git a/debug/DwarfPrinter.ml b/debug/DwarfPrinter.ml index df67a352..43505e12 100644 --- a/debug/DwarfPrinter.ml +++ b/debug/DwarfPrinter.ml @@ -357,9 +357,9 @@ module DwarfPrinter(Target: DWARF_TARGET): let print_loc oc c loc = match loc with | LocSymbol s -> - print_sleb128 oc c 5; + print_sleb128 oc c (1 + !Machine.config.Machine.sizeof_ptr); print_byte oc "" dw_op_addr; - fprintf oc " .4byte %a\n" symbol s + fprintf oc " %s %a\n" address symbol s | LocSimple e -> print_sleb128 oc c (size_of_loc_expr e); print_loc_expr oc e @@ -371,9 +371,9 @@ module DwarfPrinter(Target: DWARF_TARGET): let print_list_loc oc = function | LocSymbol s -> - print_2byte oc "" 5; + print_2byte oc "" (1 + !Machine.config.Machine.sizeof_ptr); print_byte oc "" dw_op_addr; - fprintf oc " .4byte %a\n" symbol s + fprintf oc " %s %a\n" address symbol s | LocSimple e -> print_2byte oc "" (size_of_loc_expr e); print_loc_expr oc e @@ -391,7 +391,10 @@ module DwarfPrinter(Target: DWARF_TARGET): | _ -> () let print_addr oc c a = - fprintf oc " .4byte %a%a\n" label a print_comment c + fprintf oc " %s %a%a\n" address label a print_comment c + + let print_data4_addr oc c a = + fprintf oc " .4byte %a%a\n" label a print_comment c let print_array_type oc at = print_ref oc "DW_AT_type" at.array_type @@ -432,7 +435,7 @@ module DwarfPrinter(Target: DWARF_TARGET): print_uleb128 oc "DW_AT_language" 1; print_string oc "DW_AT_name" tag.compile_unit_name; print_string oc "DW_AT_producer" tag.compile_unit_prod_name; - print_addr oc "DW_AT_stmt_list" !debug_stmt_list + print_data4_addr oc "DW_AT_stmt_list" !debug_stmt_list let print_const_type oc ct = print_ref oc "DW_AT_type" ct.const_type @@ -573,7 +576,7 @@ module DwarfPrinter(Target: DWARF_TARGET): fprintf oc " .4byte %a-%a%a\n" label debug_end label debug_length_start print_comment "Length of Unit"; print_label oc debug_length_start; fprintf oc " .2byte 0x%d%a\n" !Clflags.option_gdwarf print_comment "DWARF version number"; (* Dwarf version *) - print_addr oc "Offset Into Abbrev. Section" !abbrev_start_addr; (* Offset into the abbreviation *) + print_data4_addr oc "Offset Into Abbrev. Section" !abbrev_start_addr; (* Offset into the abbreviation *) print_byte oc "Address Size (in bytes)" !Machine.config.Machine.sizeof_ptr; (* Sizeof pointer type *) print_entry oc entry; print_sleb128 oc "" 0; @@ -582,20 +585,20 @@ module DwarfPrinter(Target: DWARF_TARGET): let print_location_entry oc c_low l = print_label oc (loc_to_label l.loc_id); List.iter (fun (b,e,loc) -> - fprintf oc " .4byte %a-%a\n" label b label c_low; - fprintf oc " .4byte %a-%a\n" label e label c_low; + fprintf oc " %s %a-%a\n" address label b label c_low; + fprintf oc " %s %a-%a\n" address label e label c_low; print_list_loc oc loc) l.loc; - fprintf oc " .4byte 0\n"; - fprintf oc " .4byte 0\n" + fprintf oc " %s 0\n" address; + fprintf oc " %s 0\n" address let print_location_entry_abs oc l = print_label oc (loc_to_label l.loc_id); List.iter (fun (b,e,loc) -> - fprintf oc " .4byte %a\n" label b; - fprintf oc " .4byte %a\n" label e; + fprintf oc " %s %a\n" address label b; + fprintf oc " %s %a\n" address label e; print_list_loc oc loc) l.loc; - fprintf oc " .4byte 0\n"; - fprintf oc " .4byte 0\n" + fprintf oc " %s 0\n" address; + fprintf oc " %s 0\n" address let print_location_list oc (c_low,l) = @@ -628,10 +631,10 @@ module DwarfPrinter(Target: DWARF_TARGET): print_label oc !debug_ranges_addr; List.iter (fun l -> List.iter (fun (b,e) -> - fprintf oc " .4byte %a\n" label b; - fprintf oc " .4byte %a\n" label e) l; - fprintf oc " .4byte 0\n"; - fprintf oc " .4byte 0\n") r + fprintf oc " %s %a\n" address label b; + fprintf oc " %s %a\n" address label e) l; + fprintf oc " %s 0\n" address; + fprintf oc " %s 0\n" address) r let print_gnu_entries oc cp (lpc,loc) s r = compute_abbrev cp; diff --git a/debug/DwarfTypes.mli b/debug/DwarfTypes.mli index de4082a5..566fa16c 100644 --- a/debug/DwarfTypes.mli +++ b/debug/DwarfTypes.mli @@ -302,4 +302,5 @@ module type DWARF_TARGET = val section: out_channel -> section_name -> unit val symbol: out_channel -> atom -> unit val comment: string + val address: string end diff --git a/powerpc/TargetPrinter.ml b/powerpc/TargetPrinter.ml index 1271e410..3d4db98f 100644 --- a/powerpc/TargetPrinter.ml +++ b/powerpc/TargetPrinter.ml @@ -41,6 +41,7 @@ module type SYSTEM = val print_epilogue: out_channel -> unit val section: out_channel -> section_name -> unit val debug_section: out_channel -> section_name -> unit + val address: string end let symbol = elf_symbol @@ -170,6 +171,8 @@ module Linux_System : SYSTEM = end let debug_section _ _ = () + + let address = if Archi.ptr64 then ".quad" else ".4byte" end module Diab_System : SYSTEM = @@ -301,6 +304,8 @@ module Diab_System : SYSTEM = and end_line () = fprintf oc " .d2_line_end\n" in Debug.compute_diab_file_enum end_label entry_label end_line + let address = assert (not Archi.ptr64); ".4byte" + end module Target (System : SYSTEM):TARGET = @@ -868,6 +873,8 @@ module Target (System : SYSTEM):TARGET = let new_label = new_label + let address = address + let section oc sec = section oc sec; debug_section oc sec diff --git a/x86/TargetPrinter.ml b/x86/TargetPrinter.ml index 33d47830..b5aeefae 100644 --- a/x86/TargetPrinter.ml +++ b/x86/TargetPrinter.ml @@ -870,6 +870,8 @@ module Target(System: SYSTEM):TARGET = let new_label = new_label + let address = if Archi.ptr64 then ".quad" else ".long" + end let sel_target () = -- cgit