libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges
When commit
879f3a4f99df ("libdw: Handle .debug_rnglists in
dwarf_ranges.") added support for split DWARF 5 in 2018, GCC put all
range lists for split DWARF in the .debug_rnglists section of the
skeleton file (similarly to GNU DebugFission, which puts all range lists
in .debug_ranges in the skeleton file).
In 2021, after a discussion on the dwarf-discuss mailing list [1], GCC
changed this to match Clang's behavior. Now, ranges are in
.debug_rnglists.dwo in the split file, _except_ for one: the skeleton
unit DIE has a DW_AT_ranges attribute, and its ranges are in
.debug_rnglists in the skeleton file. See GCC commit
4b33c5aaab9e
("dwarf2out: Fix up ranges for -gdwarf-5 -gsplit-dwarf [PR99490]") and
the Issue 210310.1 clarifying the DWARF standard [2].
Unfortunately, this confuses dwarf_ranges, which always uses
.debug_rnglists.dwo if it exists. Fix it by special casing the unit
DIE: its range lists should be in .debug_rnglists if that exists, and
.debug_rnglists.dwo otherwise.
1: https://lists.dwarfstd.org/pipermail/dwarf-discuss/2021-March/002009.html
2: https://dwarfstd.org/issues/210310.1.html
Signed-off-by: Omar Sandoval <osandov@fb.com>