public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@seketeli.org>
To: libabigail@sourceware.org
Subject: [PATCH, applied] dwarf-reader: Bug 29932 - Handle function DIE as type as needed
Date: Mon, 26 Dec 2022 13:57:56 +0100	[thread overview]
Message-ID: <87wn6eb9uz.fsf@seketeli.org> (raw)

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 <dodji@redhat.com>
---
 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

                 reply	other threads:[~2022-12-26 12:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wn6eb9uz.fsf@seketeli.org \
    --to=dodji@seketeli.org \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).