From: Cary Coutant <ccoutant@google.com>
To: Ian Lance Taylor <iant@google.com>, Binutils <binutils@sourceware.org>
Subject: [gold patch] PR gold/12163: Don't load same archive twice as a whole archive
Date: Thu, 02 Jun 2011 19:11:00 -0000 [thread overview]
Message-ID: <BANLkTi=QmwbEMo14eHK00hUF8rf=VZjELCb-NvqG5Kt-NVikUA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 470 bytes --]
As described in PR 12163
http://sourceware.org/bugzilla/show_bug.cgi?id=12163
if a library is linked with --whole-archive, nested inside a
--start-group/--end-group, gold will load the library twice. This
patch prevents that.
OK?
-cary
PR gold/12163
* gold/archive.cc (Archive::Archive): Initialize new data member.
(Archive::include_all_members): Return if archive has already been
included.
* gold/archive.h (Archive::include_all_members_): New data member.
[-- Attachment #2: gold-pr12163-patch.txt --]
[-- Type: text/plain, Size: 1909 bytes --]
2011-06-02 Cary Coutant <ccoutant@google.com>
PR gold/12163
* gold/archive.cc (Archive::Archive): Initialize new data member.
(Archive::include_all_members): Return if archive has already been
included.
* gold/archive.h (Archive::include_all_members_): New data member.
diff --git a/gold/archive.cc b/gold/archive.cc
index a7a5b93..c3f7b94 100644
--- a/gold/archive.cc
+++ b/gold/archive.cc
@@ -179,7 +179,8 @@ Archive::Archive(const std::string& name, Input_file* input_file,
: Library_base(task), name_(name), input_file_(input_file), armap_(),
armap_names_(), extended_names_(), armap_checked_(), seen_offsets_(),
members_(), is_thin_archive_(is_thin_archive), included_member_(false),
- nested_archives_(), dirpath_(dirpath), num_members_(0)
+ nested_archives_(), dirpath_(dirpath), num_members_(0),
+ included_all_members_(false)
{
this->no_export_ =
parameters->options().check_excluded_libs(input_file->found_name());
@@ -847,6 +848,13 @@ bool
Archive::include_all_members(Symbol_table* symtab, Layout* layout,
Input_objects* input_objects, Mapfile* mapfile)
{
+ // Don't include the same archive twice. This can happen if
+ // --whole-archive is nested inside --start-group (PR gold/12163).
+ if (this->included_all_members_)
+ return true;
+
+ this->included_all_members_ = true;
+
input_objects->archive_start(this);
if (this->members_.size() > 0)
diff --git a/gold/archive.h b/gold/archive.h
index 78c2cc8..e73a687 100644
--- a/gold/archive.h
+++ b/gold/archive.h
@@ -405,6 +405,8 @@ class Archive : public Library_base
unsigned int num_members_;
// True if we exclude this library archive from automatic export.
bool no_export_;
+ // True if this library has been included as a --whole-archive.
+ bool included_all_members_;
};
// This class is used to read an archive and pick out the desired
next reply other threads:[~2011-06-02 19:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-02 19:11 Cary Coutant [this message]
2011-06-02 20:03 ` Ian Lance Taylor
2011-06-02 20:18 ` Cary Coutant
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='BANLkTi=QmwbEMo14eHK00hUF8rf=VZjELCb-NvqG5Kt-NVikUA@mail.gmail.com' \
--to=ccoutant@google.com \
--cc=binutils@sourceware.org \
--cc=iant@google.com \
/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).