]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
backends (*_return_value_location): call dwarf_peeled_die_type
authorPetr Machata <pmachata@redhat.com>
Fri, 20 Jun 2014 20:59:43 +0000 (22:59 +0200)
committerPetr Machata <pmachata@redhat.com>
Fri, 20 Jun 2014 20:59:43 +0000 (22:59 +0200)
... instead of inlining equivalent code.

Signed-off-by: Petr Machata <pmachata@redhat.com>
12 files changed:
backends/ChangeLog
backends/alpha_retval.c
backends/arm_retval.c
backends/i386_retval.c
backends/ia64_retval.c
backends/ppc64_retval.c
backends/ppc_retval.c
backends/s390_retval.c
backends/sh_retval.c
backends/sparc_retval.c
backends/tilegx_retval.c
backends/x86_64_retval.c

index bc5b8434ffa38a7a6252f8848d197cab6c7ed496..7eda035c3d3c48abdf507bc830bf57db7651dd41 100644 (file)
@@ -1,3 +1,18 @@
+2014-06-20  Petr Machata  <pmachata@redhat.com>
+
+       * alpha_retval.c (alpha_return_value_location): Call
+       dwarf_peeled_die_type instead of inlining equivalent code.
+       * arm_retval.c (arm_return_value_location): Likewise.
+       * i386_retval.c (i386_return_value_location): Likewise.
+       * ia64_retval.c (ia64_return_value_location): Likewise.
+       * ppc64_retval.c (ppc64_return_value_location): Likewise.
+       * ppc_retval.c (ppc_return_value_location): Likewise.
+       * s390_retval.c (s390_return_value_location): Likewise.
+       * sh_retval.c (sh_return_value_location): Likewise.
+       * sparc_retval.c (sparc_return_value_location): Likewise.
+       * tilegx_retval.c (tilegx_return_value_location): Likewise.
+       * x86_64_retval.c (x86_64_return_value_location): Likewise.
+
 2014-05-19  Mark Wielaard  <mjw@redhat.com>
 
        * arm_init.c (arm_init): Hook check_reloc_target_type.
