From 9277c30c29f32ebee42e9e390a08bfac64d1ee67 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Fri, 4 Feb 2011 18:13:25 +0000 Subject: [PATCH] * dwarf2read.c (dwarf2_ranges_read): Skip empty range entries. Complain about inverted range entries. (dwarf2_record_block_ranges): Likewise. --- gdb/ChangeLog | 6 ++++++ gdb/dwarf2read.c | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 95ab56383b..9622483182 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2011-02-04 Ulrich Weigand + + * dwarf2read.c (dwarf2_ranges_read): Skip empty range entries. + Complain about inverted range entries. + (dwarf2_record_block_ranges): Likewise. + 2011-02-04 Thiago Jung Bauermann Fix some typos. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 6a98d57bcc..bc43bd8eb1 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -5863,10 +5863,22 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, return 0; } + if (range_beginning > range_end) + { + /* Inverted range entries are invalid. */ + complaint (&symfile_complaints, + _("Invalid .debug_ranges data (inverted range)")); + return 0; + } + + /* Empty range entries have no effect. */ + if (range_beginning == range_end) + continue; + range_beginning += base; range_end += base; - if (ranges_pst != NULL && range_beginning < range_end) + if (ranges_pst != NULL) addrmap_set_empty (objfile->psymtabs_addrmap, range_beginning + baseaddr, range_end - 1 + baseaddr, @@ -6149,6 +6161,19 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block, return; } + if (start > end) + { + /* Inverted range entries are invalid. */ + complaint (&symfile_complaints, + _("Invalid .debug_ranges data " + "(inverted range)")); + return; + } + + /* Empty range entries have no effect. */ + if (start == end) + continue; + record_block_range (block, baseaddr + base + start, baseaddr + base + end - 1);