]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libdw: Handle split DWARF in dwarf_macro_getsrcfiles
authorOmar Sandoval <osandov@fb.com>
Wed, 27 Sep 2023 18:20:55 +0000 (11:20 -0700)
committerMark Wielaard <mark@klomp.org>
Tue, 3 Oct 2023 21:36:05 +0000 (23:36 +0200)
commitefedcaa3415cf1305bb4d20a42aae3b60d341122
treec1c7682e3643d4443380d62825dae7118f2231d3
parent4bddabc1e7f3020b83a5abd98901146c58da403e
libdw: Handle split DWARF in dwarf_macro_getsrcfiles

Macro information references file names from the line number information
table, which is tricky in split DWARF for a couple of reasons.

First, the line number information for a macro unit comes from the
.debug_line.dwo section in the split file, not the .debug_line section
in the skeleton file.  This was not specified in the GNU DebugFission
design document [1] or the DWARF 5 standard, but it is how GCC and Clang
behave in practice and was clarified in DWARF standard issue
200602.1 [2] for the upcoming DWARF 6 standard.

dwarf_macro_getsrcfiles uses the line number information from whichever
Dwarf handle it was passed.  This is error-prone, since the most natural
thing to do is to pass the skeleton Dwarf handle.  Fix this by storing
the appropriate Dwarf handle in Dwarf_Macro_Op_Table and using that one.

Second, for .debug_macinfo.dwo in GNU DebugFission (generated by gcc
-gdwarf-4 -gstrict-dwarf -gsplit-dwarf), the offset into .debug_line.dwo
is implicitly 0.  Again, this isn't in any specification, but it's how
GCC behaves in practice (Clang never generates macro information for
DWARF 4 split DWARF).  Make get_macinfo_table default to 0 for split
DWARF when it can't find DW_AT_stmt_list.

1: https://gcc.gnu.org/wiki/DebugFission
2: https://dwarfstd.org/issues/200602.1.html

Signed-off-by: Omar Sandoval <osandov@fb.com>
libdw/ChangeLog
libdw/dwarf_getmacros.c
libdw/dwarf_macro_getsrcfiles.c
libdw/libdwP.h