From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH] dwarf-reader: Use DW_FORM_line_strp only if it's present
Date: Mon, 08 Feb 2021 13:58:33 +0100 [thread overview]
Message-ID: <86lfbyhg1y.fsf@redhat.com> (raw)
* configure.ac: Define if HAS_DW_FORM_line_strp if the
DW_FORM_line_strp enumerator is present.
* src/abg-dwarf-reader.cc (form_is_DW_FORM_line_strp): Define new
static function.
(compare_dies_string_attribute_value): Use it.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
configure.ac | 12 ++++++++++++
src/abg-dwarf-reader.cc | 33 +++++++++++++++++++++++++++++----
2 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 37b7882..b9f59c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -844,6 +844,7 @@ HAS_DW_FORM_strx1=no
HAS_DW_FORM_strx2=no
HAS_DW_FORM_strx3=no
HAS_DW_FORM_strx4=no
+HAS_DW_FORM_line_strp=no
AC_CHECK_DECL([DW_FORM_strx1],
[HAS_DW_FORM_strx1=yes],
@@ -889,6 +890,17 @@ if test x$HAS_DW_FORM_strx4 = xyes; then
[Define to 1 if dwarf.h has the DW_FORM_strx4 enumerator])
fi
+AC_CHECK_DECL([DW_FORM_line_strp],
+ [HAS_DW_FORM_line_strp=yes],
+ [HAS_DW_FORM_line_strp=no],
+ [[#include <dwarf.h>]])
+
+if test x$HAS_DW_FORM_line_strp = xyes; then
+ AC_DEFINE([HAVE_DW_FORM_line_strp],
+ 1,
+ [Define to 1 if dwarf.h has the DW_FORM_line_strp enumerator])
+fi
+
if test x$HAS_DW_FORM_strx1 = xyes -a \
x$HAS_DW_FORM_strx2 = xyes -a \
x$HAS_DW_FORM_strx3 = xyes -a \
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 13c8182..810da2f 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -390,6 +390,9 @@ static bool
form_is_DW_FORM_strx(unsigned form);
static bool
+form_is_DW_FORM_line_strp(unsigned form);
+
+static bool
die_address_attribute(Dwarf_Die* die, unsigned attr_name, Dwarf_Addr& result);
static string
@@ -8310,6 +8313,28 @@ form_is_DW_FORM_strx(unsigned form)
return false;
}
+/// Test if a given DWARF form is DW_FORM_line_strp.
+///
+/// Unfortunaly, the DW_FORM_line_strp is an enumerator of an untagged
+/// enum in dwarf.h so we have to use an unsigned int for the form,
+/// grrr.
+///
+/// @param form the form to consider.
+///
+/// @return true iff @p form is DW_FORM_line_strp.
+static bool
+form_is_DW_FORM_line_strp(unsigned form)
+{
+ if (form)
+ {
+#if defined HAVE_DW_FORM_line_strp
+ if (form == DW_FORM_line_strp)
+ return true;
+#endif
+ }
+ return false;
+}
+
/// Get the value of a DIE attribute; that value is meant to be a
/// flag.
///
@@ -9415,13 +9440,13 @@ compare_dies_string_attribute_value(const Dwarf_Die *l, const Dwarf_Die *r,
|| l_attr.form == DW_FORM_string
|| l_attr.form == DW_FORM_GNU_strp_alt
|| form_is_DW_FORM_strx(l_attr.form)
- || l_attr.form == DW_FORM_line_strp);
+ || form_is_DW_FORM_line_strp(l_attr.form));
ABG_ASSERT(r_attr.form == DW_FORM_strp
|| r_attr.form == DW_FORM_string
|| r_attr.form == DW_FORM_GNU_strp_alt
|| form_is_DW_FORM_strx(r_attr.form)
- || l_attr.form == DW_FORM_line_strp);
+ || form_is_DW_FORM_line_strp(l_attr.form));
if ((l_attr.form == DW_FORM_strp
&& r_attr.form == DW_FORM_strp)
@@ -9429,8 +9454,8 @@ compare_dies_string_attribute_value(const Dwarf_Die *l, const Dwarf_Die *r,
&& r_attr.form == DW_FORM_GNU_strp_alt)
|| (form_is_DW_FORM_strx(l_attr.form)
&& form_is_DW_FORM_strx(r_attr.form))
- || (l_attr.form == DW_FORM_line_strp
- && r_attr.form == DW_FORM_line_strp))
+ || (form_is_DW_FORM_line_strp(l_attr.form)
+ && form_is_DW_FORM_line_strp(r_attr.form)))
{
// So these string attributes are actually pointers into a
// string table. The string table is most likely de-duplicated
--
1.8.3.1
--
Dodji
reply other threads:[~2021-02-08 12:58 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=86lfbyhg1y.fsf@redhat.com \
--to=dodji@redhat.com \
--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).