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

PATCH: dwarf2_finish() too eager to create a .debug_line section

Hi Guys,

  I ran across a small problem with dwarf2_finish() today.  It will
  create a .debug_line section even when there is no .debug_info
  section to accompany it.  This causes problems for tools like
  readelf and GDB because they expect there to be a .debug_info block
  to accompany every .debug_line block.  The Dwarf2 Standard says:

     As mentioned in section 3.1, above, the line number
     information generated for a compilation unit is
     represented in the .debug_line section of an object
     file and is referenced by a corresponding compilation
     unit debugging information entry in the .debug_info

  The patch below partially fixes this problem by fixing the test at
  the start of dwarf2_finish().  The comment there says:

    "or, there is a user-provided .debug_info section which
     could reference the file table in the .debug_line
     section we generate below."

  But currently the code always assumes that a file table will be
  produced.  The patch adds a check to see if the there were any .file
  directives recorded and hence that a file table will be created.

  I am not sure if this patch is sufficient to fix all possible cases
  however.  For example if the assembler source code has a .debug_line
  section but no .debug_info section should this be remarked upon via
  a warning message, or should the assembler create one ?

2004-11-02  Nick Clifton  <>

	* dwarf2dbg.c (dwarf2_finish): Check for the existence of a file
	table before deciding to produce a .debug_line section to match up
	with a user provided .debug_info section.

Index: gas/dwarf2dbg.c
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.70
diff -c -3 -p -r1.70 dwarf2dbg.c
*** gas/dwarf2dbg.c	29 Apr 2004 16:40:18 -0000	1.70
--- gas/dwarf2dbg.c	2 Nov 2004 08:58:15 -0000
*************** dwarf2_finish (void)
*** 1363,1369 ****
         below.  */
    if (all_segs == NULL
        && debug_type != DEBUG_DWARF2
!       && bfd_get_section_by_name (stdoutput, ".debug_info") == NULL)
    /* Calculate the size of an address for the target machine.  */
--- 1363,1370 ----
         below.  */
    if (all_segs == NULL
        && debug_type != DEBUG_DWARF2
!       && (bfd_get_section_by_name (stdoutput, ".debug_info") == NULL
! 	  || files_in_use == 0))
    /* Calculate the size of an address for the target machine.  */

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