From: Dodji Seketeli Date: Sat, 24 Dec 2022 14:29:15 +0000 (+0100) Subject: dwarf-reader: Bug 29932 - Handle function DIE as type as needed X-Git-Tag: upstream/2.3~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de45f1e69b96a1f7511c94837e1793136b384407;p=platform%2Fupstream%2Flibabigail.git dwarf-reader: Bug 29932 - Handle function DIE as type as needed When building the IR for a function type, the DWARF reader considers the function DIE we are looking at as a type DIE. In dwarf::reader::lookup_fn_type_from_die_repr_per_tu, the call to get_die_pretty_representation doesn't enforce the fact that the DIE we are looking at must be considered as a type. This is usually not a problem because even if get_die_pretty_representation considers the function DIE as a decl, the representation of a function and a function type are almost the same. In this particular case, we run into a function DIE that has an empty name: [ 51e54] subprogram abbrev: 18 external (flag_present) yes name (strp) "" decl_file (data1) catgets.c (1) decl_line (data1) 89 prototyped (flag_present) yes type (ref4) [ 51ac5] low_pc (addr) +0x0000000000034cc0 high_pc (data8) 133 (+0x0000000000034d45) frame_base (exprloc) [ 0] call_frame_cfa GNU_all_call_sites (flag_present) yes sibling (ref4) [ 51edb] Note that this is from the /lib64/libc-2.17.so from the https://vault.centos.org/7.6.1810/os/x86_64/Packages/glibc-2.17-260.el7.x86_64.rpm package, associated with the debuginfo package at http://debuginfo.centos.org/7/x86_64/glibc-debuginfo-2.17-260.el7.x86_64.rpm. In that case, get_die_pretty_representation returns an empty string because it doesn't expects a function decl with an empty name. If we make dwarf::reader::lookup_fn_type_from_die_repr_per_tu explicitly be in the context of a type by invoking get_die_pretty_type_representation instead, the problem disapears as the latter function treats the DIE as a function type DIE, so it doesn't need its name. Thus, this patch makes dwarf::reader::lookup_fn_type_from_die_repr_per_tu invoke get_die_pretty_type_representation instead. * src/abg-dwarf-reader.cc (reader::lookup_fn_type_from_die_repr_per_tu): Invoke get_die_pretty_type_representation instead of get_die_pretty_representation when looking at a function DIE without a name. Signed-off-by: Dodji Seketeli --- diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 5df1516d..668f970d 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -3509,8 +3509,9 @@ public: if (!die_is_function_type(die)) return function_type_sptr(); - interned_string repr = - get_die_pretty_representation(die, /*where=*/0); + interned_string repr = die_name(die).empty() ? + get_die_pretty_type_representation(die, /*where=*/0) + : get_die_pretty_representation(die, /*where=*/0); ABG_ASSERT(!repr.empty()); istring_fn_type_map_type::const_iterator i =