]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Move secinfo_map initiazitaion into ctor, avoid macros
authorPetr Machata <pmachata@redhat.com>
Tue, 14 Sep 2010 12:34:11 +0000 (14:34 +0200)
committerPetr Machata <pmachata@redhat.com>
Tue, 14 Sep 2010 12:34:11 +0000 (14:34 +0200)
- and reindent two statements below where it's instantiated
- and add a documentation to the section_name array

dwarflint/section_id.h
dwarflint/sections.cc

index 2687d6175d6daafe832fe148b6107a6fecdcc464..1fe74b0208c922e6bf4c7f18b143872927741c31 100644 (file)
@@ -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
index 6b49044077a36c6f2f109528169f3281f1fa0e40..91ecaac112f1ab8054701b64e54aba7b63bebd18 100644 (file)
@@ -201,6 +201,13 @@ namespace
   struct secinfo_map
     : public std::map <std::string, secentry>
   {
+    secinfo_map ()
+    {
+      // 0 is invalid section
+      for (unsigned i = 1; i < count_debuginfo_sections; ++i)
+       (*this)[section_name[i]] = secentry (static_cast<section_id> (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;