This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: dwarf2 debug dependent upon GAS?


>  > What would be the best way to handle this?  Something like letting
>  > ASM_OUTPUT_SECTION_NAME watch for the first time any of the 'debug_'
>  > sections are emitted and then letting it emit a symbol of the same name?
> 
> Nah, just spit out the useful ones in dwarf2out_init.
> 
>  > The random symbol could be the section name, right?
> 
> I'd suggest a variant on the section name so we can use that solution for
> all targets.

This turned ugly.  In the process it became a spokesperson for use of
ANSI string pasting, but I know that's a no-no for us.

It does allow an empty C file to assemble and link on SVR5 when using
-gdwarf-2.  Still, it "feels" wrong.  Before I continue down this path,
can you please tell me if I should perhaps go a different way?

Thanx,
RJL




Index: dwarf2out.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/dwarf2out.c,v
retrieving revision 1.85
diff -u -p -r1.85 dwarf2out.c
--- dwarf2out.c	1999/02/24 17:48:42	1.85
+++ dwarf2out.c	1999/02/26 04:50:54
@@ -2613,6 +2613,7 @@ static unsigned lookup_filename		PROTO((
 #define STR_SECTION		".debug_str"
 #endif
 
+
 /* Standard ELF section names for compiled code and data.  */
 #ifndef TEXT_SECTION
 #define TEXT_SECTION		".text"
@@ -2624,6 +2625,16 @@ static unsigned lookup_filename		PROTO((
 #define BSS_SECTION		".bss"
 #endif
 
+dyn_string_t abbrev_section_base;
+dyn_string_t debug_line_section_base;
+dyn_string_t debug_info_section_base;
+dyn_string_t text_section_base;
+
+#define ABBREV_SECTION_BASE	ABBREV_SECTION "_base"
+#define DEBUG_LINE_SECTION_BASE	DEBUG_LINE_SECTION "_base"
+#define DEBUG_INFO_SECTION_BASE	DEBUG_INFO_SECTION "_base"
+#define TEXT_SECTION_BASE	TEXT_SECTION "_base"
+
 
 /* Definitions of defaults for formats and names of various special
    (artificial) labels which may be generated within this file (when the -g
@@ -5423,7 +5434,7 @@ output_compilation_unit_header ()
     fprintf (asm_out_file, "\t%s DWARF version number", ASM_COMMENT_START);
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, stripattributes (ABBREV_SECTION));
+  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, stripattributes (abbrev_section_base->s));
   if (flag_debug_asm)
     fprintf (asm_out_file, "\t%s Offset Into Abbrev. Section",
 	     ASM_COMMENT_START);
@@ -5496,7 +5507,7 @@ output_pubnames ()
     fprintf (asm_out_file, "\t%s DWARF Version", ASM_COMMENT_START);
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, stripattributes (DEBUG_INFO_SECTION));
+  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, stripattributes (debug_info_section_base->s));
   if (flag_debug_asm)
     fprintf (asm_out_file, "\t%s Offset of Compilation Unit Info.",
 	     ASM_COMMENT_START);
@@ -5577,7 +5588,7 @@ output_aranges ()
     fprintf (asm_out_file, "\t%s DWARF Version", ASM_COMMENT_START);
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, stripattributes (DEBUG_INFO_SECTION));
+  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, stripattributes (debug_info_section_base->s));
   if (flag_debug_asm)
     fprintf (asm_out_file, "\t%s Offset of Compilation Unit Info.",
 	     ASM_COMMENT_START);
@@ -5603,13 +5614,13 @@ output_aranges ()
 	     ASM_COMMENT_START, 2 * PTR_SIZE);
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_ADDR (asm_out_file, stripattributes (TEXT_SECTION));
+  ASM_OUTPUT_DWARF_ADDR (asm_out_file, stripattributes (text_section_base->s));
   if (flag_debug_asm)
     fprintf (asm_out_file, "\t%s Address", ASM_COMMENT_START);
 
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file, text_end_label,
-			       stripattributes (TEXT_SECTION));
+			       stripattributes (text_section_base->s));
   if (flag_debug_asm)
     fprintf (asm_out_file, "%s Length", ASM_COMMENT_START);
 
@@ -5794,7 +5805,7 @@ output_line_info ()
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_ADDR (asm_out_file, stripattributes (TEXT_SECTION));
+  ASM_OUTPUT_DWARF_ADDR (asm_out_file, stripattributes (text_section_base->s));
   fputc ('\n', asm_out_file);
 
   /* Generate the line number to PC correspondence table, encoded as
@@ -9851,6 +9862,29 @@ dwarf2out_init (asm_out_file, main_input
   gen_compile_unit_die (main_input_filename);
 
   ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);
+
+  abbrev_section_base = dyn_string_new (32);
+  text_section_base = dyn_string_new (32);
+  debug_info_section_base = dyn_string_new (32);
+  debug_line_section_base = dyn_string_new (32);
+
+  dyn_string_append(abbrev_section_base, ABBREV_SECTION);
+  dyn_string_append(abbrev_section_base, "_base");
+  dyn_string_append(text_section_base, TEXT_SECTION);
+  dyn_string_append(text_section_base, "_base");
+  dyn_string_append(debug_info_section_base, DEBUG_INFO_SECTION);
+  dyn_string_append(debug_info_section_base, "_base");
+  dyn_string_append(debug_line_section_base, DEBUG_LINE_SECTION);
+  dyn_string_append(debug_line_section_base, "_base");
+
+  ASM_OUTPUT_SECTION (asm_out_file, ABBREV_SECTION);
+  ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_base->s);
+  ASM_OUTPUT_SECTION (asm_out_file, TEXT_SECTION);
+  ASM_OUTPUT_LABEL (asm_out_file, text_section_base->s);
+  ASM_OUTPUT_SECTION (asm_out_file, DEBUG_INFO_SECTION);
+  ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_base->s);
+  ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION);
+  ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_base->s);
 }
 
 /* Output stuff that dwarf requires at the end of every file,
@@ -9911,7 +9945,7 @@ dwarf2out_finish ()
   if (line_info_table_in_use > 1 || separate_line_info_table_in_use)
     {
       fputc ('\n', asm_out_file);
-      ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION);
+      ASM_OUTPUT_SECTION (asm_out_file, debug_line_section_base->s);
       output_line_info ();
 
       /* We can only use the low/high_pc attributes if all of the code
@@ -9919,11 +9953,11 @@ dwarf2out_finish ()
       if (separate_line_info_table_in_use == 0)
 	{
 	  add_AT_lbl_id (comp_unit_die, DW_AT_low_pc,
-			 stripattributes (TEXT_SECTION));
+			 stripattributes (text_section_base->s));
 	  add_AT_lbl_id (comp_unit_die, DW_AT_high_pc, text_end_label);
 	}
 
-      add_AT_section_offset (comp_unit_die, DW_AT_stmt_list, DEBUG_LINE_SECTION);
+      add_AT_section_offset (comp_unit_die, DW_AT_stmt_list, debug_line_section_base->s);
     }
 
   /* Output the abbreviation table.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]