summaryrefslogtreecommitdiffstats
path: root/libdw/dwarf_getattrs.c
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2017-12-26 11:52:06 +0100
committerMark Wielaard <[email protected]>2018-01-01 22:48:56 +0100
commitbfb2117387eb98eae4f0aace7c32061a27483adc (patch)
tree829e1e40297a219f4e315edfcc711f780ba0b4f1 /libdw/dwarf_getattrs.c
parent68cd423edbba61af902eed2abe85578f1c134a25 (diff)
libdw: New get_uleb128_unchecked to use with already checked Dwarf_Abbrev.
When creating a Dwarf_Abbrev in dwarf_getabbrev (__libdw_getabbrev) we already check it is fully readable from the .debug_abbrev section. So whenever we reread it later using the attrp pointer we don't have to check it again. Introduce get_uleb128_unchecked to use for ulebs we know are safe to read directly. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libdw/dwarf_getattrs.c')
-rw-r--r--libdw/dwarf_getattrs.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/libdw/dwarf_getattrs.c b/libdw/dwarf_getattrs.c
index 0da8b5ba..7f55fafc 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)