bfd_get_section_by_name_if hash chain traversal

This function stops too soon, as I found when the hash chain happened
to contain two .debug_macro sections and a .bss section:
.debug_macro -> .bss -> .debug_macro

	* section.c (bfd_get_section_by_name_if): Iterate over entire hash
	chain.
This commit is contained in:
Alan Modra
2015-07-24 14:36:38 +09:30
parent f0b0791b05
commit 2fb9328d8d
2 changed files with 10 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2015-07-24 Alan Modra <amodra@gmail.com>
* section.c (bfd_get_section_by_name_if): Iterate over entire hash
chain.
2015-07-23 Joseph Myers <joseph@codesourcery.com> 2015-07-23 Joseph Myers <joseph@codesourcery.com>
* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections) * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections)

View File

@ -994,14 +994,11 @@ bfd_get_section_by_name_if (bfd *abfd, const char *name,
return NULL; return NULL;
hash = sh->root.hash; hash = sh->root.hash;
do for (; sh != NULL; sh = (struct section_hash_entry *) sh->root.next)
{ if (sh->root.hash == hash
if ((*operation) (abfd, &sh->section, user_storage)) && strcmp (sh->root.string, name) == 0
return &sh->section; && (*operation) (abfd, &sh->section, user_storage))
sh = (struct section_hash_entry *) sh->root.next; return &sh->section;
}
while (sh != NULL && sh->root.hash == hash
&& strcmp (sh->root.string, name) == 0);
return NULL; return NULL;
} }