diff mbox

[rfc] Skip empty range entries in DW_AT_ranges

Message ID 201103041640.p24Ge8FW007308@d06av02.portsmouth.uk.ibm.com
State Accepted
Headers show

Commit Message

Ulrich Weigand March 4, 2011, 4:40 p.m. UTC
http://sourceware.org/ml/gdb-patches/2011-02/msg00048.html


ChangeLog:

	* dwarf2read.c (dwarf2_ranges_read): Skip empty range entries.
	Complain about inverted range entries.
	(dwarf2_record_block_ranges): Likewise.
diff mbox

Patch

Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.496
diff -u -p -r1.496 dwarf2read.c
--- gdb/dwarf2read.c	25 Jan 2011 17:25:12 -0000	1.496
+++ gdb/dwarf2read.c	3 Feb 2011 19:02:27 -0000
@@ -5863,10 +5863,22 @@  dwarf2_ranges_read (unsigned offset, COR
 	  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_i
                   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);