]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Const correctness, references in a couple places
authorPetr Machata <pmachata@redhat.com>
Mon, 30 Nov 2009 15:39:01 +0000 (16:39 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 18 Aug 2010 12:55:17 +0000 (14:55 +0200)
src/dwarflint/check_debug_info.cc
src/dwarflint/check_debug_info.hh
src/dwarflint/check_debug_loc_range.cc
src/dwarflint/check_debug_loc_range.hh
src/dwarflint/low.c
src/dwarflint/low.h
src/dwarflint/reloc.cc
src/dwarflint/reloc.h

index 0359145e87c3ac652546341938da7a3fa099f8e5..2c3601c0c46320c88a3a6638cd000feda7e65706 100644 (file)
@@ -420,7 +420,7 @@ namespace
   */
   int
   read_die_chain (dwarf_version_h ver,
-                 struct elf_file *file,
+                 elf_file const &file,
                  struct read_ctx *ctx,
                  struct cu *cu,
                  struct abbrev_table const *abbrevs,
@@ -578,7 +578,7 @@ namespace
            enum message_category extra_mc = mc_none;
 
            uint64_t ctx_offset = read_ctx_get_offset (ctx) + cu->head->offset;
-           bool type_is_rel = file->ehdr.e_type == ET_REL;
+           bool type_is_rel = file.ehdr.e_type == ET_REL;
 
            /* Attribute value.  */
            uint64_t value = 0;
@@ -862,7 +862,7 @@ namespace
                    << "unexpected relocation of " << pri::form (form) << '.'
                    << std::endl;
 
-               relocate_one (file, reloc, rel, width, &value, &where,
+               relocate_one (&file, reloc, rel, width, &value, &where,
                              reloc_target (form, it), symbolp);
 
                if (relocatedp != NULL)
@@ -920,7 +920,7 @@ namespace
                << std::endl;
            else
              check_range_relocations (mc_die_other, &where,
-                                      file,
+                                      &file,
                                       low_pc_symbol, high_pc_symbol,
                                       "DW_AT_low_pc and DW_AT_high_pc");
          }
@@ -951,14 +951,20 @@ namespace
   }
 }
 
+read_cu_headers::read_cu_headers (dwarflint &lint)
+  : _m_sec_info (lint.check (_m_sec_info))
+  , cu_headers (read_info_headers (&_m_sec_info->file,
+                                  &_m_sec_info->sect,
+                                  _m_sec_info->reldata ()))
+{
+}
+
 bool
