diff options
author | Alan Modra <amodra@gmail.com> | 2015-07-24 14:36:38 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-07-24 14:48:35 +0930 |
commit | 2fb9328d8daa751f3b71745636323eddccaaacce (patch) | |
tree | 7b6999ce51cd5262e260d667f6a07b625b7555f3 | |
parent | f0b0791b05ed335e5d74d843d828645805db1f9c (diff) | |
download | gdb-2fb9328d8daa751f3b71745636323eddccaaacce.zip gdb-2fb9328d8daa751f3b71745636323eddccaaacce.tar.gz gdb-2fb9328d8daa751f3b71745636323eddccaaacce.tar.bz2 |
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.
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/section.c | 13 |
2 files changed, 10 insertions, 8 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9db32ed..6a29b7a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -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> * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections) diff --git a/bfd/section.c b/bfd/section.c index 6af174a..aa652a4 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; } |