diff options
| author | Petr Machata <[email protected]> | 2011-03-09 18:10:24 +0100 |
|---|---|---|
| committer | Petr Machata <[email protected]> | 2011-03-09 18:10:24 +0100 |
| commit | 2685aae8afcfac972861d295c41a1fbab2bcd6e3 (patch) | |
| tree | d35a9fa3013c2e727e548089b4a4c371c9f94026 /dwarflint | |
| parent | d40ba16a9b053647e71653a2d297bacb21eb44fa (diff) | |
dwarflint: Properly diagnose DW_AT_sibling with value of 0
Diffstat (limited to 'dwarflint')
| -rw-r--r-- | dwarflint/check_debug_info.cc | 19 | ||||
| -rw-r--r-- | dwarflint/tests/garbage-8.bz2 | bin | 0 -> 2753 bytes | |||
| -rwxr-xr-x | dwarflint/tests/run-bad.sh | 6 |
3 files changed, 23 insertions, 2 deletions
diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc index b712daab..7d7b293c 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 Binary files differnew file mode 100644 index 00000000..b9889832 --- /dev/null +++ b/dwarflint/tests/garbage-8.bz2 diff --git a/dwarflint/tests/run-bad.sh b/dwarflint/tests/run-bad.sh index 423e1f41..39fbdb5f 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 <<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 |
