[Dwarf-Discuss] DWARF5 line table file numbering inconsistent
mark at klomp.org
Thu Oct 15 11:59:54 PDT 2020
On Thu, Oct 15, 2020 at 05:55:32PM +0000, Robinson, Paul wrote:
> > Both DWARF v4 and v5 say "The value 0 indicates that no source file
> > has been specified." I assumed that was deliberate, but maybe it was
> > an oversight. But given that both versions say the same I would avoid
> > using zero to mean something different.
> I'm sure it was deliberate to say that in DWARF v2, but I'm not sure
> it was deliberate to leave the language in place in DWARF v5.
> The intent was certainly for file 0 to mean the root source file, and
> make it explicit in the line table; I don't recall any discussion
> either way about DIE attributes but as they use the line table's
> definitions, it's hard to imagine we wouldn't have wanted DW_AT_decl_file
> = 0 to mean the root source file. Because, of course, if we *don't* do
> that, then the root source file has to occupy two entries in the file
> table, which is wasteful.
I totally agree that it is a bit wasteful. You do indeed often end up
with identical file entry zero and file entry one. But at least you
can now share the name in the .debug_line_str table. And since the
line table file register defaults to one, you can then at least
immediately use it (otherwise you'll have to add an extra
DW_LNS_set_file 0). So it isn't ideal, but I don't believe it is
inconsistent. But I might have missed something. It is certainly
slightly confusing. So it would be good to see David's overview.
More information about the Dwarf-Discuss