index 6dfa6944176cb00de7b2a91cb765711ad524cf23..53dbfa45470928b635e9d71ada0eb0a081cb7c40 100644 (file)
@@ -1,5 +1,5 @@
 /* Function return value location for Alpha ELF ABI.
-   Copyright (C) 2005, 2007 Red Hat, Inc.
+   Copyright (C) 2005, 2007, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -67,27 +67,10 @@ alpha_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   switch (tag)
     {
@@ -97,6 +80,7 @@ alpha_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -108,6 +92,7 @@ alpha_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_pointer_type:
     case DW_TAG_ptr_to_member_type:
       {
+       Dwarf_Attribute attr_mem;
        Dwarf_Word size;
        if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
                                                   &attr_mem), &size) != 0)
index 222f75553323f9b5b0eaff0432221e3f333f53b4..7aced742c11fdb5bca8af060671c703d4694622c 100644 (file)
@@ -1,5 +1,5 @@
 /* Function return value location for ARM EABI.
-   Copyright (C) 2009-2010 Red Hat, Inc.
+   Copyright (C) 2009-2010, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -63,27 +63,10 @@ arm_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   Dwarf_Word size;
   switch (tag)
@@ -94,6 +77,7 @@ arm_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -104,24 +88,27 @@ arm_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_enumeration_type:
     case DW_TAG_pointer_type:
     case DW_TAG_ptr_to_member_type:
-      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
-                                                &attr_mem), &size) != 0)
-       {
-         if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
-           size = 4;
-         else
-           return -1;
-       }
-      if (size <= 16)
-       {
-       intreg:
-         *locp = loc_intreg;
-         return size <= 4 ? nloc_intreg : nloc_intregs ((size + 3) / 4);
-       }
-
-    aggregate:
-      *locp = loc_aggregate;
-      return nloc_aggregate;
+      {
+       Dwarf_Attribute attr_mem;
+       if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+                                                  &attr_mem), &size) != 0)
+         {
+           if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+             size = 4;
+           else
+             return -1;
+         }
+       if (size <= 16)
+         {
+         intreg:
+           *locp = loc_intreg;
+           return size <= 4 ? nloc_intreg : nloc_intregs ((size + 3) / 4);
+         }
+
+      aggregate:
+       *locp = loc_aggregate;
+       return nloc_aggregate;
+      }
 
     case DW_TAG_structure_type:
     case DW_TAG_class_type:
index 90678c3256956453bc325dc1c413a9a373404a4a..9da797d5ed52ed0124434c149c23ce75a2ef5530 100644 (file)
@@ -1,5 +1,5 @@
 /* Function return value location for Linux/i386 ABI.
-   Copyright (C) 2005-2010 Red Hat, Inc.
+   Copyright (C) 2005-2010, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -67,27 +67,10 @@ i386_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   switch (tag)
     {
@@ -97,6 +80,7 @@ i386_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -109,6 +93,7 @@ i386_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_ptr_to_member_type:
       {
        Dwarf_Word size;
+       Dwarf_Attribute attr_mem;
        if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
                                                   &attr_mem), &size) != 0)
          {
index ac0d8c3d3c4ec7e064ca5c7b8fd77d6467999c8b..b5928c587b71d0f401264bc738adb75772bf456b 100644 (file)
@@ -1,5 +1,5 @@
 /* Function return value location for IA64 ABI.
-   Copyright (C) 2006-2010 Red Hat, Inc.
+   Copyright (C) 2006-2010, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -238,27 +238,10 @@ ia64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   Dwarf_Word size;
   switch (tag)
@@ -269,6 +252,7 @@ ia64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -279,16 +263,21 @@ ia64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_enumeration_type:
     case DW_TAG_pointer_type:
     case DW_TAG_ptr_to_member_type:
-      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
-                                                &attr_mem), &size) != 0)
-       {
-         if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
-           size = 8;
-         else
-           return -1;
-       }
+      {
+       Dwarf_Attribute attr_mem;
+       if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+                                                  &attr_mem), &size) != 0)
+         {
+           if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+             size = 8;
+           else
+             return -1;
+         }
+      }
+
       if (tag == DW_TAG_base_type)
        {
+         Dwarf_Attribute attr_mem;
          Dwarf_Word encoding;
          if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
                                                     &attr_mem),
index c5c3b6fef45912c58076b8058e0cb1b3105a2f58..a25198392506b9b33825703b21ce79831c194f22 100644 (file)
@@ -1,5 +1,5 @@
 /* Function return value location for Linux/PPC64 ABI.
-   Copyright (C) 2005-2010 Red Hat, Inc.
+   Copyright (C) 2005-2010, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -77,27 +77,10 @@ ppc64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   Dwarf_Word size;
   switch (tag)
@@ -108,6 +91,7 @@ ppc64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -118,16 +102,21 @@ ppc64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_enumeration_type:
     case DW_TAG_pointer_type:
     case DW_TAG_ptr_to_member_type:
-      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
-                                                &attr_mem), &size) != 0)
-       {
-         if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
-           size = 8;
-         else
-           return -1;
+      {
+       Dwarf_Attribute attr_mem;
+       if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+                                                  &attr_mem), &size) != 0)
+         {
+           if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+             size = 8;
+           else
+             return -1;
        }
+      }
+
       if (tag == DW_TAG_base_type)
        {
+         Dwarf_Attribute attr_mem;
          Dwarf_Word encoding;
          if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
                                                     &attr_mem),
@@ -162,6 +151,7 @@ ppc64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 
     case DW_TAG_array_type:
       {
+       Dwarf_Attribute attr_mem;
        bool is_vector;
        if (dwarf_formflag (dwarf_attr_integrate (typedie, DW_AT_GNU_vector,
                                                  &attr_mem), &is_vector) == 0
@@ -179,6 +169,7 @@ ppc64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
          if (tag == DW_TAG_array_type)
            {
              /* Check if it's a character array.  */
+             Dwarf_Attribute attr_mem, *attr;
              attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
              typedie = dwarf_formref_die (attr, &die_mem);
              tag = DWARF_TAG_OR_RETURN (typedie);
