The code that faulted made the assumption that a group section always
had at least one valid member. Fix that assumption. Also fail if all
entries in a SHT_GROUP section are invalid. (An empty group will not
result in a call to process_sht_group_entries.)
PR 33473
* elflink.x (_bfd_elf_gc_mark_debug_special_section_group): Don't
segfault on empty group.
* elf.c (process_sht_group_entries): Return false if all
entries are invalid.
}
free (contents);
- return true;
+ return last_elt != NULL;
}
bool
/* First scan to see if group contains any section other than debug
and special section. */
ssec = msec = elf_next_in_group (grp);
- do
+ while (msec != NULL)
{
if ((msec->flags & SEC_DEBUGGING) == 0)
is_debug_grp = false;
is_special_grp = false;
msec = elf_next_in_group (msec);
+ if (msec == ssec)
+ break;
}
- while (msec != ssec);
/* If this is a pure debug section group or pure special section group,
keep all sections in this group. */
if (is_debug_grp || is_special_grp)
{
- do
+ msec = ssec;
+ while (msec != NULL)
{
msec->gc_mark = 1;
msec = elf_next_in_group (msec);
+ if (msec == ssec)
+ break;
}
- while (msec != ssec);
}
}