]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Allow per-form configuration of CU bitness where form may appear
authorPetr Machata <pmachata@redhat.com>
Wed, 23 Feb 2011 20:52:44 +0000 (21:52 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 23 Feb 2011 20:54:13 +0000 (21:54 +0100)
dwarflint/check_debug_info.cc
dwarflint/dwarf_2.cc
dwarflint/dwarf_version-imp.hh
dwarflint/dwarf_version.cc
dwarflint/dwarf_version.hh

index a89d90d288ba8f144f575387ce0cc66a3c53aa38..69d8fdd3ed2fb2f6143db597d7f54f7c1290d5f4 100644 (file)
@@ -685,12 +685,16 @@ namespace
               cl_rangelistptr);
 
            if (cls != max_dw_class && ref_classes.test (cls))
-             if (form->width (cu->head) == fw_8
-                 && cu->head->offset_size == 4)
-               wr_error (where)
-                 << "reference attribute with form \""
-                 << pri::form (form_name) << "\" in 32-bit CU."
-                 << std::endl;
+             {
+               form_bitness_t bitness = form->bitness ();
+               if ((bitness == fb_32 && cu->head->offset_size == 8)
+                   || (bitness == fb_64 && cu->head->offset_size == 4))
+                 wr_error (where)
+                   << "reference attribute with form \""
+                   << pri::form (form_name) << "\" in "
+                   << (8 * cu->head->offset_size) << "-bit CU."
+                   << std::endl;
+             }
 
            /* Setup pointer checking.  */
            switch (cls)
index c39eca6ff710fb5102be0c7bb231b0499a7d3529..f3c23a240a453e77f7020f7b1d1d4ae26d921a8b 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files
-   Copyright (C) 2010 Red Hat, Inc.
+   Copyright (C) 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
@@ -148,7 +148,7 @@ namespace
       add (ref_form (DW_FORM_ref1, fw_1));
       add (ref_form (DW_FORM_ref2, fw_2));
       add (ref_form (DW_FORM_ref4, fw_4));
-      add (ref_form (DW_FORM_ref8, fw_8));
+      add (ref_form (DW_FORM_ref8, fw_8, fb_64));
       add (ref_form (DW_FORM_ref_udata, fw_uleb));
 
       add (string_form (DW_FORM_string));
index 4f00c7c844d78a6768b8174d56a337c2ef915053..10cbc6164bc0e87b3d43a1c955744d71ea0793af 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files
-   Copyright (C) 2010 Red Hat, Inc.
+   Copyright (C) 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
@@ -49,8 +49,9 @@ template<storage_class_t StorClass, dw_class... Classes>
 struct preset_form
   : public form
 {
-  preset_form (int a_name, form_width_t a_width)
-    : form (a_name, dw_class_set (Classes...), a_width, StorClass)
+  preset_form (int a_name, form_width_t a_width,
+              form_bitness_t a_bitness = fb_any)
+    : form (a_name, dw_class_set (Classes...), a_width, StorClass, a_bitness)
   {}
 };
 
index e611a8335a370b05b40e5f8992ce55db0d5a5a19..819f8106b0833b6203a6d0440b5dd3d17f834028 100644 (file)
@@ -58,19 +58,23 @@ dw_class_set::dw_class_set (dw_class a, dw_class b, dw_class c,
 }
 
 form::form (int a_name, dw_class_set a_classes,
-           form_width_t a_width, storage_class_t a_storclass)
+           form_width_t a_width, storage_class_t a_storclass,
+           form_bitness_t a_bitness)
   : _m_name (a_name)
   , _m_classes (a_classes)
   , _m_width (a_width)
   , _m_storclass (a_storclass)
+  , _m_bitness (a_bitness)
 {}
 
 form::form (int a_name, dw_class_set a_classes,
-           form_width_special_t a_width, storage_class_t a_storclass)
+           form_width_special_t a_width, storage_class_t a_storclass,
+           form_bitness_t a_bitness)
   : _m_name (a_name)
   , _m_classes (a_classes)
   , _m_width (a_width)
   , _m_storclass (a_storclass)
+  , _m_bitness (a_bitness)
 {}
 
 dw_class
index c8a0e6a31f0c52f5e007b78adc150f048addc8e8..f7a1df5d7532207e477dcb00685cf70ddd59ebe6 100644 (file)
@@ -85,19 +85,29 @@ enum storage_class_t
     sc_string,
   };
 
+enum form_bitness_t
+  {
+    fb_any, ///< Form is allowed in all CUs
+    fb_32,  ///< Form is allowed only in 32-bit CUs
+    fb_64,  ///< Form is allowed only in 64-bit CUs
+  };
+
 class form
 {
   int const _m_name;
   dw_class_set const _m_classes;
   int const _m_width;
   storage_class_t const _m_storclass;
+  form_bitness_t _m_bitness;
 
 public:
-  form (int a_name, dw_class_set a_classes,
-       form_width_t a_width, storage_class_t a_storclass);
+  form (int name, dw_class_set classes,
+       form_width_t width, storage_class_t storclass,
+       form_bitness_t bitness = fb_any);
 
-  form (int a_name, dw_class_set a_classes,
-       form_width_special_t a_width, storage_class_t a_storclass);
+  form (int name, dw_class_set classes,
+       form_width_special_t width, storage_class_t storclass,
+       form_bitness_t bitness = fb_any);
 
   int
   name () const
@@ -131,6 +141,12 @@ public:
   {
     return _m_storclass;
   }
+
+  form_bitness_t
+  bitness () const
+  {
+    return _m_bitness;
+  }
 };
 std::ostream &operator << (std::ostream &os, form const &obj);