* 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.
+2010-12-13 Alan Modra <amodra@gmail.com>
+
+ * 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.
+
2010-12-13 Alan Modra <amodra@gmail.com>
* plugin.c (bfd_plugin_mkobject): Delete.
continue;
}
- 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;
outside BFD. We assume that we should link
in the object file. This is done for the -u
option in the linker. */
- 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;
symbol. It is already on the undefs list. */
h->type = bfd_link_hash_common;
h->u.c.p = (struct bfd_link_hash_common_entry *)
- bfd_hash_allocate (&info->hash->table,
- sizeof (struct bfd_link_hash_common_entry));
+ bfd_hash_allocate (&info->hash->table,
+ sizeof (struct bfd_link_hash_common_entry));
if (h->u.c.p == NULL)
return FALSE;
it if the current link symbol is common. */
if (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;
struct bfd_link_info *info,
bfd_boolean *pneeded)
{
- bfd *subsbfd = NULL;
+ bfd *oldbfd;
+ bfd_boolean needed;
- if (! aout_get_external_symbols (abfd))
+ if (!aout_get_external_symbols (abfd))
return FALSE;
- if (! aout_link_check_ar_symbols (abfd, info, pneeded, &subsbfd))
+ oldbfd = abfd;
+ if (!aout_link_check_ar_symbols (abfd, info, pneeded, &abfd))
return FALSE;
- if (*pneeded)
+ needed = *pneeded;
+ if (needed)
{
/* Potentially, the add_archive_element hook may have set a
substitute BFD for us. */
- if (subsbfd && !aout_get_external_symbols (subsbfd))
- return FALSE;
- if (! aout_link_add_symbols (subsbfd ? subsbfd : abfd, info))
+ if (abfd != oldbfd)
+ {
+ if (!info->keep_memory
+ && !aout_link_free_symbols (oldbfd))
+ return FALSE;
+ if (!aout_get_external_symbols (abfd))
+ return FALSE;
+ }
+ if (!aout_link_add_symbols (abfd, info))
return FALSE;
}
- if (! info->keep_memory || ! *pneeded)
+ if (!info->keep_memory || !needed)
{
- if (! aout_link_free_symbols (abfd))
+ if (!aout_link_free_symbols (abfd))
return FALSE;
}
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;
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;
}
EXTR esym;
bfd_boolean def;
const char *name;
- bfd *subsbfd;
+ bfd *oldbfd;
struct bfd_link_hash_entry *h;
(*swap_ext_in) (abfd, (void *) ext_ptr, &esym);
continue;
/* Include this element. */
- subsbfd = NULL;
- if (! (*info->callbacks->add_archive_element)
- (info, abfd, name, &subsbfd))
+ oldbfd = abfd;
+ if (!(*info->callbacks
+ ->add_archive_element) (info, abfd, name, &abfd))
goto error_return;
/* Potentially, the add_archive_element hook may have set a
substitute BFD for us. */
- if (subsbfd
+ if (abfd != oldbfd
&& !reread_ext_syms_and_strs (&symhdr, &external_ext_size, &esize,
- &external_ext, &ssext, subsbfd, backend))
+ &external_ext, &ssext, abfd, backend))
goto error_return;
- if (! ecoff_link_add_externals (subsbfd ? subsbfd : abfd, info,
- external_ext, ssext))
+ if (! ecoff_link_add_externals (abfd, info, external_ext, ssext))
goto error_return;
*pneeded = TRUE;
unsigned int file_offset;
const char *name;
bfd *element;
- bfd *subsbfd;
h = *pundef;
/* Unlike the generic linker, we know that this element provides
a definition for an undefined symbol and we know that we want
to include it. We don't need to check anything. */
- subsbfd = NULL;
- if (! (*info->callbacks->add_archive_element)
- (info, element, name, &subsbfd))
+ if (!(*info->callbacks
+ ->add_archive_element) (info, element, name, &element))
return FALSE;
- /* Potentially, the add_archive_element hook may have set a
- substitute BFD for us. */
- if (! ecoff_link_add_object_symbols (subsbfd ? subsbfd : element, info))
+ if (! ecoff_link_add_object_symbols (element, info))
return FALSE;
pundef = &(*pundef)->u.undef.next;
undefs_tail = info->hash->undefs_tail;
- if (! (*info->callbacks->add_archive_element)
- (info, element, symdef->name, &element))
+ if (!(*info->callbacks
+ ->add_archive_element) (info, element, symdef->name, &element))
goto error_return;
- if (! bfd_link_add_symbols (element, info))
+ if (!bfd_link_add_symbols (element, info))
goto error_return;
/* If there are any new undefined symbols, we need to make
{
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,
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
but not if it is defined in the .text section. That
seems a bit crazy to me, and I haven't implemented it.
However, it might be correct. */
- 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;
outside BFD. We assume that we should link
in the object file. This is done for the -u
option in the linker. */
- 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;
struct bfd_link_info *info,
bfd_boolean *pneeded)
{
- bfd *subsbfd = NULL;
+ bfd *oldbfd;
+ bfd_boolean needed;
- if (! aout_get_external_symbols (abfd))
+ if (!aout_get_external_symbols (abfd))
return FALSE;
- if (! aout_link_check_ar_symbols (abfd, info, pneeded, &subsbfd))
+ oldbfd = abfd;
+ if (!aout_link_check_ar_symbols (abfd, info, pneeded, &abfd))
return FALSE;
- if (*pneeded)
+ needed = *pneeded;
+ if (needed)
{
/* Potentially, the add_archive_element hook may have set a
substitute BFD for us. */
- if (subsbfd && ! aout_get_external_symbols (subsbfd))
- return FALSE;
- if (! aout_link_add_symbols (subsbfd ? subsbfd : abfd, info))
+ if (abfd != oldbfd)
+ {
+ if (!info->keep_memory
+ && !aout_link_free_symbols (oldbfd))
+ return FALSE;
+ if (!aout_get_external_symbols (abfd))
+ return FALSE;
+ }
+ if (!aout_link_add_symbols (abfd, info))
return FALSE;
}
- if (! info->keep_memory || ! *pneeded)
+ if (!info->keep_memory || !needed)
{
- if (! aout_link_free_symbols (abfd))
+ if (!aout_link_free_symbols (abfd))
return FALSE;
}
symindex symidx;
bfd *element;
bfd *orig_element;
- bfd *subsbfd;
h = *pundef;
next_pundef = &(*pundef)->u.undef.next;
/* Unlike the generic linker, we know that this element provides
a definition for an undefined symbol and we know that we want
to include it. We don't need to check anything. */
- subsbfd = NULL;
- if (! (*info->callbacks->add_archive_element)
- (info, element, h->root.string, &subsbfd))
+ if (!(*info->callbacks
+ ->add_archive_element) (info, element, h->root.string, &element))
return FALSE;
- /* Potentially, the add_archive_element hook may have set a
- substitute BFD for us. */
- if (! alpha_vms_link_add_object_symbols (subsbfd ? subsbfd : element,
- info))
+ if (!alpha_vms_link_add_object_symbols (element, info))
return FALSE;
orig_element->archive_pass = pass;
&& (((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;
|| (((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;
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;
if (!keep_syms_p)
{
- if (! _bfd_coff_free_symbols (abfd))
+ if (!_bfd_coff_free_symbols (abfd))
return FALSE;
}