From 60983b50de63e9278fcd906e954fc955e68b4f48 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Thu, 19 Aug 2010 17:08:14 +0200 Subject: [PATCH] dwarflint: Declare template "section" using an enum type * split out enum section_id to separate file to make this possible * also define section names there --- dwarflint/Makefile.am | 1 + dwarflint/section_id.cc | 36 ++++++++++++++++++++++++++++ dwarflint/section_id.h | 52 +++++++++++++++++++++++++++++++++++++++++ dwarflint/sections.hh | 2 +- dwarflint/sections.ii | 3 ++- dwarflint/where.h | 38 ++---------------------------- 6 files changed, 94 insertions(+), 38 deletions(-) create mode 100644 dwarflint/section_id.cc create mode 100644 dwarflint/section_id.h diff --git a/dwarflint/Makefile.am b/dwarflint/Makefile.am index a3bfed6bb..5056ec66a 100644 --- a/dwarflint/Makefile.am +++ b/dwarflint/Makefile.am @@ -45,6 +45,7 @@ dwarflint_SOURCES = main.cc \ readctx.c readctx.h \ pri.cc pri.hh \ messages.cc messages.h \ + section_id.cc section_id.h \ where.c where.h \ options.cc options.h \ addr-record.cc addr-record.h \ diff --git a/dwarflint/section_id.cc b/dwarflint/section_id.cc new file mode 100644 index 000000000..a9d28c699 --- /dev/null +++ b/dwarflint/section_id.cc @@ -0,0 +1,36 @@ +/* Pedantic checking of DWARF files + Copyright (C) 2010 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 + . */ + +#include "section_id.h" + +#include + +char const *section_name[] = { + "", +#define SEC(n) ".debug_"#n, + DEBUGINFO_SECTIONS + NULL +#undef SEC +}; diff --git a/dwarflint/section_id.h b/dwarflint/section_id.h new file mode 100644 index 000000000..dd7bd00fc --- /dev/null +++ b/dwarflint/section_id.h @@ -0,0 +1,52 @@ +#ifndef DWARFLINT_SECTION_ID_H +#define DWARFLINT_SECTION_ID_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define DEBUGINFO_SECTIONS \ + SEC (info) \ + SEC (abbrev) \ + SEC (aranges) \ + SEC (pubnames) \ + SEC (pubtypes) \ + SEC (str) \ + SEC (line) \ + SEC (loc) \ + SEC (mac) \ + SEC (ranges) + + enum section_id + { + sec_invalid = 0, + + /* Debuginfo sections: */ +#define SEC(n) sec_##n, + DEBUGINFO_SECTIONS + count_debuginfo_sections, +#undef SEC + + /* Non-debuginfo sections: */ + sec_rel = count_debuginfo_sections, + sec_rela, + + // XXX the following should really be split out to different enum + /* Non-sections: */ + sec_locexpr, /* Not a section, but a portion of file that + contains a location expression. */ + rel_value, /* For relocations, this denotes that the + relocation is applied to taget value, not a + section offset. */ + rel_address, /* Same as above, but for addresses. */ + rel_exec, /* Some as above, but we expect EXEC bit. */ + }; + + extern char const *section_name[]; + +#ifdef __cplusplus +} +#endif + +#endif//DWARFLINT_SECTION_ID_H diff --git a/dwarflint/sections.hh b/dwarflint/sections.hh index 3bd2c63da..e12621c3a 100644 --- a/dwarflint/sections.hh +++ b/dwarflint/sections.hh @@ -53,7 +53,7 @@ public: } }; -template +template class section : public section_base , public check > diff --git a/dwarflint/sections.ii b/dwarflint/sections.ii index 67f5e3f3f..bc726d440 100644 --- a/dwarflint/sections.ii +++ b/dwarflint/sections.ii @@ -1 +1,2 @@ -template class section; +#include "section_id.h" +template class section; diff --git a/dwarflint/where.h b/dwarflint/where.h index f8fd6c136..feefd0547 100644 --- a/dwarflint/where.h +++ b/dwarflint/where.h @@ -1,6 +1,8 @@ #ifndef DWARFLINT_WHERE_H #define DWARFLINT_WHERE_H +#include "section_id.h" + #include #include @@ -10,42 +12,6 @@ extern "C" { #endif -#define DEBUGINFO_SECTIONS \ - SEC (info) \ - SEC (abbrev) \ - SEC (aranges) \ - SEC (pubnames) \ - SEC (pubtypes) \ - SEC (str) \ - SEC (line) \ - SEC (loc) \ - SEC (mac) \ - SEC (ranges) - - enum section_id - { - sec_invalid = 0, - - /* Debuginfo sections: */ -#define SEC(n) sec_##n, - DEBUGINFO_SECTIONS - count_debuginfo_sections, -#undef SEC - - /* Non-debuginfo sections: */ - sec_rel = count_debuginfo_sections, - sec_rela, - - /* Non-sections: */ - sec_locexpr, /* Not a section, but a portion of file that - contains a location expression. */ - rel_value, /* For relocations, this denotes that the - relocation is applied to taget value, not a - section offset. */ - rel_address, /* Same as above, but for addresses. */ - rel_exec, /* Some as above, but we expect EXEC bit. */ - }; - enum where_formatting { wf_plain = 0, /* Default formatting for given section. */ -- 2.47.3