]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Move read_address_size to read_ctx module
authorPetr Machata <pmachata@redhat.com>
Tue, 21 Sep 2010 16:41:13 +0000 (18:41 +0200)
committerPetr Machata <pmachata@redhat.com>
Tue, 21 Sep 2010 16:41:13 +0000 (18:41 +0200)
- and shuffle arguments around so it makes sense

dwarflint/check_debug_info.cc
dwarflint/low.c
dwarflint/low.h
dwarflint/readctx.c
dwarflint/readctx.h

index d99fdadb29a0b3b43d55d4782e3d38c317f2f1ab..77515328a4fb4b88727b566306e4a6bfda1763f7 100644 (file)
@@ -263,7 +263,7 @@ namespace
            << pri::lacks_relocation ("abbrev table offset") << std::endl;
 
        /* Address size.  */
-       if (!read_address_size (file->addr_64, &ctx, &head.address_size,
+       if (!read_address_size (&ctx, file->addr_64, &head.address_size,
                                &head.where))
          throw check_base::failed ();
 
index a5aafb5d423a0c39cab1e09125ce8245c2a25174..945af7b44f29e73fb6edc42f30d0db8a027cb1b5 100644 (file)
@@ -196,38 +196,6 @@ check_range_relocations (enum message_category cat,
                file->sec[end_symbol->st_shndx].name);
 }
 
-bool
-read_address_size (bool elf_64,
-                  struct read_ctx *ctx,
-                  int *address_sizep,
-                  struct where const *where)
-{
-  uint8_t address_size;
-  if (!read_ctx_read_ubyte (ctx, &address_size))
-    {
-      wr_error (where, ": can't read address size.\n");
-      return false;
-    }
-
-  if (address_size != 4 && address_size != 8)
-    {
-      /* Keep going.  Deduce the address size from ELF header, and try
-        to parse it anyway.  */
-      wr_error (where,
-               ": invalid address size: %d (only 4 or 8 allowed).\n",
-               address_size);
-      address_size = elf_64 ? 8 : 4;
-    }
-  else if ((address_size == 8) != elf_64)
-    /* Keep going, we may still be able to parse it.  */
-    wr_error (where,
-             ": CU reports address size of %d in %d-bit ELF.\n",
-             address_size, elf_64 ? 64 : 32);
-
-  *address_sizep = address_size;
-  return true;
-}
-
 static void
 compare_coverage (struct elf_file *file,
                  struct coverage *coverage, struct coverage *other,
@@ -389,7 +357,7 @@ check_aranges_structural (struct elf_file *file,
 
       /* Address size.  */
       int address_size;
-      if (!read_address_size (file->addr_64, &sub_ctx, &address_size, &where))
+      if (!read_address_size (&sub_ctx, file->addr_64, &address_size, &where))
        {
          retval = false;
          goto next;
index 16a74ac5bf5938afeb65663cf4d838e17b0482d6..309e13c171f077b031815034c5a9b07c644ab9cc 100644 (file)
@@ -104,10 +104,6 @@ extern "C"
   extern bool check_zero_padding (struct read_ctx *ctx,
                                  enum message_category category,
                                  struct where const *wh);
-  extern bool read_address_size (bool elf_64,
-                                struct read_ctx *ctx,
-                                int *address_sizep,
-                                struct where const *where);
 
   struct section_coverage
   {
index 20bda8d8fabb7d962d4a8137748597c378015563..a17bd5a5452e0d7a1d4e66294d59592aca9a966b 100644 (file)
@@ -320,13 +320,13 @@ read_ctx_eof (struct read_ctx *ctx)
 
 bool
 read_size_extra (struct read_ctx *ctx, uint32_t size32, uint64_t *sizep,
-                int *offset_sizep, struct where *wh)
+                int *offset_sizep, struct where *where)
 {
   if (size32 == DWARF3_LENGTH_64_BIT)
     {
       if (!read_ctx_read_8ubyte (ctx, sizep))
        {
-         wr_error (wh, ": can't read 64bit CU length.\n");
+         wr_error (where, ": can't read 64bit CU length.\n");
          return false;
        }
 
@@ -334,7 +334,7 @@ read_size_extra (struct read_ctx *ctx, uint32_t size32, uint64_t *sizep,
     }
   else if (size32 >= DWARF3_LENGTH_MIN_ESCAPE_CODE)
     {
-      wr_error (wh, ": unrecognized CU length escape value: "
+      wr_error (where, ": unrecognized CU length escape value: "
                "%" PRIx32 ".\n", size32);
       return false;
     }
@@ -346,3 +346,36 @@ read_size_extra (struct read_ctx *ctx, uint32_t size32, uint64_t *sizep,
 
   return true;
 }
+
+bool
+read_address_size (struct read_ctx *ctx,
+                  bool addr_64,
+                  int *address_sizep,
+                  struct where const *where)
+{
+  uint8_t address_size;
+  if (!read_ctx_read_ubyte (ctx, &address_size))
+    {
+      wr_error (where, ": can't read address size.\n");
+      return false;
+    }
+
+  if (address_size != 4 && address_size != 8)
+    {
+      /* Keep going.  Deduce the address size from ELF header, and try
+        to parse it anyway.  */
+      wr_error (where,
+               ": invalid address size: %d (only 4 or 8 allowed).\n",
+               address_size);
+      address_size = addr_64 ? 8 : 4;
+    }
+  else if ((address_size == 8) != addr_64)
+    /* Keep going, we may still be able to parse it.  */
+    wr_error (where,
+             ": CU reports address size of %d in %d-bit ELF.\n",
+             address_size, addr_64 ? 64 : 32);
+
+  *address_sizep = address_size;
+  return true;
+}
+
index 8f7b636427049ac90a3d0fde17e405765cbdbac5..d6f94bf8eb552419f7d82bf9164d817843dd7ea2 100644 (file)
@@ -76,10 +76,16 @@ bool read_ctx_skip (struct read_ctx *ctx, uint64_t len);
 bool read_ctx_eof (struct read_ctx *ctx);
 
 /* The following procedures build on the ones above and do their own
-   error reporting.  */
+   error reporting in addition.  */
 
 bool read_size_extra (struct read_ctx *ctx, uint32_t size32,
-                     uint64_t *sizep, int *offset_sizep, struct where *wh);
+                     uint64_t *sizep, int *offset_sizep,
+                     struct where *where);
+
+bool read_address_size (struct read_ctx *ctx,
+                       bool addr_64,
+                       int *address_sizep,
+                       struct where const *where);
 
 #ifdef __cplusplus
 }