From Craig Silverstein: add support for searching for input files
[deliverable/binutils-gdb.git] / gold / script.cc
index 950fa1581095653dc9ef5d7abbc638bcb81a0a5a..b003addec21bd7b01e63085091fb3f2bbdab7e80 100644 (file)
@@ -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);
 }
 
This page took 0.024347 seconds and 4 git commands to generate.