diff options
Diffstat (limited to 'bfd/xcofflink.c')
-rw-r--r-- | bfd/xcofflink.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index c055b26..d3e9043 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -2292,8 +2292,8 @@ xcoff_link_check_dynamic_ar_symbols (bfd *abfd, && (((struct xcoff_link_hash_entry *) h)->flags & XCOFF_DEF_DYNAMIC) == 0) { - if (! (*info->callbacks->add_archive_element) - (info, abfd, name, subsbfd)) + if (!(*info->callbacks + ->add_archive_element) (info, abfd, name, subsbfd)) return FALSE; *pneeded = TRUE; return TRUE; @@ -2364,8 +2364,8 @@ xcoff_link_check_ar_symbols (bfd *abfd, || (((struct xcoff_link_hash_entry *) h)->flags & XCOFF_DEF_DYNAMIC) == 0)) { - if (! (*info->callbacks->add_archive_element) - (info, abfd, name, subsbfd)) + if (!(*info->callbacks + ->add_archive_element) (info, abfd, name, subsbfd)) return FALSE; *pneeded = TRUE; return TRUE; @@ -2390,22 +2390,30 @@ xcoff_link_check_archive_element (bfd *abfd, bfd_boolean *pneeded) { bfd_boolean keep_syms_p; - bfd *subsbfd = NULL; + bfd *oldbfd; keep_syms_p = (obj_coff_external_syms (abfd) != NULL); - if (! _bfd_coff_get_external_symbols (abfd)) + if (!_bfd_coff_get_external_symbols (abfd)) return FALSE; - if (! xcoff_link_check_ar_symbols (abfd, info, pneeded, &subsbfd)) + oldbfd = abfd; + if (!xcoff_link_check_ar_symbols (abfd, info, pneeded, &abfd)) return FALSE; if (*pneeded) { /* Potentially, the add_archive_element hook may have set a substitute BFD for us. */ - if (subsbfd && !_bfd_coff_get_external_symbols (subsbfd)) - return FALSE; - if (! xcoff_link_add_symbols (subsbfd ? subsbfd : abfd, info)) + if (abfd != oldbfd) + { + if (!keep_syms_p + && !_bfd_coff_free_symbols (oldbfd)) + return FALSE; + keep_syms_p = (obj_coff_external_syms (abfd) != NULL); + if (!_bfd_coff_get_external_symbols (abfd)) + return FALSE; + } + if (!xcoff_link_add_symbols (abfd, info)) return FALSE; if (info->keep_memory) keep_syms_p = TRUE; @@ -2413,7 +2421,7 @@ xcoff_link_check_archive_element (bfd *abfd, if (!keep_syms_p) { - if (! _bfd_coff_free_symbols (abfd)) + if (!_bfd_coff_free_symbols (abfd)) return FALSE; } |