This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: dwarflint allow strange combinations of attribute/form in gnu mode
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Sun, 03 Apr 2011 16:25:36 +0200
- Subject: Re: dwarflint allow strange combinations of attribute/form in gnu mode
Hi,
On Wed, 2011-03-30 at 12:53 +0200, Mark Wielaard wrote:
> I came across a strange combination of new attribute with old form for
> gcc. When gcc isn't using -gstrict-dwarf, it allows attributes from
> newer versions, but doesn't use new forms, even if such an attribute
> would need that. So this patch allows that (in particular for
> DW_AT_ranges for dwarf2), but only in gnu mode. Does this look like a
> sane solution?
On irc Petr told me he didn't like the creeping of the version as state
into dwarf_gnu. So this simpler version, just allows it as gnu extension
in general. Petr, does this new patch look better?
The reason I would really like this to get resolved is because upstream
gcc defaults to non-strict dwarf-2 + gnu extensions, which will output
this form for the ranges attribute. Which results in low-level check
failure, so you cannot run any high-level check against such binaries.
Cheers,
Mark
diff --git a/dwarflint/dwarf_gnu.cc b/dwarflint/dwarf_gnu.cc
index b70a6d2..fa1a14b 100644
--- a/dwarflint/dwarf_gnu.cc
+++ b/dwarflint/dwarf_gnu.cc
@@ -93,6 +93,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 a74e169..8a34ef0 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));
+ }
};
}