summaryrefslogtreecommitdiff
path: root/libdw/dwarf_getlocation.c
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2013-12-09 16:33:26 +0100
committerMark Wielaard <mjw@redhat.com>2013-12-13 14:23:02 +0100
commit3951f2ec0aaca021c77a2c7a464dcf43433261c3 (patch)
treeae53cf11004fbb40596d7ccde179100b52f3fa20 /libdw/dwarf_getlocation.c
parent8b10aaa3dd3db1981aee29cf8f88411707172295 (diff)
downloadelfutils-3951f2ec0aaca021c77a2c7a464dcf43433261c3.tar.gz
libdw: Handle empty location expression for (indirect) DIE locations.
When dwarf_getlocation_implicit_pointer and dwarf_getlocation_attr refer to a DIE that doesn't contain a DW_AT_location then don't generate an error, but return an empty location expression to signal the actual value pointed to is not available. This isn't invalid DWARF. Also make sure that __libdw_intern_expression handles empty location expressions. Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libdw/dwarf_getlocation.c')
-rw-r--r--libdw/dwarf_getlocation.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c
index ff25fc7c..4124ae36 100644
--- a/libdw/dwarf_getlocation.c
+++ b/libdw/dwarf_getlocation.c
@@ -202,6 +202,13 @@ __libdw_intern_expression (Dwarf *dbg, bool other_byte_order,
bool cfap, bool valuep,
Dwarf_Op **llbuf, size_t *listlen, int sec_index)
{
+ /* Empty location expressions don't have any ops to intern. */
+ if (block->length == 0)
+ {
+ *listlen = 0;
+ return 0;
+ }
+
/* Check whether we already looked at this list. */
struct loc_s fake = { .addr = block->data };
struct loc_s **found = tfind (&fake, cache, loc_compare);
@@ -465,8 +472,8 @@ __libdw_intern_expression (Dwarf *dbg, bool other_byte_order,
if (unlikely (n == 0))
{
/* This is not allowed.
-
- XXX Is it? */
+ It would mean an empty location expression, which we handled
+ already as a special case above. */
goto invalid;
}