+const Position_dependent_options&
+Input_file::options() const
+{
+ return this->input_argument_->options();
+}
+
+// Return the name given by the user. For -lc this will return "c".
+
+const char*
+Input_file::name() const
+{
+ return this->input_argument_->name();
+}
+
+// Return whether this file is in a system directory.
+
+bool
+Input_file::is_in_system_directory() const
+{
+ if (this->is_in_sysroot())
+ return true;
+ return parameters->options().is_in_system_directory(this->filename());
+}
+
+// Return whether we are only reading symbols.
+
+bool
+Input_file::just_symbols() const
+{
+ return this->input_argument_->just_symbols();
+}
+
+// Return whether this is a file that we will search for in the list
+// of directories.
+
+bool
+Input_file::will_search_for() const
+{
+ return (!IS_ABSOLUTE_PATH(this->input_argument_->name())
+ && (this->input_argument_->is_lib()
+ || this->input_argument_->is_searched_file()
+ || this->input_argument_->extra_search_path() != NULL));
+}
+
+// Return the file last modification time. Calls gold_fatal if the stat
+// system call failed.
+
+Timespec
+File_read::get_mtime()
+{
+ struct stat file_stat;
+ this->reopen_descriptor();
+
+ if (fstat(this->descriptor_, &file_stat) < 0)
+ gold_fatal(_("%s: stat failed: %s"), this->name_.c_str(),
+ strerror(errno));
+#ifdef HAVE_STAT_ST_MTIM
+ return Timespec(file_stat.st_mtim.tv_sec, file_stat.st_mtim.tv_nsec);
+#else
+ return Timespec(file_stat.st_mtime, 0);
+#endif
+}
+
+// Try to find a file in the extra search dirs. Returns true on success.
+
+bool
+Input_file::try_extra_search_path(int* pindex,
+ const Input_file_argument* input_argument,
+ std::string filename, std::string* found_name,
+ std::string* namep)
+{
+ if (input_argument->extra_search_path() == NULL)
+ return false;
+
+ std::string name = input_argument->extra_search_path();
+ if (!IS_DIR_SEPARATOR(name[name.length() - 1]))
+ name += '/';
+ name += filename;
+
+ struct stat dummy_stat;
+ if (*pindex > 0 || ::stat(name.c_str(), &dummy_stat) < 0)
+ return false;
+
+ *found_name = filename;
+ *namep = name;
+ return true;
+}
+
+// Find the actual file.
+// If the filename is not absolute, we assume it is in the current
+// directory *except* when:
+// A) input_argument_->is_lib() is true;
+// B) input_argument_->is_searched_file() is true; or
+// C) input_argument_->extra_search_path() is not empty.
+// In each, we look in extra_search_path + library_path to find
+// the file location, rather than the current directory.
+
+bool
+Input_file::find_file(const Dirsearch& dirpath, int* pindex,
+ const Input_file_argument* input_argument,
+ bool* is_in_sysroot,
+ std::string* found_name, std::string* namep)