From: Petr Machata Date: Mon, 7 Mar 2011 16:30:15 +0000 (+0100) Subject: dwarflint: Fail low-level cases if toplevel CU DIE has wrong tag X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=427f6c53451744b15dbac6a0a4a5d120053b1e56;p=thirdparty%2Felfutils.git dwarflint: Fail low-level cases if toplevel CU DIE has wrong tag --- diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc index c65ee832a..6672c8c8d 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 000000000..3cd561926 Binary files /dev/null and b/dwarflint/tests/garbage-2.bz2 differ diff --git a/dwarflint/tests/run-bad.sh b/dwarflint/tests/run-bad.sh index 5dd649566..871fe551c 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 <