[Dwarf-Discuss] DWARF v5 and "file 0"

paul.robinson@sony.com paul.robinson
Thu Jul 8 19:23:14 GMT 2021


Tom Russell asked me about this, and I think it's a bug in the
v5 specification.

In v5, the line-table header's directory table added an entry for
directory 0.  Previous versions had directory 0 mean the current
compilation directory, i.e. DW_AT_comp_dir from the compile unit DIE.

The file table also added an entry for file 0, claiming that it
similarly used to mean the primary compilation file.  I can't find
any evidence that was actually true, though; the default value for
the line-number program's "file" register was (and still is) 1, not
0, and in fact section 2.14 says that DW_AT_decl_file = 0 means
there is no source file (analogous to line 0 meaning no specific
source line).

If DW_AT_decl_file = 0 means "no source file" then the file table
pretty much has to have two entries for the primary source file, 
entry 0 to satisfy the line-table specification and another non-zero
entry to satisfy the DW_AT_decl_file requirements.  That's wasteful.

Am I missing something?  Happy to be wrong here, but it helps
explain why it has been such a bear to get file 0 working properly
in LLVM.

If I'm not wrong I will file an issue to get this fixed in DWARF v6.
Thanks,
--paulr




More information about the Dwarf-discuss mailing list