]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Allow DW_AT_ranges with const form, as gnu extension.
authorMark Wielaard <mjw@redhat.com>
Wed, 30 Mar 2011 10:44:14 +0000 (12:44 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 4 Apr 2011 14:09:56 +0000 (16:09 +0200)
Without -gstrict-dwarf gcc allows usage of attributes from
later versions. One strange case is DW_AT_ranges in version 2
since that version doesn't actually define a rangelistptr
class. This case is added in the form_allowed override for dwarf_gnu.
In gnu mode dwarf_version_union::form_allowed checks both variants,
source and extension, in no-gnu mode, only the latest is allowed.

dwarflint/dwarf_gnu.cc
dwarflint/dwarf_version.cc

index 2d29f118405af8bd3fdec336d066787c0da45916..52d0a492ca837f8ad998bb3776388606ce4d6d76 100644 (file)
@@ -94,6 +94,17 @@ namespace
     virtual bool
     form_allowed (attribute const *attr, form const *form) const
     {
+      // Without -gstrict-dwarf gcc allows usage of attributes from
+      // later versions. One strange case is DW_AT_ranges in version 2
+      // since that version doesn't actually define a rangelistptr
+      // class. So we just allow data4 or data8 here.
+      if (attr->name () == DW_AT_ranges)
+       {
+         form_width_t width = form->width (NULL);
+         return (form->classes ()[cl_constant]
+                 && (width == fw_4 || width == fw_8));
+       }
+
       if (attr->name () == DW_AT_GNU_odr_signature)
        return form->classes ()[cl_constant] && form->width (NULL) == fw_8;
       else
index a74e1699b87c1f84ef34395b352a422510b52167..8a34ef0e7ae050f889b8f31e93d7d066ede64b7e 100644 (file)
@@ -219,6 +219,18 @@ namespace
        ret = _m_source->ambiguous_class (form, attribute, candidates);
       return ret;
     }
+
+    bool
+    form_allowed (attribute const *attr, form const *form) const
+    {
+      // In GNU mode any combination of new attribute/old form goes,
+      // in strict mode only the latest.
+      if (opt_nognu)
+       return _m_extension->form_allowed (attr, form);
+      else
+       return (_m_source->form_allowed (attr, form)
+               || _m_extension->form_allowed (attr, form));
+    }
   };
 }