+2019-05-28 Alan Modra <amodra@gmail.com>
+
+ PR 24596
+ * dwarf2.c (save_section_vma, section_vma_same): Check for NULL
+ end of section list as well as section_count.
+ * xcofflink.c (xcoff_link_add_symbols): Fix temporarily changed
+ section list before returning error.
+
2019-05-27 Alan Modra <amodra@gmail.com>
* elf.c (bfd_elf_set_group_contents): Exit on zero size section.
if (stash->sec_vma == NULL)
return FALSE;
stash->sec_vma_count = abfd->section_count;
- for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next)
+ for (i = 0, s = abfd->sections;
+ s != NULL && i < abfd->section_count;
+ i++, s = s->next)
{
if (s->output_section != NULL)
stash->sec_vma[i] = s->output_section->vma + s->output_offset;
if (abfd->section_count != stash->sec_vma_count)
return FALSE;
- for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next)
+ for (i = 0, s = abfd->sections;
+ s != NULL && i < abfd->section_count;
+ i++, s = s->next)
{
bfd_vma vma;
if (EXTERN_SYM_P (sym.n_sclass))
{
- bfd_boolean copy;
+ bfd_boolean copy, ok;
flagword flags;
BFD_ASSERT (section != NULL);
BFD_ASSERT (last_real->next == first_csect);
last_real->next = NULL;
flags = (sym.n_sclass == C_EXT ? BSF_GLOBAL : BSF_WEAK);
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, name, flags, section, value,
- NULL, copy, TRUE,
- (struct bfd_link_hash_entry **) sym_hash)))
- goto error_return;
+ ok = (_bfd_generic_link_add_one_symbol
+ (info, abfd, name, flags, section, value, NULL, copy, TRUE,
+ (struct bfd_link_hash_entry **) sym_hash));
last_real->next = first_csect;
+ if (!ok)
+ goto error_return;
if (smtyp == XTY_CM)
{