summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2011-03-07 17:30:15 +0100
committerPetr Machata <pmachata@redhat.com>2011-03-07 17:30:15 +0100
commit427f6c53451744b15dbac6a0a4a5d120053b1e56 (patch)
treebe1b0eba1b0978c5d03a5fe2cec44915f20929ca
parent43423ee7e421b01e23696692f8a30201cd1a3826 (diff)
downloadelfutils-427f6c53451744b15dbac6a0a4a5d120053b1e56.tar.gz
dwarflint: Fail low-level cases if toplevel CU DIE has wrong tag
-rw-r--r--dwarflint/check_debug_info.cc19
-rw-r--r--dwarflint/tests/garbage-2.bz2bin0 -> 2764 bytes
-rwxr-xr-xdwarflint/tests/run-bad.sh6
3 files changed, 20 insertions, 5 deletions
diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc
index c65ee832..6672c8c8 100644
--- a/dwarflint/check_debug_info.cc
+++ b/dwarflint/check_debug_info.cc
@@ -497,6 +497,8 @@ namespace
/*
Returns:
+ -2 in case of error that we have to note and return, but for now
+ we can carry on
-1 in case of error
+0 in case of no error, but the chain only consisted of a
terminating zero die.
@@ -522,6 +524,7 @@ namespace
struct abbrev *abbrev = NULL;
struct where where = WHERE (sec_info, NULL);
unsigned long die_count = 0;
+ int retval = 0;
struct value_check_cb_ctx cb_ctx = {
ctx, &where, cu,
@@ -622,9 +625,12 @@ namespace
<< "toplevel DIE chain contains more than one DIE."
<< std::endl;
else if (!is_cudie)
- wr_error (cu->head->where)
- << "toplevel DIE must be either compile_unit or partial_unit."
- << std::endl;
+ {
+ wr_error (cu->head->where)
+ << "toplevel DIE must be either compile_unit or partial_unit."
+ << std::endl;
+ retval = -2;
+ }
}
addr_record_add (&cu->die_addrs, cu->head->offset + die_off);
@@ -914,6 +920,8 @@ namespace
pc_coverage, need_rangesp, level + 1);
if (st == -1)
return -1;
+ else if (st == -2)
+ retval = -2;
else if (st == 0)
wr_message (mc_impact_3 | mc_acc_suboptimal | mc_die_rel,
&where,
@@ -926,7 +934,10 @@ namespace
<< "this DIE should have had its sibling at " << pri::hex (sibling_addr)
<< ", but the DIE chain ended." << std::endl;
- return got_die ? 1 : 0;
+ if (retval != 0)
+ return retval;
+ else
+ return got_die ? 1 : 0;
}
}
diff --git a/dwarflint/tests/garbage-2.bz2 b/dwarflint/tests/garbage-2.bz2
new file mode 100644
index 00000000..3cd56192
--- /dev/null
+++ b/dwarflint/tests/garbage-2.bz2
Binary files differ
diff --git a/dwarflint/tests/run-bad.sh b/dwarflint/tests/run-bad.sh
index 5dd64956..871fe551 100755
--- a/dwarflint/tests/run-bad.sh
+++ b/dwarflint/tests/run-bad.sh
@@ -27,7 +27,7 @@
srcdir=$srcdir/tests
-testfiles hello.bad-1 hello.bad-3 garbage-1
+testfiles hello.bad-1 hello.bad-3 garbage-1 garbage-2
testrun_compare ./dwarflint hello.bad-1 <<EOF
error: .debug_info: DIE 0x83: abbrev section at 0x0 doesn't contain code 83.
@@ -46,3 +46,7 @@ error: Broken ELF: offset out of range.
error: .debug_abbrev: data not found.
error: .debug_info: data not found.
EOF
+
+testrun_compare ./dwarflint garbage-2 <<EOF
+error: .debug_info: CU 0: toplevel DIE must be either compile_unit or partial_unit.
+EOF