From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: Re: Fix LTO vs. COFF archives
Date: Tue, 05 Aug 2014 01:35:00 -0000 [thread overview]
Message-ID: <20140805013438.GE8921@bubble.grove.modra.org> (raw)
In-Reply-To: <20140802050021.GJ23728@bubble.grove.modra.org>
On Sat, Aug 02, 2014 at 02:30:21PM +0930, Alan Modra wrote:
> This patch needs some serious testing by mingw/cygwin people before
Thanks to lrn1986 at gmail dot com for testing, now committed with
this additional patch.
It doesn't make sense to call add_archive_element without loading
symbols from the object. Dave Korn flagged this a while ago with the
comment he added..
* linker.c (generic_link_check_archive_element): Move handling
of command link -u symbols with a common symbol def to the
code handling non-common symbols so that archive element symbols
are loaded. Use generic_link_add_object_symbols.
diff --git a/bfd/linker.c b/bfd/linker.c
index a31e473..1877e67 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1120,29 +1120,21 @@ generic_link_check_archive_element (bfd *abfd,
/* P is a symbol we are looking for. */
- if (! bfd_is_com_section (p->section))
+ if (! bfd_is_com_section (p->section)
+ || (h->type == bfd_link_hash_undefined
+ && h->u.undef.abfd == NULL))
{
- bfd_size_type symcount;
- asymbol **symbols;
- bfd *oldbfd = abfd;
-
- /* This object file defines this symbol, so pull it in. */
+ /* P is not a common symbol, or an undefined reference was
+ created from outside BFD such as from a linker -u option.
+ This object file defines the symbol, so pull it in. */
+ *pneeded = TRUE;
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 (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,
- symbols, collect))
- return FALSE;
- *pneeded = TRUE;
- return TRUE;
+ return generic_link_add_object_symbols (abfd, info, collect);
}
/* P is a common symbol. */
@@ -1153,23 +1145,6 @@ generic_link_check_archive_element (bfd *abfd,
bfd_vma size;
unsigned int power;
- symbfd = h->u.undef.abfd;
- if (symbfd == 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),
- &abfd))
- return FALSE;
- /* Potentially, the add_archive_element hook may have set a
- substitute BFD for us. But no symbols are going to get
- registered by anything we're returning to from here. */
- *pneeded = TRUE;
- return TRUE;
- }
-
/* Turn the symbol into a common symbol but do not link in
the object file. This is how a.out works. Object
formats that require different semantics must implement
@@ -1177,6 +1152,7 @@ generic_link_check_archive_element (bfd *abfd,
undefs list. We add the section to a common section
attached to symbfd to ensure that it is in a BFD which
will be linked in. */
+ symbfd = h->u.undef.abfd;
h->type = bfd_link_hash_common;
h->u.c.p = (struct bfd_link_hash_common_entry *)
bfd_hash_allocate (&info->hash->table,
--
Alan Modra
Australia Development Lab, IBM
prev parent reply other threads:[~2014-08-05 1:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-02 5:00 Alan Modra
2014-08-05 1:35 ` Alan Modra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140805013438.GE8921@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).