struct dwarf_gnu_ext_t
: public std_dwarf
{
- dwarf_gnu_ext_t ()
- : std_dwarf (dwarf_gnu_attributes (), form_table ())
- {}
+ unsigned _m_version;
- virtual bool
+ dwarf_gnu_ext_t (unsigned version)
+ : std_dwarf (dwarf_gnu_attributes (), form_table ()),
+ _m_version (version)
+ { }
+
+ 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 (_m_version == 2 && 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
}
dwarf_version const *
-dwarf_gnu_ext ()
+dwarf_gnu_ext (unsigned version)
{
- static dwarf_gnu_ext_t dw;
+ static dwarf_gnu_ext_t dw (version);
return &dw;
}
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));
+ }
};
}
namespace
{
- dwarf_version const *get_ext ()
+ dwarf_version const *get_ext (unsigned version)
{
// xxx The GNU toolchain commonly uses DW_AT_MIPS_linkage_name,
// which is part of the MIPS extensions. So that's what we
if (opt_nognu)
return dwarf_mips_ext ();
else
- return dwarf_version::extend (dwarf_mips_ext (), dwarf_gnu_ext ());
+ return dwarf_version::extend (dwarf_mips_ext (),
+ dwarf_gnu_ext (version));
}
}
dwarf_version const *
dwarf_version::get (unsigned version)
{
- static dwarf_version const *ext = get_ext ();
-
switch (version)
{
case 2:
{
+ static dwarf_version const *ext = get_ext (2);
static dwarf_version const *dw = extend (dwarf_2 (), ext);
return dw;
}
case 3:
{
+ static dwarf_version const *ext = get_ext (3);
static dwarf_version const *dw = extend (dwarf_3 (), ext);
return dw;
}
case 4:
{
+ static dwarf_version const *ext = get_ext (4);
static dwarf_version const *dw = extend (dwarf_4 (), ext);
return dw;
}