This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Assember generating .debug_line table


There was a previous discussion about this a few months ago:
http://sourceware.org/ml/binutils/2007-06/msg00341.html

If you have a target which does linker-time relaxation,
and the assembler generate the line table entries, then the
.debug_line entries can be incorrect.  This is because gas
generates line address increment operations, rather than
relocatable references to the code for each line.  If the
linker shrinks the code, the computed addresses will be wrong.

If you have gcc generate the line table
(#define DWARF2_ASM_LINE_DEBUG_INFO 0) it will generate
relocatable references for each line, which will be fixed
during relaxation.  Unfortunately, gas generates an empty
line table as well, which leads to error messages from readelf.

There are several possible fixes:  make ld's relaxation phase
interpret .debug_line data and fix up the offsets; have an
option for gas to only generate relocatable line references;
or have gas not generate empty line tables.

The code in dwarf2_finish generates a .debug_line entry
whenever there is a .debug_info section, whether it has
seen any .loc pseudo ops or not.  This seems incorrect.

The fix is simple:

diff -urNp --exclude '*.swp' binutils-orig/gas/dwarf2dbg.c binutils/gas/dwarf2db
g.c
--- binutils-orig/gas/dwarf2dbg.c       2007-10-10 18:04:41.000000000 -0700
+++ binutils/gas/dwarf2dbg.c    2007-10-11 09:59:36.000000000 -0700
@@ -1369,9 +1369,8 @@ dwarf2_finish (void)
   info_seg = bfd_get_section_by_name (stdoutput, ".debug_info");
   emit_other_sections = info_seg == NULL || !seg_not_empty_p (info_seg);

-  if (!all_segs && emit_other_sections)
-    /* There is no line information and no non-empty .debug_info
-       section.  */
+  if (!all_segs)
+    /* There is no line information. */
     return;

/* Calculate the size of an address for the target machine. */


-- Michael Eager eager@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077


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