This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: [delayed-symfile] handle incorrect aranges
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> Could you please also fix the address_size == 0 problem bugreported
Jan> inside RH? Testcase attached.
Sure.
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)
entry.
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.
Tom
2009-08-14 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (dwarf2_create_quick_addrmap): Ignore zero
addr_size and entries with zero length. Properly compute end of
range.
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"));
return;
}
+ 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)
break;
+ 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