diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9db32edea3b..6a29b7a439f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2015-07-24 Alan Modra + + * section.c (bfd_get_section_by_name_if): Iterate over entire hash + chain. + 2015-07-23 Joseph Myers * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections) diff --git a/bfd/section.c b/bfd/section.c index 6af174afa8b..aa652a41d79 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -994,14 +994,11 @@ bfd_get_section_by_name_if (bfd *abfd, const char *name, return NULL; hash = sh->root.hash; - do - { - if ((*operation) (abfd, &sh->section, user_storage)) - return &sh->section; - sh = (struct section_hash_entry *) sh->root.next; - } - while (sh != NULL && sh->root.hash == hash - && strcmp (sh->root.string, name) == 0); + for (; sh != NULL; sh = (struct section_hash_entry *) sh->root.next) + if (sh->root.hash == hash + && strcmp (sh->root.string, name) == 0 + && (*operation) (abfd, &sh->section, user_storage)) + return &sh->section; return NULL; }