This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [delayed-symfile] handle incorrect aranges

>>>>> "Jan" == Jan Kratochvil <> writes:

Jan> Could you please also fix the address_size == 0 problem bugreported
Jan> inside RH?  Testcase attached.


FWIW, I started with the original test case.  What happened there was
that the aranges reader stopped early, then treated some other bytes
from the middle of an aranges section as a new CU header.  This is how
we ended up with address_size==0.  If you 'readelf' the original
binaries you'll see there is nothing wrong except that bogus (0,0)

I'm checking in the appended.  It adds a check for the zero address
size, and it also adds a check that the length of an entry is non-zero,
a constraint mentioned in the DWARF standard (and which, I think,
addrmap probably does not handle well).

Finally, this patch fixes a small bug when computing the end of the
range.  addrmap uses end-inclusive, so we have to subtract one.

Jan> Testcase approval for [delayed-symfile] requested.

Yes, thank you very much.

I'll wait until you push before committing, so I can test against your
test case.


2009-08-14  Tom Tromey  <>

	* dwarf2read.c (dwarf2_create_quick_addrmap): Ignore zero
	addr_size and entries with zero length.  Properly compute end of

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 2272259..4bae7cb 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1436,6 +1436,13 @@ dwarf2_create_quick_addrmap (struct objfile *objfile)
 		     _("aranges entry runs off end of `.debug_aranges' section, ignored"));
+      if (cu_header.addr_size == 0)
+	{
+	  do_cleanups (old);
+	  complaint (&symfile_complaints,
+		     _("aranges entry has zero addr_size, ignored"));
+	  return;
+	}
       segment_size = read_1_byte (abfd, aranges_ptr);
       aranges_ptr += 1;
@@ -1462,9 +1469,18 @@ dwarf2_create_quick_addrmap (struct objfile *objfile)
 	  if (address == 0 && length == 0)
+	  if (length == 0)
+	    {
+	      do_cleanups (old);
+	      complaint (&symfile_complaints,
+			 _("aranges entry has zero length, ignored"));
+	      return;
+	    }
 	  address += baseaddr;
-	  addrmap_set_empty (mutable_map, address, address + length, objfile);
+	  addrmap_set_empty (mutable_map, address, address + length - 1,
+			     objfile);
       /* Some older versions of GCC incorrectly started the arange

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]