From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by sourceware.org (Postfix) with ESMTPS id 03DED3858D32 for ; Mon, 26 Dec 2022 12:57:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 03DED3858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=seketeli.org Received: (Authenticated sender: dodji@seketeli.org) by mail.gandi.net (Postfix) with ESMTPSA id C31B0C0008 for ; Mon, 26 Dec 2022 12:57:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seketeli.org; s=gm1; t=1672059477; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=HB+7x38k99frkg3wbc8uSDImEeWsxWuNjak4b92Sg/c=; b=TQKSFjFl4jquo55ifUI2q+rGYU6Y9Fs9pijz6p8UxueaLjWv9oxM/PxhDpIwuBo8JuE/Kx /g3xhu3pdNLeIfA/Hc51oo51GdvpJ+stHYXs7pDveBVbWAadWQKohHG1l0uafzIRGcGIdK RMDWpTOUmsBzjQCnkxjwLdQVuSdWvdAZ+I18fszxolfNAvXPz1jpEWqD9AOgGyssF5pgXY 8acgeWF0txRDXgdIw9Sw9ehbQDEA3kANagb4qzJvmtLW5bc8nfQEPDXhRom7MV3xMqrWR7 /2Wvgjv2+hcASLl4cV7XitT3QRb27h+5FBMimmSioYq+Ag1034EJRoIXX2FL+w== Received: by localhost (Postfix, from userid 1000) id F2A3BA2E7E; Mon, 26 Dec 2022 13:57:56 +0100 (CET) From: Dodji Seketeli To: libabigail@sourceware.org Subject: [PATCH, applied] dwarf-reader: Bug 29932 - Handle function DIE as type as needed Organization: Me, myself and I X-Operating-System: CentOS Stream release 9 X-URL: http://www.seketeli.net/~dodji Date: Mon, 26 Dec 2022 13:57:56 +0100 Message-ID: <87wn6eb9uz.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello, 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 --- src/abg-dwarf-reader.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 = -- 2.31.1 -- Dodji