index 7ca0c18516d820f56f1c20151ba007cdafefd426..b14a99f118664d9312b0edd98ba0b97a9fedfcd4 100644 (file)
@@ -1,5 +1,5 @@
 /* Function return value location for Linux/PPC ABI.
-   Copyright (C) 2005, 2006, 2007, 2010 Red Hat, Inc.
+   Copyright (C) 2005, 2006, 2007, 2010, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -89,27 +89,10 @@ ppc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   Dwarf_Word size;
   switch (tag)
@@ -120,6 +103,7 @@ ppc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -130,18 +114,23 @@ ppc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_enumeration_type:
     case DW_TAG_pointer_type:
     case DW_TAG_ptr_to_member_type:
-      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
-                                                &attr_mem), &size) != 0)
-       {
-         if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
-           size = 4;
-         else
-           return -1;
-       }
+      {
+       Dwarf_Attribute attr_mem;
+       if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+                                                  &attr_mem), &size) != 0)
+         {
+           if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+             size = 4;
+           else
+             return -1;
+         }
+      }
+
       if (size <= 8)
        {
          if (tag == DW_TAG_base_type)
            {
+             Dwarf_Attribute attr_mem;
              Dwarf_Word encoding;
              if (dwarf_formudata (dwarf_attr_integrate (typedie,
                                                         DW_AT_encoding,
@@ -165,6 +154,7 @@ ppc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 
     case DW_TAG_array_type:
       {
+       Dwarf_Attribute attr_mem;
        bool is_vector;
        if (dwarf_formflag (dwarf_attr_integrate (typedie, DW_AT_GNU_vector,
                                                  &attr_mem), &is_vector) == 0
index b671ee86b04462c4ee070582a52871a54d0680b5..a927d46a05a3833d16dce4e4537be55b51e93f85 100644 (file)
@@ -1,5 +1,5 @@
 /* Function return value location for S/390 ABI.
-   Copyright (C) 2006, 2007 Red Hat, Inc.
+   Copyright (C) 2006, 2007, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -68,27 +68,10 @@ s390_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   Dwarf_Word size;
   switch (tag)
@@ -99,6 +82,7 @@ s390_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -115,6 +99,7 @@ s390_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
        if (dwarf_diecu (typedie, &cudie, &asize, NULL) == NULL)
          return -1;
 
+       Dwarf_Attribute attr_mem;
        if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size,
                                         &attr_mem), &size) != 0)
          {
index 1166231845182875269d96d70af5a93e28a771d6..d44f2601f21528f9336907e095d70256519d568f 100644 (file)
@@ -1,5 +1,5 @@
 /* Function return value location for Linux/SH ABI.
-   Copyright (C) 2010 Red Hat, Inc.
+   Copyright (C) 2010, 2014 Red Hat, Inc.
    This file is part of elfutils.
    Contributed by Matt Fleming <matt@console-pimps.org>.
 
@@ -65,27 +65,10 @@ sh_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   Dwarf_Word size;
   switch (tag)
@@ -96,6 +79,7 @@ sh_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -106,18 +90,23 @@ sh_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_enumeration_type:
     case DW_TAG_pointer_type:
     case DW_TAG_ptr_to_member_type:
-      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
-                                                &attr_mem), &size) != 0)
-       {
-         if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
-           size = 4;
-         else
-           return -1;
-       }
+      {
+       Dwarf_Attribute attr_mem;
+       if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+                                                  &attr_mem), &size) != 0)
+         {
+           if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+             size = 4;
+           else
+             return -1;
+         }
+      }
+
       if (size <= 8)
        {
          if (tag == DW_TAG_base_type)
            {
+             Dwarf_Attribute attr_mem;
              Dwarf_Word encoding;
              if (dwarf_formudata (dwarf_attr_integrate (typedie,
                                                         DW_AT_encoding,
index dcd378598f872fe9dae685db82bd61550d04b7f1..e1b177538191ef2e8d7043987dc8c00f5232be32 100644 (file)
@@ -1,5 +1,5 @@
 /* Function return value location for SPARC.
-   Copyright (C) 2006-2010 Red Hat, Inc.
+   Copyright (C) 2006-2010, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -72,27 +72,10 @@ sparc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   Dwarf_Word size;
   switch (tag)
@@ -103,6 +86,7 @@ sparc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -113,19 +97,24 @@ sparc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_enumeration_type:
     case DW_TAG_pointer_type:
     case DW_TAG_ptr_to_member_type:
-      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
-                                                &attr_mem), &size) != 0)
-       {
-         uint8_t asize;
-         Dwarf_Die cudie;
-         if ((tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
-             && dwarf_diecu (typedie, &cudie, &asize, NULL) != NULL)
-           size = asize;
-         else
-           return -1;
-       }
+      {
+       Dwarf_Attribute attr_mem;
+       if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+                                                  &attr_mem), &size) != 0)
+         {
+           uint8_t asize;
+           Dwarf_Die cudie;
+           if ((tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+               && dwarf_diecu (typedie, &cudie, &asize, NULL) != NULL)
+             size = asize;
+           else
+             return -1;
+         }
+      }
+
       if (tag == DW_TAG_base_type)
        {
+         Dwarf_Attribute attr_mem;
          Dwarf_Word encoding;
          if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
                                                     &attr_mem),
index e14cc51243594c3d7900117caa7d1b9d6a9b9e7d..db81a20b3a95782fefdef0d56b298aa856800828 100644 (file)
@@ -1,5 +1,6 @@
 /* Function return value location for Linux/TILE-Gx ABI.
    Copyright (C) 2012 Tilera Corporation
+   Copyright (C) 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -59,27 +60,10 @@ tilegx_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   Dwarf_Word size;
   switch (tag)
@@ -90,6 +74,7 @@ tilegx_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -100,22 +85,25 @@ tilegx_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_enumeration_type:
     case DW_TAG_pointer_type:
     case DW_TAG_ptr_to_member_type:
-      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
-                                                &attr_mem), &size) != 0)
-       {
-         if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
-           size = 8;
-         else
-           return -1;
-       }
-      if (tag == DW_TAG_base_type)
-       {
-         Dwarf_Word encoding;
-         if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
-                                                    &attr_mem),
-                              &encoding) != 0)
-           return -1;
-        }
+      {
+       Dwarf_Attribute attr_mem;
+       if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+                                                  &attr_mem), &size) != 0)
+         {
+           if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+             size = 8;
+           else
+             return -1;
+         }
+       if (tag == DW_TAG_base_type)
+         {
+           Dwarf_Word encoding;
+           if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
+                                                      &attr_mem),
+                                &encoding) != 0)
+             return -1;
+         }
+      }
 
       /* Small enough structs are passed directly in registers R0 ... R7.  */
       if (size <= 8)
