aboutsummaryrefslogtreecommitdiff
path: root/bfd/xcofflink.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/xcofflink.c')
-rw-r--r--bfd/xcofflink.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 30923cf..c055b26 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -2233,7 +2233,8 @@ xcoff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
static bfd_boolean
xcoff_link_check_dynamic_ar_symbols (bfd *abfd,
struct bfd_link_info *info,
- bfd_boolean *pneeded)
+ bfd_boolean *pneeded,
+ bfd **subsbfd)
{
asection *lsec;
bfd_byte *contents;
@@ -2291,7 +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))
+ if (! (*info->callbacks->add_archive_element)
+ (info, abfd, name, subsbfd))
return FALSE;
*pneeded = TRUE;
return TRUE;
@@ -2314,7 +2316,8 @@ xcoff_link_check_dynamic_ar_symbols (bfd *abfd,
static bfd_boolean
xcoff_link_check_ar_symbols (bfd *abfd,
struct bfd_link_info *info,
- bfd_boolean *pneeded)
+ bfd_boolean *pneeded,
+ bfd **subsbfd)
{
bfd_size_type symesz;
bfd_byte *esym;
@@ -2325,7 +2328,7 @@ xcoff_link_check_ar_symbols (bfd *abfd,
if ((abfd->flags & DYNAMIC) != 0
&& ! info->static_link
&& info->output_bfd->xvec == abfd->xvec)
- return xcoff_link_check_dynamic_ar_symbols (abfd, info, pneeded);
+ return xcoff_link_check_dynamic_ar_symbols (abfd, info, pneeded, subsbfd);
symesz = bfd_coff_symesz (abfd);
esym = (bfd_byte *) obj_coff_external_syms (abfd);
@@ -2361,7 +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))
+ if (! (*info->callbacks->add_archive_element)
+ (info, abfd, name, subsbfd))
return FALSE;
*pneeded = TRUE;
return TRUE;
@@ -2386,17 +2390,22 @@ xcoff_link_check_archive_element (bfd *abfd,
bfd_boolean *pneeded)
{
bfd_boolean keep_syms_p;
+ bfd *subsbfd = NULL;
keep_syms_p = (obj_coff_external_syms (abfd) != NULL);
if (! _bfd_coff_get_external_symbols (abfd))
return FALSE;
- if (! xcoff_link_check_ar_symbols (abfd, info, pneeded))
+ if (! xcoff_link_check_ar_symbols (abfd, info, pneeded, &subsbfd))
return FALSE;
if (*pneeded)
{
- if (! xcoff_link_add_symbols (abfd, info))
+ /* 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))
return FALSE;
if (info->keep_memory)
keep_syms_p = TRUE;