summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2011-02-23 21:52:44 +0100
committerPetr Machata <pmachata@redhat.com>2011-02-23 21:54:13 +0100
commit5982e1cc64499959e2e55458387fe1d4add24e15 (patch)
treebd612ea6856e6d819839c78d436a5b2a0660d238
parent92cf230319c6f079498b2912484ef074a5d84c07 (diff)
downloadelfutils-5982e1cc64499959e2e55458387fe1d4add24e15.tar.gz
dwarflint: Allow per-form configuration of CU bitness where form may appear
-rw-r--r--dwarflint/check_debug_info.cc16
-rw-r--r--dwarflint/dwarf_2.cc4
-rw-r--r--dwarflint/dwarf_version-imp.hh7
-rw-r--r--dwarflint/dwarf_version.cc8
-rw-r--r--dwarflint/dwarf_version.hh24
5 files changed, 42 insertions, 17 deletions
diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc
index a89d90d2..69d8fdd3 100644
--- a/dwarflint/check_debug_info.cc
+++ b/dwarflint/check_debug_info.cc
@@ -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)
diff --git a/dwarflint/dwarf_2.cc b/dwarflint/dwarf_2.cc
index c39eca6f..f3c23a24 100644
--- a/dwarflint/dwarf_2.cc
+++ b/dwarflint/dwarf_2.cc
@@ -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));
diff --git a/dwarflint/dwarf_version-imp.hh b/dwarflint/dwarf_version-imp.hh
index 4f00c7c8..10cbc616 100644
--- a/dwarflint/dwarf_version-imp.hh
+++ b/dwarflint/dwarf_version-imp.hh
@@ -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)
{}
};
diff --git a/dwarflint/dwarf_version.cc b/dwarflint/dwarf_version.cc
index e611a833..819f8106 100644
--- a/dwarflint/dwarf_version.cc
+++ b/dwarflint/dwarf_version.cc
@@ -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
diff --git a/dwarflint/dwarf_version.hh b/dwarflint/dwarf_version.hh
index c8a0e6a3..f7a1df5d 100644
--- a/dwarflint/dwarf_version.hh
+++ b/dwarflint/dwarf_version.hh
@@ -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);