@@ -139,6 +127,7 @@ tilegx_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
        {
          if (tag == DW_TAG_array_type)
            {
+             Dwarf_Attribute attr_mem, *attr;
              /* Check if it's a character array.  */
              attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
              typedie = dwarf_formref_die (attr, &die_mem);
index f3e9f2be29936473c738bd19e81f003155106db2..b3799ae075c5adef39fdb55cc1fcf71ddd0af418 100644 (file)
@@ -1,5 +1,5 @@
 /* Function return value location for Linux/x86-64 ABI.
-   Copyright (C) 2005-2010 Red Hat, Inc.
+   Copyright (C) 2005-2010, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -81,27 +81,10 @@ x86_64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
 {
   /* Start with the function's type, and get the DW_AT_type attribute,
      which is the type of the return value.  */
-
-  Dwarf_Attribute attr_mem;
-  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
-                                               &attr_mem);
-  if (attr == NULL)
-    /* The function has no return value, like a `void' function in C.  */
-    return 0;
-
-  Dwarf_Die die_mem;
-  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
-  int tag = DWARF_TAG_OR_RETURN (typedie);
-
-  /* Follow typedefs and qualifiers to get to the actual type.  */
-  while (tag == DW_TAG_typedef
-        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
-        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
-    {
-      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
-      typedie = dwarf_formref_die (attr, &die_mem);
-      tag = DWARF_TAG_OR_RETURN (typedie);
-    }
+  Dwarf_Die die_mem, *typedie = &die_mem;
+  int tag = dwarf_peeled_die_type (functypedie, typedie);
+  if (tag <= 0)
+    return tag;
 
   Dwarf_Word size;
   switch (tag)
@@ -112,6 +95,7 @@ x86_64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_subrange_type:
       if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
        {
+         Dwarf_Attribute attr_mem, *attr;
          attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
          typedie = dwarf_formref_die (attr, &die_mem);
          tag = DWARF_TAG_OR_RETURN (typedie);
@@ -122,16 +106,21 @@ x86_64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
     case DW_TAG_enumeration_type:
     case DW_TAG_pointer_type:
     case DW_TAG_ptr_to_member_type:
-      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
-                                                &attr_mem), &size) != 0)
-       {
-         if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
-           size = 8;
-         else
-           return -1;
-       }
+      {
+       Dwarf_Attribute attr_mem;
+       if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+                                                  &attr_mem), &size) != 0)
+         {
+           if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+             size = 8;
+           else
+             return -1;
+         }
+      }
+
       if (tag == DW_TAG_base_type)
        {
+         Dwarf_Attribute attr_mem;
          Dwarf_Word encoding;
          if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
                                                     &attr_mem),