]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: form::width takes cu_head, not cu argument
authorPetr Machata <pmachata@redhat.com>
Wed, 23 Feb 2011 19:44:34 +0000 (20:44 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 23 Feb 2011 19:44:34 +0000 (20:44 +0100)
- also the argument may be NULL, in which case the width may end up being
  fw_unknown

dwarflint/check_debug_info.cc
dwarflint/check_debug_loc_range.cc
dwarflint/dwarf_version.cc
dwarflint/dwarf_version.hh

index 63ea4c43cac227c57be16a2e79f5de611eca5c1d..a89d90d288ba8f144f575387ce0cc66a3c53aa38 100644 (file)
@@ -1,6 +1,6 @@
 /* Routines related to .debug_info.
 
-   Copyright (C) 2009, 2010 Red Hat, Inc.
+   Copyright (C) 2009, 2010, 2011 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -629,7 +629,8 @@ namespace
                && ver->form_class (form, attribute) == cl_indirect)
              {
                uint64_t value;
-               if (!read_sc_value (&value, form->width (cu), ctx, &where))
+               if (!read_sc_value (&value, form->width (cu->head),
+                                   ctx, &where))
                  return -1;
                form_name = value;
                form = check_debug_abbrev::check_form
@@ -684,7 +685,7 @@ namespace
               cl_rangelistptr);
 
            if (cls != max_dw_class && ref_classes.test (cls))
-             if (form->width (cu) == fw_8
+             if (form->width (cu->head) == fw_8
                  && cu->head->offset_size == 4)
                wr_error (where)
                  << "reference attribute with form \""
@@ -773,7 +774,7 @@ namespace
            read_ctx block;
 
            storage_class_t storclass = form->storage_class ();
-           if (!read_generic_value (ctx, form->width (cu), storclass,
+           if (!read_generic_value (ctx, form->width (cu->head), storclass,
                                     &where, &value, &block))
              {
                // Note that for fw_uleb and fw_sleb we report the
@@ -814,7 +815,7 @@ namespace
 
                if (attribute != NULL)
                  {
-                   form_width_t width = form->width (cu);
+                   form_width_t width = form->width (cu->head);
                    relocate_one (&file, reloc, rel, width, &value, &where,
                                  reloc_target (form, attribute), symbolp);
                  }
index f3b5f5a4cae4ec051f436a8fc381bb87f99e84f1..e64b07c911ddb630556eebd4c572025541925918 100644 (file)
@@ -1,6 +1,6 @@
 /* Routines related to .debug_loc and .debug_range.
 
-   Copyright (C) 2009, 2010 Red Hat, Inc.
+   Copyright (C) 2009, 2010, 2011 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -791,7 +791,7 @@ namespace
 
     storage_class_t storclass = form->storage_class ();
     assert (storclass != sc_string);
-    if (!read_generic_value (ctx, form->width (cu), storclass,
+    if (!read_generic_value (ctx, form->width (cu->head), storclass,
                             where, valuep, NULL))
       {
        wr_error (*where)
index 9b4ebaaf8e79926b6ecc4dbb561dbb984c2c2923..e611a8335a370b05b40e5f8992ce55db0d5a5a19 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files
-   Copyright (C) 2009,2010 Red Hat, Inc.
+   Copyright (C) 2009,2010,2011 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
 // version.  Apart from standardized DWARF formats, e.g. DWARF3+GNU is
 // a version of its own.
 
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include "dwarf_version.hh"
 #include "dwarf_2.hh"
 #include "dwarf_3.hh"
@@ -89,14 +93,22 @@ dwarf_version::form_class (form const *form, attribute const *attribute) const
 }
 
 form_width_t
-form::width (cu const *cu) const
+form::width (cu_head const *cu_head) const
 {
-  if (_m_width == fw_offset)
-    return static_cast<form_width_t> (cu->head->offset_size);
-  else if (_m_width == fw_address)
-    return static_cast<form_width_t> (cu->head->address_size);
-  else
-    return static_cast<form_width_t> (_m_width);
+  switch (_m_width)
+    {
+    case fw_offset:
+    case fw_address:
+      if (unlikely (cu_head == NULL))
+       return fw_unknown;
+      if (_m_width == fw_offset)
+       return static_cast<form_width_t> (cu_head->offset_size);
+      else
+       return static_cast<form_width_t> (cu_head->address_size);
+
+    default:
+      return static_cast<form_width_t> (_m_width);
+    }
 }
 
 std::ostream &
index f3bee10b5e1879743adc448f1ec450cba5ae7270..1d397817f77b0591f96a7861624ff2fe7ec1c495 100644 (file)
@@ -1,6 +1,6 @@
 /* Dwarf version tables.
 
-   Copyright (C) 2009, 2010 Red Hat, Inc.
+   Copyright (C) 2009, 2010, 2011 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -122,8 +122,8 @@ public:
   ///
   /// Return value is never fw_offset or fw_address.  These get
   /// resolved to fw_4 or fw_8 depending on corresponding value in
-  /// CU->head.
-  form_width_t width (cu const *cu) const;
+  /// CU_HEAD.
+  form_width_t width (cu_head const *cu_head) const;
 
   /// Return storage class of given form.  Closely related to width.
   storage_class_t