When running the internal AdaCore test suite against the new DWARF
indexer, I found one regression on RISC-V. The test in question uses
--gc-sections, and winds up with an entry in the middle of a
.debug_aranges that has both address and length of 0. In this
scenario, gdb assumes the entries are terminated and then proceeds to
reject the section because it reads a subsequent entry as if it were a
header.
It seems to me that, because each header describes the size of each
.debug_aranges CU, it's better to simply ignore 0,0 entries and simply
read to the end. That is what this patch does.
I've patched an existing test to provide a regression test for this.
bytes. */
addr += (entry_end - addr) % (2 * address_size);
- for (;;)
+ while (addr < entry_end)
{
if (addr + 2 * address_size > entry_end)
{
dwarf5_byte_order);
addr += address_size;
if (start == 0 && length == 0)
- break;
+ {
+ /* This can happen on some targets with --gc-sections.
+ This pair of values is also used to mark the end of
+ the entries for a given CU, but we ignore it and
+ instead handle termination using the check at the top
+ of the loop. */
+ continue;
+ }
if (start == 0 && !per_bfd->has_section_at_zero)
{
/* Symbol was eliminated due to a COMDAT group. */
}
aranges {} cu_label {
+ # This 0,0 entry tests that the .debug_aranges reader can
+ # handle an apparent terminator before the end of the ranges.
+ arange {} 0 0
arange {} $foo_start $foo_end
arange {} $bar_start $bar_end
}