diff options
Diffstat (limited to 'libdw/dwarf_getattrs.c')
| -rw-r--r-- | libdw/dwarf_getattrs.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/libdw/dwarf_getattrs.c b/libdw/dwarf_getattrs.c index 0da8b5ba..50faf988 100644 --- a/libdw/dwarf_getattrs.c +++ b/libdw/dwarf_getattrs.c @@ -1,5 +1,5 @@ /* Get attributes of the DIE. - Copyright (C) 2004, 2005, 2008, 2009, 2014 Red Hat, Inc. + Copyright (C) 2004, 2005, 2008, 2009, 2014, 2017 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2004. @@ -51,7 +51,6 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *), if (unlikely (abbrevp == DWARF_END_ABBREV)) { - invalid_dwarf: __libdw_seterrno (DWARF_E_INVALID_DWARF); return -1l; } @@ -61,24 +60,15 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *), const unsigned char *const offset_attrp = abbrevp->attrp + offset; /* Go over the list of attributes. */ - Dwarf *dbg = die->cu->dbg; - const unsigned char *endp; - endp = ((const unsigned char *) dbg->sectiondata[IDX_debug_abbrev]->d_buf - + dbg->sectiondata[IDX_debug_abbrev]->d_size); while (1) { - /* Are we still in bounds? */ - if (unlikely (attrp >= endp)) - goto invalid_dwarf; - - /* Get attribute name and form. */ + /* Get attribute name and form. Dwarf_Abbrev was checked when + created, so we can read unchecked. */ Dwarf_Attribute attr; const unsigned char *remembered_attrp = attrp; - get_uleb128 (attr.code, attrp, endp); - if (unlikely (attrp >= endp)) - goto invalid_dwarf; - get_uleb128 (attr.form, attrp, endp); + get_uleb128_unchecked (attr.code, attrp); + get_uleb128_unchecked (attr.form, attrp); /* We can stop if we found the attribute with value zero. */ if (attr.code == 0 && attr.form == 0) @@ -93,7 +83,10 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *), if (remembered_attrp >= offset_attrp) { /* Fill in the rest. */ - attr.valp = (unsigned char *) die_addr; + if (attr.form == DW_FORM_implicit_const) + attr.valp = (unsigned char *) attrp; + else + attr.valp = (unsigned char *) die_addr; attr.cu = die->cu; /* Now call the callback function. */ @@ -114,6 +107,12 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *), // __libdw_form_val_len will have done a bounds check. die_addr += len; + + if (attr.form == DW_FORM_implicit_const) + { + int64_t attr_value __attribute__((__unused__)); + get_sleb128_unchecked (attr_value, attrp); + } } } /* NOTREACHED */ |
