]> git.ipfire.org Git - thirdparty/elfutils.git/commit
Handle DW_AT_decl_file 0
authorAaron Merey <amerey@redhat.com>
Sat, 10 Feb 2024 02:10:19 +0000 (21:10 -0500)
committerAaron Merey <amerey@redhat.com>
Tue, 13 Feb 2024 01:36:55 +0000 (20:36 -0500)
commitadd63e0317b6e27dd4077b19e998e6c56a3becb5
tree0f869c6f256af9b6a43bee35b237a8e23fc4c602
parent0e2e5dd39e46412d390d8ecca5594f59659e74ce
Handle DW_AT_decl_file 0

Modify dwarf_decl_file to support DW_AT_decl_file with value 0.

Because of inconsistencies in the DWARF 5 spec, it is ambiguous whether
DW_AT_decl_file value 0 is a valid .debug_line file table index for the
main source file or if it means that there is no source file specified.

dwarf_decl_file interprets DW_AT_decl_file 0 as meaning no source file
is specified.  This works with DWARF 5 produced by gcc, which duplicates
the main source file name at index 0 and 1 of the file table and avoids
using DW_AT_decl_file 0.

However clang uses DW_AT_decl_file 0 for the main source index with no
duplication at another index.  In this case dwarf_decl_file will be
unable to find the file name of the main file.

This patch changes dwarf_decl_file to treat DW_AT_decl_file 0 as a normal
index into the file table, allowing it to work with DWARF 5 debuginfo
produced by clang.

As for earlier DWARF versions which exclusively use DW_AT_decl_file 0
to indicate that no source file is specified, dwarf_decl_file will now
return the name "???" if called on a DIE with DW_AT_decl_file 0.

https://sourceware.org/bugzilla/show_bug.cgi?id=31111

Signed-off-by: Aaron Merey <amerey@redhat.com>
libdw/dwarf_decl_file.c
tests/Makefile.am
tests/run-allfcts.sh
tests/testfile-dwarf5-line-clang.bz2 [new file with mode: 0755]