]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Move read_size_extra to readctx module
authorPetr Machata <pmachata@redhat.com>
Tue, 21 Sep 2010 16:09:54 +0000 (18:09 +0200)
committerPetr Machata <pmachata@redhat.com>
Tue, 21 Sep 2010 16:09:54 +0000 (18:09 +0200)
dwarflint/low.c
dwarflint/low.h
dwarflint/readctx.c
dwarflint/readctx.h

index 9872d4aeff0cca5b50d522e97ffcdbf7b9b3e143..a5aafb5d423a0c39cab1e09125ce8245c2a25174 100644 (file)
@@ -134,35 +134,6 @@ cu_find_cu (struct cu *cu_chain, uint64_t offset)
   return NULL;
 }
 
-bool
-read_size_extra (struct read_ctx *ctx, uint32_t size32, uint64_t *sizep,
-                int *offset_sizep, struct where *wh)
-{
-  if (size32 == DWARF3_LENGTH_64_BIT)
-    {
-      if (!read_ctx_read_8ubyte (ctx, sizep))
-       {
-         wr_error (wh, ": can't read 64bit CU length.\n");
-         return false;
-       }
-
-      *offset_sizep = 8;
-    }
-  else if (size32 >= DWARF3_LENGTH_MIN_ESCAPE_CODE)
-    {
-      wr_error (wh, ": unrecognized CU length escape value: "
-               "%" PRIx32 ".\n", size32);
-      return false;
-    }
-  else
-    {
-      *sizep = size32;
-      *offset_sizep = 4;
-    }
-
-  return true;
-}
-
 bool
 check_zero_padding (struct read_ctx *ctx,
                    enum message_category category,
index 13f2a9f767d5460e11bced5ad20bf727140b3c50..16a74ac5bf5938afeb65663cf4d838e17b0482d6 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files.
-   Copyright (C) 2008,2009 Red Hat, Inc.
+   Copyright (C) 2008, 2009, 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
@@ -98,9 +98,6 @@ extern "C"
   extern bool address_aligned (uint64_t addr, uint64_t align);
   extern bool necessary_alignment (uint64_t start, uint64_t length,
                                   uint64_t align);
-  extern bool read_size_extra (struct read_ctx *ctx, uint32_t size32,
-                              uint64_t *sizep, int *offset_sizep,
-                              struct where *wh);
 #define PRI_NOT_ENOUGH ": not enough data for %s.\n"
   extern bool supported_version (unsigned version,
                                 size_t num_supported, struct where *where, ...);
index 20666fc8635fb4e6e5524ff5a3107dc9ab8e4364..20bda8d8fabb7d962d4a8137748597c378015563 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files.
-   Copyright (C) 2009 Red Hat, Inc.
+   Copyright (C) 2009, 2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Petr Machata <pmachata@redhat.com>, 2009.
 
 
 #include "readctx.h"
 #include "low.h"
+#include "../libdw/dwarf.h"
 
 #include <stdlib.h>
 #include <assert.h>
 #include <byteswap.h>
+#include <inttypes.h>
 
 /* read_Xubyte_* is basically cut'n'paste from memory-access.h.  */
 union unaligned
@@ -315,3 +317,32 @@ read_ctx_eof (struct read_ctx *ctx)
 {
   return !read_ctx_need_data (ctx, 1);
 }
+
+bool
+read_size_extra (struct read_ctx *ctx, uint32_t size32, uint64_t *sizep,
+                int *offset_sizep, struct where *wh)
+{
+  if (size32 == DWARF3_LENGTH_64_BIT)
+    {
+      if (!read_ctx_read_8ubyte (ctx, sizep))
+       {
+         wr_error (wh, ": can't read 64bit CU length.\n");
+         return false;
+       }
+
+      *offset_sizep = 8;
+    }
+  else if (size32 >= DWARF3_LENGTH_MIN_ESCAPE_CODE)
+    {
+      wr_error (wh, ": unrecognized CU length escape value: "
+               "%" PRIx32 ".\n", size32);
+      return false;
+    }
+  else
+    {
+      *sizep = size32;
+      *offset_sizep = 4;
+    }
+
+  return true;
+}
index 45afd4f10733fa115bf573fd18fa73552a4548c3..8f7b636427049ac90a3d0fde17e405765cbdbac5 100644 (file)
@@ -1,5 +1,5 @@
 /* Pedantic checking of DWARF files
-   Copyright (C) 2009,2010 Red Hat, Inc.
+   Copyright (C) 2009, 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
@@ -28,6 +28,7 @@
 
 #include <stdbool.h>
 #include "../libelf/libelf.h"
+#include "where.h"
 
 #ifdef __cplusplus
 extern "C"
@@ -68,12 +69,18 @@ bool read_ctx_read_2ubyte (struct read_ctx *ctx, uint16_t *ret);
 bool read_ctx_read_4ubyte (struct read_ctx *ctx, uint32_t *ret);
 bool read_ctx_read_8ubyte (struct read_ctx *ctx, uint64_t *ret);
 bool read_ctx_read_offset (struct read_ctx *ctx, bool dwarf64,
-                                 uint64_t *ret);
+                          uint64_t *ret);
 bool read_ctx_read_var (struct read_ctx *ctx, int width, uint64_t *ret);
 const char *read_ctx_read_str (struct read_ctx *ctx);
 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.  */
+
+bool read_size_extra (struct read_ctx *ctx, uint32_t size32,
+                     uint64_t *sizep, int *offset_sizep, struct where *wh);
+
 #ifdef __cplusplus
 }
 #endif