This is the mail archive of the gcc-patches@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]

PATCH: Fix DWARF2 section lossage



This patch fixes PR1964, a regression from GCC 2.95.x.  The problem
comes from the fact that the x86 back-end now emits PIC stubs at the
end of the file.  At this point, the DWARF2 code has changed the
current section around, but hasn't told varasm.c about what it's done.
As a result, when the x86 back-end calls text_section, varasm.c thinks
that we are already in the text section, and does nothing.  Then, we
end up emitting the PIC stub into the middle of the .debug_aranges
section.

The patch fixes the problem by forcibly synchronizing varasm.c's
notion of the current section with reality.

The real problem, however, is that dwarf2out.c is doing things behind
the back of the rest of the compiler.  In particular, dwaf2out.c uses
ASM_OUTPUT_SECTION throughout -- a macro that can be overridden by the
target machine, but which is not documented in the TeXinfo
documentation.  Using this macro doesn't updated in_section in
varasm.c.

Instead, the dwaf2out.c code should be using named_section; the
routine that is supposed to switch among sections.  However, just
making that change doesn't work on i686-pc-linux-gnu; the definition
of ASM_OUTPUT_SECTION_NAME (which *is* documented) used there does:

  .section debug_aranges,"aw",@progbits

and the linker then proceeds to issue error messages.  Presumably
ASM_OUTPUT_SECTION_NAME needs some tweaking to handle the .debug_*
sections appropriately.

The attached patch should do the trick on the branch, but the mainline
should get a better fix, via the use of named_section.  Or someone
should tell me I misapprehend the situation. :-)

Jason, would you care to take a whack at this, since you're an expert
on this code?

Tested on i686-pc-linux-gnu, committed on the branch.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2001-04-24  Mark Mitchell  <mark@codesourcery.com>

	* dwarf2out.c (dwarf2out_finish): Forcibly return to the data
	section after emitting information.

Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.242.2.7
diff -c -p -r1.242.2.7 dwarf2out.c
*** dwarf2out.c	2001/04/23 16:37:15	1.242.2.7
--- dwarf2out.c	2001/04/25 01:39:28
*************** dwarf2out_finish ()
*** 11922,11926 ****
--- 11922,11940 ----
        ASM_OUTPUT_SECTION (asm_out_file, ARANGES_SECTION);
        output_aranges ();
      }
+ 
+   /* At this point, we've switched sections like mad, but we've done
+      so behind the back of varasm.c.  Unfortunately, used
+      named_section to switch sections doesn't work either; GAS 2.9.5
+      is not pleased by:
+ 
+        .section debug_aranges,"a",@progbits
+ 
+      on i686-pc-linux-gnu.  
+ 
+      By calling force_data_section, we get varasm.c synched back up
+      with reality.  That makes subsequent calls to text_section and
+      such make sense.  */
+   force_data_section ();
  }
  #endif /* DWARF2_DEBUGGING_INFO */


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