diff options
author | Mark Wielaard <mark@klomp.org> | 2017-12-26 11:52:06 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2018-01-01 22:48:56 +0100 |
commit | bfb2117387eb98eae4f0aace7c32061a27483adc (patch) | |
tree | 829e1e40297a219f4e315edfcc711f780ba0b4f1 /libdw/dwarf_child.c | |
parent | 68cd423edbba61af902eed2abe85578f1c134a25 (diff) | |
download | elfutils-bfb2117387eb98eae4f0aace7c32061a27483adc.tar.gz |
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 <mark@klomp.org>
Diffstat (limited to 'libdw/dwarf_child.c')
-rw-r--r-- | libdw/dwarf_child.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/libdw/dwarf_child.c b/libdw/dwarf_child.c index cc95fb3f..248338eb 100644 --- a/libdw/dwarf_child.c +++ b/libdw/dwarf_child.c @@ -1,5 +1,5 @@ /* Return child of current DIE. - Copyright (C) 2003-2011, 2014 Red Hat, Inc. + Copyright (C) 2003-2011, 2014, 2017 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2003. @@ -43,36 +43,27 @@ internal_function __libdw_find_attr (Dwarf_Die *die, unsigned int search_name, unsigned int *codep, unsigned int *formp) { - Dwarf *dbg = die->cu->dbg; const unsigned char *readp; /* Find the abbreviation entry. */ Dwarf_Abbrev *abbrevp = __libdw_dieabbrev (die, &readp); if (unlikely (abbrevp == DWARF_END_ABBREV)) { - invalid_dwarf: __libdw_seterrno (DWARF_E_INVALID_DWARF); return NULL; } - /* Search the name attribute. */ - unsigned char *const endp - = ((unsigned char *) dbg->sectiondata[IDX_debug_abbrev]->d_buf - + dbg->sectiondata[IDX_debug_abbrev]->d_size); - + /* Search the name attribute. Attribute has been checked when + Dwarf_Abbrev was created, we can read unchecked. */ const unsigned char *attrp = abbrevp->attrp; while (1) { /* Get attribute name and form. */ - if (unlikely (attrp >= endp)) - goto invalid_dwarf; unsigned int attr_name; - get_uleb128 (attr_name, attrp, endp); + get_uleb128_unchecked (attr_name, attrp); - if (unlikely (attrp >= endp)) - goto invalid_dwarf; unsigned int attr_form; - get_uleb128 (attr_form, attrp, endp); + get_uleb128_unchecked (attr_form, attrp); /* We can stop if we found the attribute with value zero. */ if (attr_name == 0 && attr_form == 0) |