* [PATCH] libdw: Add support for DWARF5 DW_FORM_data16.
@ 2018-02-09 20:58 Mark Wielaard
2018-02-21 16:23 ` Mark Wielaard
0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2018-02-09 20:58 UTC (permalink / raw)
To: elfutils-devel; +Cc: Mark Wielaard
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libdw: Add support for DWARF5 DW_FORM_data16.
2018-02-09 20:58 [PATCH] libdw: Add support for DWARF5 DW_FORM_data16 Mark Wielaard
@ 2018-02-21 16:23 ` Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2018-02-21 16:23 UTC (permalink / raw)
To: elfutils-devel
On Fri, 2018-02-09 at 21:58 +0100, Mark Wielaard wrote:
> 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.
Pushed to master.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-21 16:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-09 20:58 [PATCH] libdw: Add support for DWARF5 DW_FORM_data16 Mark Wielaard
2018-02-21 16:23 ` Mark Wielaard
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).