summaryrefslogtreecommitdiff
path: root/libdw/dwarf_getattrs.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-01-18 19:59:08 +0000
committerUlrich Drepper <drepper@redhat.com>2008-01-18 19:59:08 +0000
commit35f08c4d52d0ffd9f8aa50f47b84de5603842b1f (patch)
tree7def9d6d4ef3ffea169252d44325cb039294129d /libdw/dwarf_getattrs.c
parent4173bd8d5dd43413ba0635e2a74bc57a9478fb13 (diff)
downloadelfutils-35f08c4d52d0ffd9f8aa50f47b84de5603842b1f.tar.gz
propagate from branch 'com.redhat.elfutils.nickc.pending' (head 28d6423325f0cc14a133eb6b92a8c3604e437ba6)
to branch 'com.redhat.elfutils' (head 6ef48518ed8497626058574c787852bd939d46ee)
Diffstat (limited to 'libdw/dwarf_getattrs.c')
-rw-r--r--libdw/dwarf_getattrs.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libdw/dwarf_getattrs.c b/libdw/dwarf_getattrs.c
index ebf0869c..876475e6 100644
--- a/libdw/dwarf_getattrs.c
+++ b/libdw/dwarf_getattrs.c
@@ -72,7 +72,7 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *),
/* Find the abbreviation. */
die->abbrev = __libdw_findabbrev (die->cu, u128);
- if (die->abbrev == (Dwarf_Abbrev *) -1l)
+ if (die->abbrev == DWARF_END_ABBREV)
{
__libdw_seterrno (DWARF_E_INVALID_DWARF);
return -1l;
@@ -96,13 +96,19 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *),
/* Get attribute name and form. */
Dwarf_Attribute attr;
+ const unsigned char * remembered_attrp = attrp;
+
// XXX Fix bound checks
get_uleb128 (attr.code, attrp);
get_uleb128 (attr.form, attrp);
/* We can stop if we found the attribute with value zero. */
if (attr.code == 0 && attr.form == 0)
- return 0;
+ /* Do not return 0 here - there would be no way to
+ distinguish this value from the attribute at offset 0.
+ Instead we return +1 which would never be a valid
+ offset of an attribute. */
+ return 1l;
/* Fill in the rest. */
attr.valp = (unsigned char *) die_addr;
@@ -110,7 +116,10 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *),
/* Now call the callback function. */
if (callback (&attr, arg) != DWARF_CB_OK)
- return attrp - die->abbrev->attrp;
+ /* Return the offset of the start of the attribute, so that
+ dwarf_getattrs() can be restarted from this point if the
+ caller so desires. */
+ return remembered_attrp - die->abbrev->attrp;
/* Skip over the rest of this attribute (if there is any). */
if (attr.form != 0)