summaryrefslogtreecommitdiff
path: root/libdw
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-02-12 16:28:50 +0100
committerMark Wielaard <mark@klomp.org>2021-02-17 16:52:57 +0100
commitce6a126b01b2c8951dd941a95a92be71e34f2088 (patch)
treec70be2b1a6c4ed23dbb8a5e65112a3a3b7d0208f /libdw
parentf146d5ec8e2eee566df6eb4c939cf29d779fc08c (diff)
downloadelfutils-ce6a126b01b2c8951dd941a95a92be71e34f2088.tar.gz
readelf, libdw: blocks aren't expressions for DWARF version 4
For DWARF version 4 or higher a block form really encodes a block, not an expression location. Also constant offsets can be expressed as DW_FORM_implicit_const in DWARF version 5. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdw')
-rw-r--r--libdw/ChangeLog6
-rw-r--r--libdw/dwarf_getlocation.c17
2 files changed, 23 insertions, 0 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index b8038f00..f01bee39 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,9 @@
+2021-02-12 Mark Wielaard <mark@klomp.org>
+
+ * dwarf_getlocation.c (attr_ok): For DWARF version 4 or higher
+ block forms are not expression locations.
+ (is_constant_offset): DW_FORM_implicit_const is also a constant.
+
2020-12-20 Dmitry V. Levin <ldv@altlinux.org>
* .gitignore: New file.
diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c
index 4e582db2..5db3cf97 100644
--- a/libdw/dwarf_getlocation.c
+++ b/libdw/dwarf_getlocation.c
@@ -48,6 +48,22 @@ attr_ok (Dwarf_Attribute *attr)
if (dwarf_whatform (attr) == DW_FORM_exprloc)
return true;
+ if (attr->cu->version >= 4)
+ {
+ /* Must be an exprloc (or constant), just not any block form. */
+ switch (dwarf_whatform (attr))
+ {
+ case DW_FORM_block:
+ case DW_FORM_block1:
+ case DW_FORM_block2:
+ case DW_FORM_block4:
+ __libdw_seterrno (DWARF_E_NO_LOC_VALUE);
+ return false;
+ default:
+ break;
+ }
+ }
+
/* Otherwise must be one of the attributes listed below. Older
DWARF versions might have encoded the exprloc as block, and we
cannot easily distinguish attributes in the loclist class because
@@ -186,6 +202,7 @@ is_constant_offset (Dwarf_Attribute *attr,
case DW_FORM_data8:
case DW_FORM_sdata:
case DW_FORM_udata:
+ case DW_FORM_implicit_const:
break;
}