From: David Meyer <pdox@google.com>
To: binutils@sourceware.org
Subject: [gold][patch] Clean up library names search
Date: Wed, 25 May 2011 05:26:00 -0000 [thread overview]
Message-ID: <BANLkTikZ=fjsiuCTku-+fvCB9svdApBL2g@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 225 bytes --]
I am working on an architecture which has more than two library
suffixes (.a, .so, and .pso).
This patch increases the flexibility of library name searching, by
using a list instead of hard-coding two possibilities.
- pdox
[-- Attachment #2: libnames.patch --]
[-- Type: application/octet-stream, Size: 5109 bytes --]
Index: dirsearch.cc
===================================================================
RCS file: /cvs/src/src/gold/dirsearch.cc,v
retrieving revision 1.12
diff -u -r1.12 dirsearch.cc
--- dirsearch.cc 11 Feb 2010 07:42:17 -0000 1.12
+++ dirsearch.cc 25 May 2011 05:10:20 -0000
@@ -241,8 +241,9 @@
// File_read::open.
std::string
-Dirsearch::find(const std::string& n1, const std::string& n2,
- bool* is_in_sysroot, int* pindex) const
+Dirsearch::find(const std::list<std::string> &names,
+ bool* is_in_sysroot, int* pindex,
+ std::string *found_name) const
{
gold_assert(!this->token_.is_blocked());
gold_assert(*pindex >= 0);
@@ -254,28 +255,20 @@
const Search_directory* p = &this->directories_->at(i);
Dir_cache* pdc = caches->lookup(p->name().c_str());
gold_assert(pdc != NULL);
- if (pdc->find(n1))
- {
- *is_in_sysroot = p->is_in_sysroot();
- *pindex = i;
- return p->name() + '/' + n1;
- }
- else
- gold_debug(DEBUG_FILES, "Attempt to open %s/%s failed",
- p->name().c_str(), n1.c_str());
-
- if (!n2.empty())
+ for (std::list<std::string>::const_iterator n = names.begin();
+ n != names.end(); ++n)
{
- if (pdc->find(n2))
+ if (pdc->find(*n))
{
*is_in_sysroot = p->is_in_sysroot();
- *pindex = i;
- return p->name() + '/' + n2;
+ *pindex = i;
+ *found_name = *n;
+ return p->name() + '/' + *n;
}
else
gold_debug(DEBUG_FILES, "Attempt to open %s/%s failed",
- p->name().c_str(), n2.c_str());
- }
+ p->name().c_str(), (*n).c_str());
+ }
}
*pindex = -2;
Index: dirsearch.h
===================================================================
RCS file: /cvs/src/src/gold/dirsearch.h,v
retrieving revision 1.8
diff -u -r1.8 dirsearch.h
--- dirsearch.h 25 Aug 2010 08:36:54 -0000 1.8
+++ dirsearch.h 25 May 2011 05:10:20 -0000
@@ -59,8 +59,8 @@
// and that value plus one may be used to find the next file with
// the same name(s).
std::string
- find(const std::string&, const std::string& n2, bool* is_in_sysroot,
- int* pindex) const;
+ find(const std::list<std::string> &names, bool* is_in_sysroot,
+ int* pindex, std::string *found_name) const;
// Return the blocker token which controls access.
Task_token*
Index: fileread.cc
===================================================================
RCS file: /cvs/src/src/gold/fileread.cc,v
retrieving revision 1.73
diff -u -r1.73 fileread.cc
--- fileread.cc 12 Apr 2011 18:06:16 -0000 1.73
+++ fileread.cc 25 May 2011 05:10:20 -0000
@@ -986,34 +986,31 @@
else if (input_argument->is_lib()
|| input_argument->is_searched_file())
{
- std::string n1, n2;
+ std::list<std::string> names;
if (input_argument->is_lib())
{
- n1 = "lib";
- n1 += input_argument->name();
+ std::string prefix = "lib";
+ prefix += input_argument->name();
if (parameters->options().is_static()
|| !input_argument->options().Bdynamic())
- n1 += ".a";
+ names.push_back(prefix + ".a");
else
{
- n2 = n1 + ".a";
- n1 += ".so";
+ names.push_back(prefix + ".so");
+ names.push_back(prefix + ".a");
}
}
else
- n1 = input_argument->name();
+ names.push_back(input_argument->name());
- if (Input_file::try_extra_search_path(pindex, input_argument, n1,
- found_name, namep))
- return true;
-
- if (!n2.empty() && Input_file::try_extra_search_path(pindex,
- input_argument, n2,
- found_name, namep))
- return true;
+ for (std::list<std::string>::iterator n = names.begin();
+ n != names.end(); ++n)
+ if (Input_file::try_extra_search_path(pindex, input_argument, *n,
+ found_name, namep))
+ return true;
// It is not in the extra_search_path.
- name = dirpath.find(n1, n2, is_in_sysroot, pindex);
+ name = dirpath.find(names, is_in_sysroot, pindex, found_name);
if (name.empty())
{
gold_error(_("cannot find %s%s"),
@@ -1021,10 +1018,6 @@
input_argument->name());
return false;
}
- if (n2.empty() || name[name.length() - 1] == 'o')
- *found_name = n1;
- else
- *found_name = n2;
*namep = name;
return true;
}
@@ -1041,15 +1034,14 @@
int index = *pindex;
if (index > 0)
--index;
- name = dirpath.find(input_argument->name(), "",
- is_in_sysroot, &index);
+ name = dirpath.find(std::list<std::string>(1,input_argument->name()),
+ is_in_sysroot, &index, found_name);
if (name.empty())
{
gold_error(_("cannot find %s"),
input_argument->name());
return false;
}
- *found_name = input_argument->name();
*namep = name;
*pindex = index + 1;
return true;
next reply other threads:[~2011-05-25 5:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-25 5:26 David Meyer [this message]
2011-05-25 6:16 ` Ian Lance Taylor
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='BANLkTikZ=fjsiuCTku-+fvCB9svdApBL2g@mail.gmail.com' \
--to=pdox@google.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).