diff options
author | Nick Clifton <nickc@redhat.com> | 2018-04-18 12:03:03 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2018-04-18 12:03:03 +0100 |
commit | a7504f87d41694d441fabb3308631df4d2750c24 (patch) | |
tree | ae89ddf688dc34d25311bbc1b89a06e7e5544516 /binutils/dwarf.c | |
parent | 82deb12e5f96af0b767abf6ec83d5e95f408c8d0 (diff) | |
download | gdb-a7504f87d41694d441fabb3308631df4d2750c24.zip gdb-a7504f87d41694d441fabb3308631df4d2750c24.tar.gz gdb-a7504f87d41694d441fabb3308631df4d2750c24.tar.bz2 |
Prevent an assertion failure in readelf & objdump when parsing corrupt DWARF information.
PR 23062
* dwarf.c (read_and_display_attr_value): Replace assertions with
test and warning message.
Diffstat (limited to 'binutils/dwarf.c')
-rw-r--r-- | binutils/dwarf.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c index f94f5b2..cd3df7f 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -2174,19 +2174,28 @@ read_and_display_attr_value (unsigned long attribute, debug_info_p->have_frame_base [num] = have_frame_base; if (attribute != DW_AT_GNU_locviews) { - debug_info_p->loc_offsets [num] = uvalue; - debug_info_p->num_loc_offsets++; - assert (debug_info_p->num_loc_offsets - - debug_info_p->num_loc_views <= 1); + /* Corrupt DWARF info can produce more offsets than views. + See PR 23062 for an example. */ + if (debug_info_p->num_loc_offsets + > debug_info_p->num_loc_views) + warn (_("More location offset attributes than DW_AT_GNU_locview attributes\n")); + else + { + debug_info_p->loc_offsets [num] = uvalue; + debug_info_p->num_loc_offsets++; + } } else { assert (debug_info_p->num_loc_views <= num); num = debug_info_p->num_loc_views; - debug_info_p->loc_views [num] = uvalue; - debug_info_p->num_loc_views++; - assert (debug_info_p->num_loc_views - - debug_info_p->num_loc_offsets <= 1); + if (num > debug_info_p->num_loc_offsets) + warn (_("More DW_AT_GNU_locview attributes than location offset attributes\n")); + else + { + debug_info_p->loc_views [num] = uvalue; + debug_info_p->num_loc_views++; + } } } break; |