From 2fb9328d8daa751f3b71745636323eddccaaacce Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 24 Jul 2015 14:36:38 +0930 Subject: 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. --- bfd/section.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'bfd/section.c') 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; } -- cgit v1.2.1