summaryrefslogtreecommitdiff
path: root/libdw/dwarf_getabbrevattr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdw/dwarf_getabbrevattr.c')
-rw-r--r--libdw/dwarf_getabbrevattr.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/libdw/dwarf_getabbrevattr.c b/libdw/dwarf_getabbrevattr.c
index 3b4da99c..54ff604f 100644
--- a/libdw/dwarf_getabbrevattr.c
+++ b/libdw/dwarf_getabbrevattr.c
@@ -1,5 +1,5 @@
/* Get specific attribute of abbreviation.
- Copyright (C) 2003, 2004, 2005, 2014 Red Hat, Inc.
+ Copyright (C) 2003, 2004, 2005, 2014, 2017 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -37,8 +37,9 @@
int
-dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx, unsigned int *namep,
- unsigned int *formp, Dwarf_Off *offsetp)
+dwarf_getabbrevattr_data (Dwarf_Abbrev *abbrev, size_t idx,
+ unsigned int *namep, unsigned int *formp,
+ Dwarf_Sword *datap, Dwarf_Off *offsetp)
{
if (abbrev == NULL)
return -1;
@@ -48,15 +49,21 @@ dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx, unsigned int *namep,
const unsigned char *start_attrp;
unsigned int name;
unsigned int form;
+ Dwarf_Word data;
do
{
start_attrp = attrp;
- /* Attribute code and form are encoded as ULEB128 values.i
- XXX We have no way to bounds check. */
- get_uleb128 (name, attrp, attrp + len_leb128 (name));
- get_uleb128 (form, attrp, attrp + len_leb128 (form));
+ /* Attribute code and form are encoded as ULEB128 values.
+ Already checked when Dwarf_Abbrev was created, read unchecked. */
+ get_uleb128_unchecked (name, attrp);
+ get_uleb128_unchecked (form, attrp);
+
+ if (form == DW_FORM_implicit_const)
+ get_sleb128_unchecked (data, attrp);
+ else
+ data = 0;
/* If both values are zero the index is out of range. */
if (name == 0 && form == 0)
@@ -69,8 +76,19 @@ dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx, unsigned int *namep,
*namep = name;
if (formp != NULL)
*formp = form;
+ if (datap != NULL)
+ *datap = data;
if (offsetp != NULL)
*offsetp = (start_attrp - abbrev->attrp) + abbrev->offset;
return 0;
}
+INTDEF(dwarf_getabbrevattr_data)
+
+int
+dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx, unsigned int *namep,
+ unsigned int *formp, Dwarf_Off *offsetp)
+{
+ return INTUSE(dwarf_getabbrevattr_data) (abbrev, idx, namep, formp,
+ NULL, offsetp);
+}