From: Mark Wielaard Date: Wed, 30 Mar 2011 10:44:14 +0000 (+0200) Subject: dwarflint: Allow DW_AT_ranges with const form, as gnu extension. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a8e81c3262c577a9209659ce5f683dcd1a069b1b;p=thirdparty%2Felfutils.git dwarflint: Allow DW_AT_ranges with const form, as gnu extension. 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. --- diff --git a/dwarflint/dwarf_gnu.cc b/dwarflint/dwarf_gnu.cc index 2d29f1184..52d0a492c 100644 --- a/dwarflint/dwarf_gnu.cc +++ b/dwarflint/dwarf_gnu.cc @@ -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 diff --git a/dwarflint/dwarf_version.cc b/dwarflint/dwarf_version.cc index a74e1699b..8a34ef0e7 100644 --- a/dwarflint/dwarf_version.cc +++ b/dwarflint/dwarf_version.cc @@ -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)); + } }; }