From 0e144ba71eacb7e00bff43fc66b707bd7f029c44 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 13 Dec 2010 01:06:16 +0000 Subject: * aoutx.h (aout_link_check_ar_symbols): Formatting. * cofflink.c (coff_link_check_ar_symbols): Likewise. * elflink.c (elf_link_add_archive_symbols): Likewise. * pdp11.c (aout_link_check_ar_symbols): Likewise. * xcofflink.c (xcoff_link_check_dynamic_ar_symbols, xcoff_link_check_dynamic_ar_symbols): Likewise. * aoutx.h (aout_link_check_archive_element): Simplify code dealing with add_archive_element substitute BFD. * cofflink.c (coff_link_check_archive_element): Likewise. * ecoff.c (ecoff_link_check_archive_element): Likewise. (ecoff_link_add_archive_symbols): Likewise. * linker.c (generic_link_check_archive_element): Likewise. * pdp11.c (aout_link_check_archive_element): Likewise. * vms-alpha.c (alpha_vms_link_add_archive_symbols): Likewise. * xcofflink.c (xcoff_link_check_archive_element): Likewise. * aoutx.h (aout_link_check_archive_element): Free symbols from old bfd if !keep_memory. * cofflink.c (coff_link_check_archive_element): Likewise. * pdp11.c (aout_link_check_archive_element): Likewise. * xcofflink.c (xcoff_link_check_archive_element): Likewise. --- bfd/cofflink.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'bfd/cofflink.c') diff --git a/bfd/cofflink.c b/bfd/cofflink.c index a28d396..33de7fe 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -244,8 +244,8 @@ coff_link_check_ar_symbols (bfd *abfd, if (h != (struct bfd_link_hash_entry *) NULL && h->type == bfd_link_hash_undefined) { - 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; @@ -269,29 +269,38 @@ coff_link_check_archive_element (bfd *abfd, struct bfd_link_info *info, bfd_boolean *pneeded) { - bfd *subsbfd = NULL; + bfd *oldbfd; + bfd_boolean needed; - if (! _bfd_coff_get_external_symbols (abfd)) - return FALSE; - - if (! coff_link_check_ar_symbols (abfd, info, pneeded, &subsbfd)) - return FALSE; - - /* Potentially, the add_archive_element hook may have set a - substitute BFD for us. */ - if (*pneeded - && subsbfd - && ! _bfd_coff_get_external_symbols (subsbfd)) + if (!_bfd_coff_get_external_symbols (abfd)) return FALSE; - if (*pneeded - && ! coff_link_add_symbols (subsbfd ? subsbfd : abfd, info)) + oldbfd = abfd; + if (!coff_link_check_ar_symbols (abfd, info, pneeded, &abfd)) return FALSE; - if ((! info->keep_memory || ! *pneeded) - && ! _bfd_coff_free_symbols (abfd)) - return FALSE; + needed = *pneeded; + if (needed) + { + /* Potentially, the add_archive_element hook may have set a + substitute BFD for us. */ + if (abfd != oldbfd) + { + if (!info->keep_memory + && !_bfd_coff_free_symbols (oldbfd)) + return FALSE; + if (!_bfd_coff_get_external_symbols (abfd)) + return FALSE; + } + if (!coff_link_add_symbols (abfd, info)) + return FALSE; + } + if (!info->keep_memory || !needed) + { + if (!_bfd_coff_free_symbols (abfd)) + return FALSE; + } return TRUE; } -- cgit v1.1