[PATCH] inconsistent DWARF2 sections generated by --gdwarf2
Bob Wilson
bwilson@tensilica.com
Mon Nov 15 19:27:00 GMT 2004
The code for dwarf2_finish() in gas/dwarf2dbg.c appears to be inconsistent. If
you assemble a file that contains no instructions, e.g., just a symbol
declaration: ".global some_symbol", with --gdwarf2, GAS will create a
.debug_line section but no corresponding .debug_info section. This is probably
harmless for GDB, but it breaks readelf, which expects a one-to-one
correspondence between .debug_info and .debug_line sections. Running "readelf
-wl" on such a file results in the following error message:
readelf: Error: Not enough comp units for .debug_lines section
It looks like the problem was introduced by the following change:
2002-08-01 H.J. Lu <hjl@gnu.org>
Daniel Jacobowitz <drow@mvista.com>
* dwarf2dbg.c (dwarf2_finish): Don't emit unreferenced
.debug_line section unless it has line information.
I read through the discussions surrounding that patch to try to understand the
issues involved, but I'm not sure if I succeeded. I _think_ this patch is
correct -- assuming the .debug_info section is needed, it must either be
provided in the input or generated later in dwarf2_finish. In the latter case,
the test to "do nothing" should be consistent with the test to generate
.debug_info, etc. An alternative would be changing GAS to write out a
.debug_info section even when no line numbers are specified, but the following
comment in out_debug_info() suggests that might not work: "We're not supposed to
get called unless at least one line number entry was emitted...."
I'll be happy to commit this if someone will confirm that it is the right thing
to do and approve the patch. It doesn't cause any gas testsuite regressions for
an xtensa-elf target.
--Bob
gas ChangeLog
2004-11-15 Bob Wilson <bob.wilson@acm.org>
* dwarf2dbg.c (dwarf2_finish): Don't write a .debug_line section
without a corresponding .debug_info section.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dwarf2dbg.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20041115/d576b489/attachment.ksh>
More information about the Binutils
mailing list