* [PATCH] dwarf-reader: Use DW_FORM_line_strp only if it's present
@ 2021-02-08 12:58 Dodji Seketeli
0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2021-02-08 12:58 UTC (permalink / raw)
To: libabigail
* 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-02-08 12:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 12:58 [PATCH] dwarf-reader: Use DW_FORM_line_strp only if it's present Dodji Seketeli
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).