check_nodebug.cc \
check_range_out_of_scope.cc \
check_self_referential_die.cc \
+ check_linkage_external_die.cc \
locstats.cc \
lowlevel_checks.cc lowlevel_checks.hh \
\
--- /dev/null
+/* Check that every die that has a linkage_name is also external.
+ Copyright (C) 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
+ it under the terms of the GNU General Public License as published by the
+ Free Software Foundation; version 2 of the License.
+
+ Red Hat elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Red Hat elfutils; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+ Red Hat elfutils is an included package of the Open Invention Network.
+ An included package of the Open Invention Network is a package for which
+ Open Invention Network licensees cross-license their patents. No patent
+ license is granted, either expressly or impliedly, by designation as an
+ included package. Should you wish to participate in the Open Invention
+ Network licensing program, please visit www.openinventionnetwork.com
+ <http://www.openinventionnetwork.com>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "highlevel_check.hh"
+#include "../src/dwarfstrings.h"
+#include "all-dies-it.hh"
+#include "pri.hh"
+#include "messages.hh"
+#include <map>
+
+using elfutils::dwarf;
+
+namespace
+{
+ class check_linkage_external_die
+ : public highlevel_check<check_linkage_external_die>
+ {
+ public:
+ static checkdescriptor const *descriptor ()
+ {
+ static checkdescriptor cd
+ (checkdescriptor::create ("check_linkage_external_die")
+ .inherit<highlevel_check<check_linkage_external_die> > ()
+ .description (
+"Check that each DIE that has a linkage_name also has an external attribute.\n"
+ ));
+ return &cd;
+ }
+
+ explicit check_linkage_external_die (checkstack &stack, dwarflint &lint)
+ : highlevel_check<check_linkage_external_die> (stack, lint)
+ {
+ for (all_dies_iterator<dwarf> it = all_dies_iterator<dwarf> (dw);
+ it != all_dies_iterator<dwarf> (); ++it)
+ {
+ dwarf::debug_info_entry const &die = *it;
+ dwarf::debug_info_entry::attributes_type attrs = die.attributes ();
+ if ((attrs.find (DW_AT_linkage_name) != attrs.end ()
+ || attrs.find (DW_AT_MIPS_linkage_name) != attrs.end ())
+ && attrs.find (DW_AT_external) == attrs.end ())
+ {
+ wr_message (to_where (die),
+ mc_impact_3 | mc_acc_suboptimal | mc_die_other)
+ << elfutils::dwarf::tags::name (die.tag ())
+ << " has linkage_name attribute, but no external attribute."
+ << std::endl;
+ }
+ }
+ }
+ };
+
+ reg<check_linkage_external_die> reg;
+}
/* Pedantic checking of DWARF files.
- Copyright (C) 2009 Red Hat, Inc.
+ Copyright (C) 2009, 2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Petr Machata <pmachata@redhat.com>, 2009.
at_set_decl.insert (DW_AT_decl_file);
at_set_decl.insert (DW_AT_decl_line);
+ std::set <int> at_linkage_name;
+ at_linkage_name.insert (DW_AT_MIPS_linkage_name);
+ at_linkage_name.insert (DW_AT_linkage_name);
+
m_map [DW_TAG_access_declaration]
.optional (at_set_decl)
.optional (DW_AT_accessibility)
.optional (DW_AT_segment)
.optional (DW_AT_sibling)
.optional (DW_AT_visibility)
+ .optional (at_linkage_name)
;
m_map [DW_TAG_common_inclusion]
.optional (DW_AT_start_scope)
.optional (DW_AT_type)
.optional (DW_AT_visibility)
+ .optional (at_linkage_name)
;
m_map [DW_TAG_dwarf_procedure]
.optional (DW_AT_GNU_all_tail_call_sites)
.optional (DW_AT_GNU_all_call_sites)
.optional (DW_AT_GNU_all_source_call_sites)
+ .optional (at_linkage_name)
;
m_map [DW_TAG_enumeration_type]
.optional (DW_AT_sibling)
;
+ // At one time gcc did emit at_linkage_name for members, but that
+ // has been corrected:
+ // http://gcc.gnu.org/ml/gcc-patches/2010-06/msg01713.html
m_map [DW_TAG_member]
.optional (at_set_decl)
.optional (DW_AT_accessibility)
.optional (DW_AT_sibling)
.optional (DW_AT_type)
.optional (DW_AT_visibility)
- .optional (DW_AT_MIPS_linkage_name) // xxx
- .optional (DW_AT_external) // xxx
- .optional (DW_AT_const_value) // xxx
- .optional (DW_AT_artificial) // xxx
;
m_map [DW_TAG_module]
.optional (DW_AT_visibility)
.optional (DW_AT_virtuality)
.optional (DW_AT_vtable_elem_location)
- .optional (DW_AT_MIPS_linkage_name) // XXX added to reflect reality
+ .optional (at_linkage_name)
.optional (DW_AT_containing_type) // XXX added to reflect reality
.optional (DW_AT_GNU_all_tail_call_sites)
.optional (DW_AT_GNU_all_call_sites)
.optional (DW_AT_start_scope)
.optional (DW_AT_type)
.optional (DW_AT_visibility)
- .optional (DW_AT_MIPS_linkage_name) // XXX added to reflect reality
+ .optional (at_linkage_name)
.optional (DW_AT_artificial) // XXX added to reflect reality
;