]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Properly diagnose DW_AT_sibling with value of 0
authorPetr Machata <pmachata@redhat.com>
Wed, 9 Mar 2011 17:10:24 +0000 (18:10 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 9 Mar 2011 17:10:24 +0000 (18:10 +0100)
dwarflint/check_debug_info.cc
dwarflint/tests/garbage-8.bz2 [new file with mode: 0644]
dwarflint/tests/run-bad.sh

index b712daab2de2c4767a9a2d2011b9e06daaea2c07..7d7b293c57102f0c277b388c99e1150be0ca0362 100644 (file)
@@ -507,6 +507,21 @@ namespace
     ref_record_add (&ctx->cu->decl_file_refs, value, ctx->where);
   }
 
+  /* The real sibling checking takes place down in read_die_chain.
+     Here we just make sure that the value is non-zero.  That value is
+     clearly invalid, and we use it to mark absent DW_AT_sibling.  */
+  void
+  check_sibling_non0 (uint64_t addr, struct value_check_cb_ctx const *ctx)
+  {
+    if (addr == 0)
+      {
+       wr_error (*ctx->where)
+         << "DW_AT_sibling with a value of 0." << std::endl;
+       // Don't let this up.
+       *ctx->retval_p = -2;
+      }
+  }
+
   /*
     Returns:
     -2 in case of error that we have to note and return, but for now
@@ -889,9 +904,11 @@ namespace
                   siblings.  */
                assert (value_check_cb == check_die_ref_local
                        || value_check_cb == check_die_ref_global);
+               value_check_cb = check_sibling_non0;
                valuep = &sibling_addr;
              }
-           else if (value_check_cb != NULL)
+
+           if (value_check_cb != NULL)
              value_check_cb (value, &cb_ctx);
 
            /* Store the relocated value.  Note valuep may point to
diff --git a/dwarflint/tests/garbage-8.bz2 b/dwarflint/tests/garbage-8.bz2
new file mode 100644 (file)
index 0000000..b988983
Binary files /dev/null and b/dwarflint/tests/garbage-8.bz2 differ
index 423e1f4183bd56952c54a0948eaf1a417fc6f1d7..39fbdb5f4285e6dd72aa4e7de75523a0e216624f 100755 (executable)
@@ -28,7 +28,7 @@
 srcdir=$srcdir/tests
 
 testfiles hello.bad-1 hello.bad-3 garbage-1 garbage-2 garbage-3 garbage-4 \
-    garbage-5 garbage-6 garbage-7
+    garbage-5 garbage-6 garbage-7 garbage-8
 
 testrun_compare ./dwarflint hello.bad-1 <<EOF
 error: .debug_info: DIE 0x83: abbrev section at 0x0 doesn't contain code 83.
@@ -78,3 +78,7 @@ error: .debug_abbrev: abbr. attribute 0x7e: invalid or unknown name 0x703.
 error: .debug_abbrev: abbr. attribute 0x7e: invalid form 0x0.
 error: .debug_abbrev: abbreviation 122: missing zero to mark end-of-table.
 EOF
+
+testrun_compare ./dwarflint garbage-8 <<EOF
+error: .debug_info: DIE 0x6c (abbr. attribute 0x43): DW_AT_sibling with a value of 0.
+EOF