From a479c280441b91007c379b0b63b907926d54f930 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 13 Oct 2015 16:23:20 +0200 Subject: Changed the type of the debug sections with additional string. Instead of using a string they now take an optional string, which should be none if the backend is not the diab backend and the corresponding section is the text section and Some s with s being the custom section name else. Bug 17392. --- common/Sections.ml | 4 ++-- common/Sections.mli | 4 ++-- debug/DwarfPrinter.ml | 7 ++++--- powerpc/TargetPrinter.ml | 16 +++++++++++----- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/common/Sections.ml b/common/Sections.ml index 70311d4e..0910f2dc 100644 --- a/common/Sections.ml +++ b/common/Sections.ml @@ -28,9 +28,9 @@ type section_name = | Section_jumptable | Section_user of string * bool (*writable*) * bool (*executable*) | Section_debug_abbrev - | Section_debug_info of string + | Section_debug_info of string option | Section_debug_loc - | Section_debug_line of string + | Section_debug_line of string option | Section_debug_str type access_mode = diff --git a/common/Sections.mli b/common/Sections.mli index 276fc047..6b1e56fa 100644 --- a/common/Sections.mli +++ b/common/Sections.mli @@ -27,9 +27,9 @@ type section_name = | Section_jumptable | Section_user of string * bool (*writable*) * bool (*executable*) | Section_debug_abbrev - | Section_debug_info of string + | Section_debug_info of string option | Section_debug_loc - | Section_debug_line of string + | Section_debug_line of string option | Section_debug_str type access_mode = diff --git a/debug/DwarfPrinter.ml b/debug/DwarfPrinter.ml index 407850a5..12ad16bf 100644 --- a/debug/DwarfPrinter.ml +++ b/debug/DwarfPrinter.ml @@ -602,7 +602,8 @@ module DwarfPrinter(Target: DWARF_TARGET): List.iter (fun e -> compute_abbrev e.entry) entries; print_abbrev oc; List.iter (fun e -> - section oc (Section_debug_info e.section_name); + let name = if e.section_name <> ".text" then Some e.section_name else None in + section oc (Section_debug_info name); print_debug_info oc e.start_label e.line_label e.entry) entries; section oc Section_debug_loc; List.iter (fun e -> print_location_list oc e.locs) entries @@ -613,12 +614,12 @@ module DwarfPrinter(Target: DWARF_TARGET): and start = new_label () and abbrev_start = new_label () in abbrev_start_addr := abbrev_start; - section oc (Section_debug_info ""); + section oc (Section_debug_info None); print_debug_info oc start line_start cp; print_abbrev oc; section oc Section_debug_loc; print_location_list oc loc; - section oc (Section_debug_line ""); + section oc (Section_debug_line None); print_label oc line_start; section oc Section_debug_str; List.iter (fun (id,s) -> diff --git a/powerpc/TargetPrinter.ml b/powerpc/TargetPrinter.ml index 61ac5e42..a596e587 100644 --- a/powerpc/TargetPrinter.ml +++ b/powerpc/TargetPrinter.ml @@ -218,20 +218,25 @@ module Diab_System : SYSTEM = | true, false -> 'd' (* data *) | false, true -> 'c' (* text *) | false, false -> 'r') (* const *) - | Section_debug_info s -> sprintf ".section .debug_info%s,,n" (if s <> ".text" then s else "") + | Section_debug_info (Some s) -> + sprintf ".section .debug_info%s,,n" s + | Section_debug_info None -> + sprintf ".section .debug_info,,n" | Section_debug_abbrev -> ".section .debug_abbrev,,n" | Section_debug_loc -> ".section .debug_loc,,n" - | Section_debug_line s -> sprintf ".section .debug_line.%s,,n\n" s + | Section_debug_line (Some s) -> + sprintf ".section .debug_line.%s,,n\n" s + | Section_debug_line None -> + sprintf ".section .debug_line,,n\n" | Section_debug_str -> assert false (* Should not be used *) let section oc sec = let name = name_of_section sec in assert (name <> "COMM"); match sec with - | Section_debug_info s -> + | Section_debug_info (Some s) -> fprintf oc " %s\n" name; - if s <> ".text" then - fprintf oc " .sectionlink .debug_info\n" + fprintf oc " .sectionlink .debug_info\n" | _ -> fprintf oc " %s\n" name @@ -263,6 +268,7 @@ module Diab_System : SYSTEM = Debug.add_diab_info name (line_start,debug_info,name_of_section sec); Debug.add_compilation_section_start name low_pc; let line_name = ".debug_line" ^(if name <> ".text" then name else "") in + section oc (Section_debug_line (if name <> ".text" then Some name else None)); fprintf oc " .section %s,,n\n" line_name; if name <> ".text" then fprintf oc " .sectionlink .debug_line\n"; -- cgit