17452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath/* Compute size of an aggregate type from DWARF.
2b50014f56418d9be8eb3d5a86c693a4fda83dc09Mark Wielaard   Copyright (C) 2010, 2014 Red Hat, Inc.
3de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   This file is part of elfutils.
47452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
5de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   This file is free software; you can redistribute it and/or modify
6de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   it under the terms of either
77452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
8de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard     * the GNU Lesser General Public License as published by the Free
9de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       Software Foundation; either version 3 of the License, or (at
10de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       your option) any later version
11de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
12de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   or
13de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
14de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard     * the GNU General Public License as published by the Free
15de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       Software Foundation; either version 2 of the License, or (at
16de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       your option) any later version
17de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
18de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   or both in parallel, as here.
19de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
20de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   elfutils is distributed in the hope that it will be useful, but
217452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath   WITHOUT ANY WARRANTY; without even the implied warranty of
227452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
237452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath   General Public License for more details.
247452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
25de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   You should have received copies of the GNU General Public License and
26de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   the GNU Lesser General Public License along with this program.  If
27de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   not, see <http://www.gnu.org/licenses/>.  */
287452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
297452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath#ifdef HAVE_CONFIG_H
307452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath# include <config.h>
317452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath#endif
327452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
337452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath#include <dwarf.h>
347452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath#include "libdwP.h"
357452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
367452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
377452e1953a4a4e70af3fb472e609e89776031e53Roland McGrathstatic Dwarf_Die *
387452e1953a4a4e70af3fb472e609e89776031e53Roland McGrathget_type (Dwarf_Die *die, Dwarf_Attribute *attr_mem, Dwarf_Die *type_mem)
397452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath{
403a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard  Dwarf_Die *type = INTUSE(dwarf_formref_die)
417452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath    (INTUSE(dwarf_attr_integrate) (die, DW_AT_type, attr_mem), type_mem);
423a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard
433a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard  if (INTUSE(dwarf_peel_type) (type, type) != 0)
443a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard    return NULL;
453a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard
463a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard  return type;
477452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath}
487452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
497452e1953a4a4e70af3fb472e609e89776031e53Roland McGrathstatic int
507452e1953a4a4e70af3fb472e609e89776031e53Roland McGratharray_size (Dwarf_Die *die, Dwarf_Word *size,
517452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    Dwarf_Attribute *attr_mem, Dwarf_Die *type_mem)
527452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath{
537452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  Dwarf_Word eltsize;
547452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  if (INTUSE(dwarf_aggregate_size) (get_type (die, attr_mem, type_mem),
557452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath				    &eltsize) != 0)
567452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      return -1;
577452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
587452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  /* An array can have DW_TAG_subrange_type or DW_TAG_enumeration_type
597452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath     children instead that give the size of each dimension.  */
607452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
617452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  Dwarf_Die child;
627452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  if (INTUSE(dwarf_child) (die, &child) != 0)
637452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath    return -1;
647452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
657452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  bool any = false;
667452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  Dwarf_Word total = 0;
677452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  do
687452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath    {
697452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      Dwarf_Word count;
707452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      switch (INTUSE(dwarf_tag) (&child))
717452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	{
727452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	case DW_TAG_subrange_type:
737452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  /* This has either DW_AT_count or DW_AT_upper_bound.  */
747452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  if (INTUSE(dwarf_attr_integrate) (&child, DW_AT_count,
757452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath					    attr_mem) != NULL)
767452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    {
777452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	      if (INTUSE(dwarf_formudata) (attr_mem, &count) != 0)
787452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		return -1;
797452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    }
807452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  else
817452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    {
827452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	      Dwarf_Sword upper;
837452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	      Dwarf_Sword lower;
847452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	      if (INTUSE(dwarf_formsdata) (INTUSE(dwarf_attr_integrate)
857452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath					   (&child, DW_AT_upper_bound,
867452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath					    attr_mem), &upper) != 0)
877452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		return -1;
887452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
897452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	      /* Having DW_AT_lower_bound is optional.  */
907452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	      if (INTUSE(dwarf_attr_integrate) (&child, DW_AT_lower_bound,
917452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath						attr_mem) != NULL)
927452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		{
937452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		  if (INTUSE(dwarf_formsdata) (attr_mem, &lower) != 0)
947452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    return -1;
957452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		}
967452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	      else
977452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		{
987452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		  /* Determine default lower bound from language,
997452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		     as per "4.12 Subrange Type Entries".  */
1007452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		  Dwarf_Die cu = CUDIE (die->cu);
1017452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		  switch (INTUSE(dwarf_srclang) (&cu))
1027452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    {
1037452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_C:
1047452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_C89:
1057452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_C99:
1069f8c08e68243561a54a09e38fd472b4fc2c17d5dMark Wielaard		    case DW_LANG_C11:
1077452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_C_plus_plus:
1089f8c08e68243561a54a09e38fd472b4fc2c17d5dMark Wielaard		    case DW_LANG_C_plus_plus_11:
1099f8c08e68243561a54a09e38fd472b4fc2c17d5dMark Wielaard		    case DW_LANG_C_plus_plus_14:
110c4010b8194a458d4e12f86c0b05327126199ff60Mark Wielaard		    case DW_LANG_ObjC:
1117452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_ObjC_plus_plus:
1127452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_Java:
1137452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_D:
1147452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_UPC:
1159f8c08e68243561a54a09e38fd472b4fc2c17d5dMark Wielaard		    case DW_LANG_Go:
1167452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		      lower = 0;
1177452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		      break;
1187452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
1197452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_Ada83:
1207452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_Ada95:
1217452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_Cobol74:
1227452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_Cobol85:
1237452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_Fortran77:
1247452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_Fortran90:
1257452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_Fortran95:
126d3c816d2d882e7917693acf9464941cf10b118d1Mark Wielaard		    case DW_LANG_Fortran03:
127d3c816d2d882e7917693acf9464941cf10b118d1Mark Wielaard		    case DW_LANG_Fortran08:
1287452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_Pascal83:
1297452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_Modula2:
1307452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    case DW_LANG_PL1:
1317452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		      lower = 1;
1327452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		      break;
1337452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
1347452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    default:
1357452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		      return -1;
1367452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    }
1377452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		}
1387452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	      if (unlikely (lower > upper))
1397452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		return -1;
1407452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	      count = upper - lower + 1;
1417452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    }
1427452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  break;
1437452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
1447452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	case DW_TAG_enumeration_type:
1457452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  /* We have to find the DW_TAG_enumerator child with the
1467452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	     highest value to know the array's element count.  */
1477452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  count = 0;
1487452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  Dwarf_Die enum_child;
1497452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  int has_children = INTUSE(dwarf_child) (die, &enum_child);
1507452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  if (has_children < 0)
1517452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    return -1;
1527452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  if (has_children > 0)
1537452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    do
1547452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	      if (INTUSE(dwarf_tag) (&enum_child) == DW_TAG_enumerator)
1557452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		{
1567452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		  Dwarf_Word value;
1577452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		  if (INTUSE(dwarf_formudata) (INTUSE(dwarf_attr_integrate)
1587452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath					       (&enum_child, DW_AT_const_value,
1597452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath						attr_mem), &value) != 0)
1607452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    return -1;
1617452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		  if (value >= count)
1627452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		    count = value + 1;
1637452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath		}
1647452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    while (INTUSE(dwarf_siblingof) (&enum_child, &enum_child) > 0);
1657452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  break;
1667452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
1677452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	default:
1687452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  continue;
1697452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	}
1707452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
1717452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      /* This is a subrange_type or enumeration_type and we've set COUNT.
1727452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	 Now determine the stride for this array dimension.  */
1737452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      Dwarf_Word stride = eltsize;
1747452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      if (INTUSE(dwarf_attr_integrate) (&child, DW_AT_byte_stride,
1757452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath					attr_mem) != NULL)
1767452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	{
1777452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  if (INTUSE(dwarf_formudata) (attr_mem, &stride) != 0)
1787452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    return -1;
1797452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	}
1807452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      else if (INTUSE(dwarf_attr_integrate) (&child, DW_AT_bit_stride,
1817452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath					     attr_mem) != NULL)
1827452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	{
1837452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  if (INTUSE(dwarf_formudata) (attr_mem, &stride) != 0)
1847452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    return -1;
1857452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  if (stride % 8) 	/* XXX maybe compute in bits? */
1867452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	    return -1;
1877452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	  stride /= 8;
1887452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath	}
1897452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
1907452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      any = true;
1917452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      total += stride * count;
1927452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath    }
1937452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  while (INTUSE(dwarf_siblingof) (&child, &child) == 0);
1947452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
1957452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  if (!any)
1967452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath    return -1;
1977452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
1987452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  *size = total;
1997452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  return 0;
2007452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath}
2017452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
2027452e1953a4a4e70af3fb472e609e89776031e53Roland McGrathstatic int
2037452e1953a4a4e70af3fb472e609e89776031e53Roland McGrathaggregate_size (Dwarf_Die *die, Dwarf_Word *size, Dwarf_Die *type_mem)
2047452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath{
2057452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  Dwarf_Attribute attr_mem;
2067452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
2077452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  if (INTUSE(dwarf_attr_integrate) (die, DW_AT_byte_size, &attr_mem) != NULL)
2087452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath    return INTUSE(dwarf_formudata) (&attr_mem, size);
2097452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
2107452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  switch (INTUSE(dwarf_tag) (die))
2117452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath    {
2127452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath    case DW_TAG_subrange_type:
2137452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      return aggregate_size (get_type (die, &attr_mem, type_mem),
2147452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath			     size, type_mem); /* Tail call.  */
2157452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
2167452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath    case DW_TAG_array_type:
2177452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath      return array_size (die, size, &attr_mem, type_mem);
218b50014f56418d9be8eb3d5a86c693a4fda83dc09Mark Wielaard
219b50014f56418d9be8eb3d5a86c693a4fda83dc09Mark Wielaard    /* Assume references and pointers have pointer size if not given an
220b50014f56418d9be8eb3d5a86c693a4fda83dc09Mark Wielaard       explicit DW_AT_byte_size.  */
221b50014f56418d9be8eb3d5a86c693a4fda83dc09Mark Wielaard    case DW_TAG_pointer_type:
222b50014f56418d9be8eb3d5a86c693a4fda83dc09Mark Wielaard    case DW_TAG_reference_type:
223b50014f56418d9be8eb3d5a86c693a4fda83dc09Mark Wielaard    case DW_TAG_rvalue_reference_type:
224b50014f56418d9be8eb3d5a86c693a4fda83dc09Mark Wielaard      *size = die->cu->address_size;
225b50014f56418d9be8eb3d5a86c693a4fda83dc09Mark Wielaard      return 0;
2267452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath    }
2277452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
2287452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  /* Most types must give their size directly.  */
2297452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  return -1;
2307452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath}
2317452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath
2327452e1953a4a4e70af3fb472e609e89776031e53Roland McGrathint
2331ccdfb683ad6c7e59793136c3a657ddf131cafd1Mark Wielaarddwarf_aggregate_size (Dwarf_Die *die, Dwarf_Word *size)
2347452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath{
2357452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  Dwarf_Die type_mem;
2363a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard
2373a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard  if (INTUSE (dwarf_peel_type) (die, die) != 0)
2383a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard    return -1;
2393a36e8a26c32103ec2f8edda8bf212d6883970a2Mark Wielaard
2407452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath  return aggregate_size (die, size, &type_mem);
2417452e1953a4a4e70af3fb472e609e89776031e53Roland McGrath}
2427452e1953a4a4e70af3fb472e609e89776031e53Roland McGrathINTDEF (dwarf_aggregate_size)
2433a36e8a26c32103ec2f8edda8bf212d6883970a2Mark WielaardOLD_VERSION (dwarf_aggregate_size, ELFUTILS_0.144)
2443a36e8a26c32103ec2f8edda8bf212d6883970a2Mark WielaardNEW_VERSION (dwarf_aggregate_size, ELFUTILS_0.161)
245