aboutsummaryrefslogtreecommitdiff
path: root/gold/script.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-10-02 21:24:41 +0000
committerIan Lance Taylor <iant@google.com>2007-10-02 21:24:41 +0000
commit51dee2fec3afad5e6fc9f78b8c1d8486ebf3a334 (patch)
tree893aeec618b946af2d86179792c87db387545133 /gold/script.cc
parentf5c3f2256ff4090c1d4a7d023c327eaed335ec27 (diff)
downloadgdb-51dee2fec3afad5e6fc9f78b8c1d8486ebf3a334.zip
gdb-51dee2fec3afad5e6fc9f78b8c1d8486ebf3a334.tar.gz
gdb-51dee2fec3afad5e6fc9f78b8c1d8486ebf3a334.tar.bz2
From Craig Silverstein: add support for searching for input files
named in linker scripts.
Diffstat (limited to 'gold/script.cc')
-rw-r--r--gold/script.cc22
1 files changed, 8 insertions, 14 deletions
diff --git a/gold/script.cc b/gold/script.cc
index 950fa15..b003add 100644
--- a/gold/script.cc
+++ b/gold/script.cc
@@ -1166,20 +1166,14 @@ extern "C" void
script_add_file(void* closurev, const char* name)
{
Parser_closure* closure = static_cast<Parser_closure*>(closurev);
- std::string absname;
- if (name[0] == '/')
- {
- absname = name;
- }
- else
- {
- // Prepend `dirname closure->filename()` to make the path absolute.
- char *slash = strrchr(closure->filename(), '/');
- absname.assign(closure->filename(),
- slash ? slash - closure->filename() + 1 : 0);
- absname += name;
- }
- Input_file_argument file(absname.c_str(), false, closure->position_dependent_options());
+ // In addition to checking the normal library search path, we also
+ // want to check in the script-directory.
+ const char *slash = strrchr(closure->filename(), '/');
+ std::string script_directory(closure->filename(),
+ slash ? slash - closure->filename() + 1 : 0);
+ Input_file_argument file(name, false,
+ slash ? script_directory.c_str() : ".",
+ closure->position_dependent_options());
closure->inputs()->add_file(file);
}