From e1db5cdc9f230f8de4df1a0f38dca69b283ee57a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 8 May 2020 12:33:11 +0200 Subject: libdw: Use correct CU to resolve file names in dwarf_decl_file. dwarf_decl_file uses dwarf_attr_integrate to get the DW_AT_decl_file attribute. This means the attribute might come from a different DIE in a different CU. If so, we need to use the CU associated with the attribute, not the original DIE, to resolve the file name. Also add a bit more documentation to dwarf_attr_integrate explaining that the attribute returned might come from a different CU (and even different Dwarf). Signed-off-by: Mark Wielaard --- libdw/dwarf_ranges.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libdw/dwarf_ranges.c') diff --git a/libdw/dwarf_ranges.c b/libdw/dwarf_ranges.c index f67d8a5a..520f9ffe 100644 --- a/libdw/dwarf_ranges.c +++ b/libdw/dwarf_ranges.c @@ -506,6 +506,11 @@ dwarf_ranges (Dwarf_Die *die, ptrdiff_t offset, Dwarf_Addr *basep, Dwarf_Attribute attr_mem; Dwarf_Attribute *attr = INTUSE(dwarf_attr) (die, DW_AT_ranges, &attr_mem); + /* Note that above we use dwarf_attr, not dwarf_attr_integrate. + The only case where the ranges can come from another DIE + attribute are the split CU case. In that case we also have a + different CU to check against. But that is already set up + above using __libdw_find_split_unit. */ if (attr == NULL && is_cudie (die) && die->cu->unit_type == DW_UT_split_compile) -- cgit v1.2.3