summaryrefslogtreecommitdiff
path: root/bfd/linker.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2010-12-13 01:06:13 +0000
committerAlan Modra <amodra@bigpond.net.au>2010-12-13 01:06:13 +0000
commitbe86fae7b04f61d5b199dedb33d40fed393166e7 (patch)
treec63922d402d05d1fa38f28cebe5d7314937dd481 /bfd/linker.c
parent261e94744c337934d4026061c43510791936c6b4 (diff)
downloadbinutils-redhat-be86fae7b04f61d5b199dedb33d40fed393166e7.tar.gz
* 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.
Diffstat (limited to 'bfd/linker.c')
-rw-r--r--bfd/linker.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/bfd/linker.c b/bfd/linker.c
index fc52b51f00..2b52ba9651 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1223,20 +1223,18 @@ generic_link_check_archive_element (bfd *abfd,
{
bfd_size_type symcount;
asymbol **symbols;
- bfd *subsbfd = NULL;
+ bfd *oldbfd = abfd;
/* This object file defines this symbol, so pull it in. */
- if (! (*info->callbacks->add_archive_element)
- (info, abfd, bfd_asymbol_name (p), &subsbfd))
+ if (!(*info->callbacks
+ ->add_archive_element) (info, abfd, bfd_asymbol_name (p),
+ &abfd))
return FALSE;
/* Potentially, the add_archive_element hook may have set a
substitute BFD for us. */
- if (subsbfd)
- {
- abfd = subsbfd;
- if (!bfd_generic_link_read_symbols (abfd))
- return FALSE;
- }
+ if (abfd != oldbfd
+ && !bfd_generic_link_read_symbols (abfd))
+ return FALSE;
symcount = _bfd_generic_link_get_symcount (abfd);
symbols = _bfd_generic_link_get_symbols (abfd);
if (! generic_link_add_symbol_list (abfd, info, symcount,
@@ -1257,12 +1255,12 @@ generic_link_check_archive_element (bfd *abfd,
symbfd = h->u.undef.abfd;
if (symbfd == NULL)
{
- bfd *subsbfd = NULL;
/* This symbol was created as undefined from outside
BFD. We assume that we should link in the object
file. This is for the -u option in the linker. */
- if (! (*info->callbacks->add_archive_element)
- (info, abfd, bfd_asymbol_name (p), &subsbfd))
+ if (!(*info->callbacks
+ ->add_archive_element) (info, abfd, bfd_asymbol_name (p),
+ &abfd))
return FALSE;
/* Potentially, the add_archive_element hook may have set a
substitute BFD for us. But no symbols are going to get