From 47c7d6998bc73f92c4768169cbc093f5eb29a798 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Tue, 14 Sep 2010 14:34:11 +0200 Subject: [PATCH] dwarflint: Move secinfo_map initiazitaion into ctor, avoid macros - and reindent two statements below where it's instantiated - and add a documentation to the section_name array --- dwarflint/section_id.h | 2 ++ dwarflint/sections.cc | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/dwarflint/section_id.h b/dwarflint/section_id.h index 2687d6175..1fe74b020 100644 --- a/dwarflint/section_id.h +++ b/dwarflint/section_id.h @@ -68,6 +68,8 @@ extern "C" rel_exec, /* Some as above, but we expect EXEC bit. */ }; + // section_name[0] is for sec_invalid. The last index is for + // count_debuginfo_sections and is NULL. extern char const *section_name[]; #ifdef __cplusplus diff --git a/dwarflint/sections.cc b/dwarflint/sections.cc index 6b4904407..91ecaac11 100644 --- a/dwarflint/sections.cc +++ b/dwarflint/sections.cc @@ -201,6 +201,13 @@ namespace struct secinfo_map : public std::map { + secinfo_map () + { + // 0 is invalid section + for (unsigned i = 1; i < count_debuginfo_sections; ++i) + (*this)[section_name[i]] = secentry (static_cast (i)); + } + secentry *get (const char *name) { iterator it = find (std::string (name)); @@ -235,17 +242,13 @@ namespace file->other_byte_order = true; Elf_Scn *reloc_symtab = NULL; - secinfo_map secinfo; -#define SEC(n) secinfo[".debug_" #n] = secentry (sec_##n); - DEBUGINFO_SECTIONS -#undef SEC - /* Now find all necessary debuginfo sections and associated - relocation sections. */ + /* Now find all necessary debuginfo sections and associated + relocation sections. */ - /* Section 0 is special, skip it. */ - REALLOC (file, sec); + /* Section 0 is special, skip it. */ + REALLOC (file, sec); file->sec[file->size++].id = sec_invalid; bool check_rel = true; -- 2.47.2