]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Check references from .debug_info to .debug_line
authorPetr Machata <pmachata@redhat.com>
Wed, 4 Mar 2009 13:59:48 +0000 (14:59 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 4 Mar 2009 13:59:48 +0000 (14:59 +0100)
src/dwarflint.c

index ae8a074081658a66b7ca1f09c64079ad4eefc157..57e5dfe9721160c813d83cb6e44695a9e6d1a568 100644 (file)
@@ -2586,6 +2586,30 @@ reloc_target_loc (uint8_t opcode)
   return rel_value;
 }
 
+static bool
+supported_version (unsigned version,
+                  size_t num_supported, struct where *where, ...)
+{
+  bool retval = false;
+  va_list ap;
+  va_start (ap, where);
+  for (size_t i = 0; i < num_supported; ++i)
+    {
+      unsigned v = va_arg (ap, unsigned);
+      if (version == v)
+       {
+         retval = true;
+         break;
+       }
+    }
+  va_end (ap);
+
+  if (!retval)
+    wr_error (where, ": unsupported version %d.\n", version);
+
+  return retval;
+}
+
 /*
   Returns:
     -1 in case of error
@@ -3106,30 +3130,6 @@ read_die_chain (struct read_ctx *ctx,
   return got_die ? 1 : 0;
 }
 
-static bool
-supported_version (unsigned version,
-                  size_t num_supported, struct where *where, ...)
-{
-  bool retval = false;
-  va_list ap;
-  va_start (ap, where);
-  for (size_t i = 0; i < num_supported; ++i)
-    {
-      unsigned v = va_arg (ap, unsigned);
-      if (version == v)
-       {
-         retval = true;
-         break;
-       }
-    }
-  va_end (ap);
-
-  if (!retval)
-    wr_error (where, ": unsupported version %d.\n", version);
-
-  return retval;
-}
-
 static bool
 check_cu_structural (struct read_ctx *ctx,
                     struct cu *const cu,
@@ -4433,16 +4433,21 @@ read_rel (struct section_data *secdata, Elf_Data *reldata, bool elf_64)
 
 static bool
 check_line_structural (struct section_data *data,
-                      __attribute__ ((unused)) struct cu *cu_chain)
+                      struct cu *cu_chain)
 {
   struct read_ctx ctx;
   read_ctx_init (&ctx, data->file->dwarf, data->data);
   bool retval = true;
 
+  struct addr_record line_tables;
+  memset (&line_tables, 0, sizeof (line_tables));
+
   while (!read_ctx_eof (&ctx))
     {
       struct where where = WHERE_SECDATA (data, NULL);
-      where_reset_1 (&where, read_ctx_get_offset (&ctx));
+      uint64_t set_offset = read_ctx_get_offset (&ctx);
+      where_reset_1 (&where, set_offset);
+      addr_record_add (&line_tables, set_offset);
       const unsigned char *set_begin = ctx.ptr;
 
       /* Size.  */
@@ -4893,7 +4898,19 @@ check_line_structural (struct section_data *data,
     }
 
   if (retval)
-    relocation_skip_rest (data);
+    {
+      relocation_skip_rest (data);
+
+      for (struct cu *cu = cu_chain; cu != NULL; cu = cu->next)
+       for (size_t i = 0; i < cu->line_refs.size; ++i)
+         {
+           struct ref *ref = cu->line_refs.refs + i;
+           if (!addr_record_has_addr (&line_tables, ref->addr))
+             wr_error (&ref->who,
+                       ": unresolved reference to .debug_line table %#" PRIx64 ".\n",
+                       ref->addr);
+         }
+    }
 
   return retval;
 }