This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] libdw: Add support for DWARF5 DW_FORM_data16.


The DWARF5 spec says DW_FORM_data16 is constant class (128bit value).
But we treat it as if it is block class. So to use a attribute that is
encoded as DW_FORM_data16 use dwarf_formblock, not dwarf_form[us]data.

We cannot use dwarf_form[us]data since they return a Dwarf_Word/Sword,
which are only 64bits.

This does mean we don't try to convert the value but just return it as
a block of 16 raw bytes.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdw/ChangeLog         |  5 +++++
 libdw/dwarf_formblock.c | 12 +++++++++++-
 src/ChangeLog           |  4 ++++
 src/readelf.c           |  3 ++-
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index f52ce58..3841d56 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,10 @@
 2018-02-09  Mark Wielaard  <mark@klomp.org>
 
+	* dwarf_formblock.c (dwarf_formblock): Handle DW_FORM_data16 as a
+	16 byte block.
+
+2018-02-09  Mark Wielaard  <mark@klomp.org>
+
 	* dwarf_child.c (__libdw_find_attr): Handle DW_FORM_implicit_const.
 	* dwarf_formsdata.c (dwarf_formsdata): Likewise.
 	* dwarf_formudata.c (dwarf_formudata): Likewise.
diff --git a/libdw/dwarf_formblock.c b/libdw/dwarf_formblock.c
index 13f9e72..924baf4 100644
--- a/libdw/dwarf_formblock.c
+++ b/libdw/dwarf_formblock.c
@@ -1,5 +1,5 @@
 /* Return block represented by attribute.
-   Copyright (C) 2004-2010, 2014 Red Hat, Inc.
+   Copyright (C) 2004-2010, 2014, 2018 Red Hat, Inc.
    This file is part of elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2004.
 
@@ -75,6 +75,16 @@ dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block)
       return_block->data = (unsigned char *) datap;
       break;
 
+    case DW_FORM_data16:
+      /* The DWARFv5 spec calls this constant class, but we interpret
+	 it as a block that the user will need to interpret when
+	 converting to a value.  */
+      if (unlikely (endp - datap < 16))
+	goto invalid;
+      return_block->length = 16;
+      return_block->data = (unsigned char *) datap;
+      break;
+
     default:
       __libdw_seterrno (DWARF_E_NO_BLOCK);
       return -1;
diff --git a/src/ChangeLog b/src/ChangeLog
index ebd6f55..26f3938 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
 2018-02-09  Mark Wielaard  <mark@klomp.org>
 
+	* readelf.c (attr_callback): Handle DW_FORM_data16 as Dwarf_Block.
+
+2018-02-09  Mark Wielaard  <mark@klomp.org>
+
 	* readelf.c (print_debug_abbrev_section): Print the value of a
 	DW_FORM_implicit_const using dwarf_getabbrevattr_data.
 	(attr_callback): Handle DW_FORM_implicit_const.
diff --git a/src/readelf.c b/src/readelf.c
index c57d7fe..af20175 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -6083,7 +6083,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
     case DW_FORM_implicit_const:
     case DW_FORM_udata:
     case DW_FORM_sdata:
-    case DW_FORM_data8:
+    case DW_FORM_data8: /* Note no data16 here, we see that as block. */
     case DW_FORM_data4:
     case DW_FORM_data2:
     case DW_FORM_data1:;
@@ -6276,6 +6276,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
     case DW_FORM_block2:
     case DW_FORM_block1:
     case DW_FORM_block:
+    case DW_FORM_data16: /* DWARF5 calls this a constant class.  */
       if (cbargs->silent)
 	break;
       Dwarf_Block block;
-- 
1.8.3.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]