From: Petr Machata Date: Wed, 9 Mar 2011 17:10:24 +0000 (+0100) Subject: dwarflint: Properly diagnose DW_AT_sibling with value of 0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2685aae8afcfac972861d295c41a1fbab2bcd6e3;p=thirdparty%2Felfutils.git dwarflint: Properly diagnose DW_AT_sibling with value of 0 --- diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc index b712daab2..7d7b293c5 100644 --- a/dwarflint/check_debug_info.cc +++ b/dwarflint/check_debug_info.cc @@ -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 index 000000000..b9889832a Binary files /dev/null and b/dwarflint/tests/garbage-8.bz2 differ diff --git a/dwarflint/tests/run-bad.sh b/dwarflint/tests/run-bad.sh index 423e1f418..39fbdb5f4 100755 --- a/dwarflint/tests/run-bad.sh +++ b/dwarflint/tests/run-bad.sh @@ -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 <