+2017-12-26 Mark Wielaard <mark@klomp.org>
+
+ * libdwP.h (struct Dwarf_Abbrev): Pack struct. Remove attrcnt,
+ use bitfields for has_children and code.
+ * dwarf_getabbrev.c (__libdw_getabbrev): Don't count attrs.
+ * dwarf_getattrcnt.c (dwarf_getattrcnt): Count attrs.
+
2017-12-26 Mark Wielaard <mark@klomp.org>
* memory-access.h (__libdw_get_uleb128_unchecked): New function.
/* Get abbreviation at given offset.
- Copyright (C) 2003, 2004, 2005, 2006, 2014 Red Hat, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, 2014, 2017 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2003.
abb->attrp = (unsigned char *) abbrevp;
abb->offset = offset;
- /* Skip over all the attributes and count them while doing so. */
- abb->attrcnt = 0;
+ /* Skip over all the attributes and check rest of the abbrev is valid. */
unsigned int attrname;
unsigned int attrform;
do
goto invalid;
get_uleb128 (attrform, abbrevp, end);
}
- while (attrname != 0 && attrform != 0 && ++abb->attrcnt);
+ while (attrname != 0 && attrform != 0);
/* Return the length to the caller if she asked for it. */
if (lengthp != NULL)
/* Get number of attributes of abbreviation.
- Copyright (C) 2003, 2004 Red Hat, Inc.
+ Copyright (C) 2003, 2004, 2017 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2003.
if (abbrev == NULL)
return -1;
- *attrcntp = abbrev->attrcnt;
+ const unsigned char *abbrevp = abbrev->attrp;
+
+ /* Skip over all the attributes and count them while doing so. */
+ int attrcnt = 0;
+ unsigned int attrname;
+ unsigned int attrform;
+ do
+ {
+ /* We can use unchecked since they were checked when the Dwrf_Abbrev
+ was created. */
+ get_uleb128_unchecked (attrname, abbrevp);
+ get_uleb128_unchecked (attrform, abbrevp);
+ }
+ while (attrname != 0 && attrform != 0 && ++attrcnt);
+
+ *attrcntp = attrcnt;
return 0;
}
/* Internal definitions for libdwarf.
- Copyright (C) 2002-2011, 2013-2016 Red Hat, Inc.
+ Copyright (C) 2002-2011, 2013-2017 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
/* Abbreviation representation. */
struct Dwarf_Abbrev
{
- Dwarf_Off offset;
- unsigned char *attrp;
- unsigned int attrcnt;
- unsigned int code;
- unsigned int tag;
- bool has_children;
-};
+ Dwarf_Off offset; /* Offset to start of abbrev into .debug_abbrev. */
+ unsigned char *attrp; /* Pointer to start of attribute name/form pairs. */
+ bool has_children : 1; /* Whether or not the DIE has children. */
+ unsigned int code : 31; /* The (unique) abbrev code. */
+ unsigned int tag; /* The tag of the DIE. */
+} attribute_packed;
#include "dwarf_abbrev_hash.h"