-check_debug_info::check_cu_structural (struct elf_file *file,
-                                      struct read_ctx *ctx,
+check_debug_info::check_cu_structural (struct read_ctx *ctx,
                                       struct cu *const cu,
                                       Elf_Data *strings,
                                       struct coverage *strings_coverage,
-                                      struct relocation_data *reloc,
-                                      struct cu_coverage *cu_coverage)
+                                      struct relocation_data *reloc)
 {
   check_debug_abbrev::abbrev_map const &abbrev_tables = _m_abbrevs->abbrevs;
 
@@ -986,10 +992,10 @@ check_debug_info::check_cu_structural (struct elf_file *file,
   WIPE (local_die_refs);
 
   cu->cudie_offset = read_ctx_get_offset (ctx) + cu->head->offset;
-  if (read_die_chain (ver, file, ctx, cu, &abbrevs, strings,
+  if (read_die_chain (ver, _m_file, ctx, cu, &abbrevs, strings,
                      &local_die_refs, strings_coverage,
                      (reloc != NULL && reloc->size > 0) ? reloc : NULL,
-                     cu_coverage) < 0)
+                     &cu_cov) < 0)
     {
       _m_abbr_skip.push_back (abbrevs.offset);
       retval = false;
@@ -1001,20 +1007,13 @@ check_debug_info::check_cu_structural (struct elf_file *file,
   return retval;
 }
 
-read_cu_headers::read_cu_headers (dwarflint &lint)
-  : _m_sec_info (lint.check (_m_sec_info))
-  , cu_headers (read_info_headers (&_m_sec_info->file,
-                                  &_m_sec_info->sect,
-                                  _m_sec_info->reldata ()))
-{
-}
-
 void
-check_debug_info::check_info_structural (struct elf_file *file,
-                                        Elf_Data *strings)
+check_debug_info::check_info_structural ()
 {
   std::vector <cu_head> const &cu_headers = _m_cu_headers->cu_headers;
   sec &sec = _m_sec_info->sect;
+  Elf_Data *const strings = _m_sec_str->sect.data;
+
   struct ref_record die_refs;
   WIPE (die_refs);
 
@@ -1032,7 +1031,7 @@ check_debug_info::check_info_structural (struct elf_file *file,
     relocation_reset (reloc);
 
   struct read_ctx ctx;
-  read_ctx_init (&ctx, sec.data, file->other_byte_order);
+  read_ctx_init (&ctx, sec.data, _m_file.other_byte_order);
   for (std::vector <cu_head>::const_iterator it = cu_headers.begin ();
        it != cu_headers.end (); ++it)
     {
@@ -1057,9 +1056,8 @@ check_debug_info::check_info_structural (struct elf_file *file,
       read_ctx_init_sub (&cu_ctx, &ctx, ctx.ptr, cu_end);
       cu_ctx.ptr += head.head_size;
 
-      if (!check_cu_structural (file, &cu_ctx, &cur,
-                               strings, strings_coverage, reloc,
-                               &cu_cov))
+      if (!check_cu_structural (&cu_ctx, &cur,
+                               strings, strings_coverage, reloc))
        {
          success = false;
          break;
@@ -1145,11 +1143,12 @@ check_debug_info::check_debug_info (dwarflint &lint)
   : _m_sec_info (lint.check (_m_sec_info))
   , _m_sec_abbrev (lint.check (_m_sec_abbrev))
   , _m_sec_str (lint.check (_m_sec_str))
+  , _m_file (_m_sec_info->file)
   , _m_abbrevs (lint.check (_m_abbrevs))
   , _m_cu_headers (lint.check (_m_cu_headers))
 {
   memset (&cu_cov, 0, sizeof (cu_cov));
-  check_info_structural (&_m_sec_info->file, _m_sec_str->sect.data);
+  check_info_structural ();
 
   // re-link CUs so that they form a chain again.  This is to
   // interface with C-level code.  The last CU's next is NULL, so we
index 709f76c8732f50f513dc96428821be243db7902c..844bc5381e311e64053688e4dacd57cb09f4261d 100644 (file)
@@ -47,6 +47,7 @@ class check_debug_info
   section<sec_info> *_m_sec_info;
   section<sec_abbrev> *_m_sec_abbrev;
   section<sec_str> *_m_sec_str;
+  elf_file const &_m_file;
   check_debug_abbrev *_m_abbrevs;
   read_cu_headers *_m_cu_headers;
 
@@ -54,16 +55,13 @@ class check_debug_info
   // validation.  Check for unused abbrevs should be skipped.
   std::vector< ::Dwarf_Off> _m_abbr_skip;
 
-  bool check_cu_structural (struct elf_file *file,
-                           struct read_ctx *ctx,
+  bool check_cu_structural (struct read_ctx *ctx,
                            struct cu *const cu,
                            Elf_Data *strings,
                            struct coverage *strings_coverage,
-                           struct relocation_data *reloc,
-                           struct cu_coverage *cu_coverage);
+                           struct relocation_data *reloc);
 
-  void check_info_structural (elf_file *file,
-                             Elf_Data *strings);
+  void check_info_structural ();
 
 public:
   // The check pass adds all low_pc/high_pc ranges loaded from DIE
index 23ccdbaecf418eada760c6e5cc550064c31e4974..797bf1754d06b3a4f8cc3636afa7c6fab37ee8ad 100644 (file)
@@ -491,13 +491,15 @@ namespace
 
                if (!read_ctx_read_2ubyte (&ctx, &len))
                  {
-                   wr_error (&where, ": can't read length of location expression.\n");
+                   wr_error (where)
+                     << "can't read length of location expression."
+                     << std::endl;
                    return false;
                  }
 
                /* location expression itself */
                uint64_t expr_start = read_ctx_get_offset (&ctx);
-               if (!check_location_expression (file, &ctx, cu, expr_start,
+               if (!check_location_expression (*file, &ctx, cu, expr_start,
                                                &sec->rel, len, &where))
                  return false;
                uint64_t expr_end = read_ctx_get_offset (&ctx);
@@ -821,7 +823,7 @@ namespace
   }
 
   bool
-  op_read_form (struct elf_file *file,
+  op_read_form (struct elf_file const &file,
                struct read_ctx *ctx,
                struct cu *cu,
                uint64_t init_off,
@@ -857,7 +859,7 @@ namespace
                                where, skip_mismatched)))
       {
        if (!isblock)
-         relocate_one (file, reloc, rel,
+         relocate_one (&file, reloc, rel,
                        cu->head->address_size, valuep, where,
                        reloc_target_loc (opcode), NULL);
        else
@@ -874,7 +876,7 @@ namespace
 }
 
 bool
-check_location_expression (struct elf_file *file,
+check_location_expression (elf_file const &file,
                           struct read_ctx *parent_ctx,
                           struct cu *cu,
                           uint64_t init_off,
index 9a31c764b9010908b116d9f97b4a04d9675694d7..086c455e0881ac46561a1b169f01de84ef7e5a87 100644 (file)
@@ -59,7 +59,7 @@ struct hole_info
    DATA->data has to point at d_buf of section in question.  */
 extern bool found_hole (uint64_t start, uint64_t length, void *data);
 
-extern bool check_location_expression (struct elf_file *file,
+extern bool check_location_expression (elf_file const &file,
                                       struct read_ctx *parent_ctx,
                                       struct cu *cu,
                                       uint64_t init_off,
index d83676c961e857229f75ea41243ac7e193102dbd..a4b0fc59cc2ca6d9e45d5d466f85392d59a284fa 100644 (file)
@@ -213,7 +213,7 @@ supported_version (unsigned version,
 void
 check_range_relocations (enum message_category cat,
                         struct where *where,
-                        struct elf_file *file,
+                        struct elf_file const *file,
                         GElf_Sym *begin_symbol,
                         GElf_Sym *end_symbol,
                         const char *description)
index f15df275fabf2de62915da43ca43250a03ccaac2..db46b98b81b0b33f2d051437c93ffc8f0fed896c 100644 (file)
@@ -154,7 +154,7 @@ extern "C"
                                     struct addr_record *line_tables);
   extern void check_range_relocations (enum message_category cat,
                                       struct where *where,
-                                      struct elf_file *file,
+                                      struct elf_file const *file,
                                       GElf_Sym *begin_symbol,
                                       GElf_Sym *end_symbol,
                                       const char *description);
index f58d268671a495ba2c54dfaea24a305c9d7b5200..7b7660f71c2f4c6f233e22ca87cc164b0281c0c3 100644 (file)
@@ -93,7 +93,7 @@ relocation_skip_rest (struct relocation_data *reloc,
    which case we failed or didn't get around to obtain the symbol from
    symbol table, or non-NULL, in which case the symbol was initialized.  */
 void
-relocate_one (struct elf_file *file,
+relocate_one (struct elf_file const *file,
              struct relocation_data *reloc,
              struct relocation *rel,
              unsigned width, uint64_t *value,
index ae5f8292fd87c0bff63b4ff7bca48c37028df617..42e4f0e549038db779577f1e70d31068147bb150 100644 (file)
@@ -84,7 +84,7 @@ extern "C"
   void relocation_skip_rest (struct relocation_data *reloc,
                             enum section_id id);
 
-  void relocate_one (struct elf_file *file,
+  void relocate_one (struct elf_file const *file,
                     struct relocation_data *reloc,
                     struct relocation *rel,
                     unsigned width, uint64_t *value,