This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils 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]

Re: Some dwarf "nitpicks"


On Wed, 2011-03-09 at 10:34 -0800, Roland McGrath wrote:
> > Ah, yes. That is what I thought first too. But gcc is sneaky :)
> > If gcc detects gas has support for the .loc directive, it will not
> > output the section itself, but let gas generate it (because the
> > assembler has exact info on instruction sizes).
> 
> Sure, but there is no .loc in there!  In fact, it's gas that is quite
> sneaky here.
> 
>     /* If there is no line information and no non-empty .debug_info
>        section, or if there is both a non-empty .debug_info and a non-empty
>        .debug_line, then we do nothing.  */
> 
> So its the presence of some .section .debug_info content (even without any
> .file, let alone .loc) that makes it emit the .debug_line header.
> 
> If there is a bug here, it's a gas bug.

Indeed. So you can "trick" gas into creating a needless .debug_line
section by just doing:

$ echo ".section .debug_info" > empty.s; echo ".byte 0x0" >> empty.s
$ as -g empty.s 
$ eu-readelf -w a.out 

DWARF section [ 4] '.debug_info' at offset 0x40:
 [Offset]

DWARF section [ 5] '.debug_line' at offset 0x41:

Table at offset 0:

 Length:                     25
 DWARF version:              2
 Prologue length:            19
 Minimum instruction length: 1
 Maximum operations per instruction: 1
 Initial value if 'is_stmt': 1
 Line base:                  -5
 Line range:                 14
 Opcode base:                13

Opcodes:
  [ 1]  0 arguments
  [ 2]  1 argument
  [ 3]  1 argument
  [ 4]  1 argument
  [ 5]  1 argument
  [ 6]  0 arguments
  [ 7]  0 arguments
  [ 8]  0 arguments
  [ 9]  1 argument
  [10]  0 arguments
  [11]  0 arguments
  [12]  1 argument

Directory table:

File name table:
 Entry Dir   Time      Size      Name

Line number statements:


That of course is an invalid .debug_info section, but there really is no
reason for gas to output the .debug_line section since there was no
explicit .debug_line sections, nor where there any .loc or .line
directives.

Current dwarflint does error on the above, but doesn't mention that
nothing refers to the "empty" .debug_line sections:
$ eu-dwarflint a.out 
error: .debug_abbrev: data not found.

So, the bug is in gas. I cannot immediately think of how to trick gcc
itself into producing this bug. But if this gas bug is fixed we might
need to fix gcc to not unconditionally produce a DW_AT_line_stmt_list
for the CU.

Cheers,

Mark


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