From: Ian Lance Taylor Date: Tue, 9 Oct 2007 17:46:15 +0000 (+0000) Subject: Fix soname for library found in search path. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e2aacd2c759620f4d18142f811c916adcf6fb7b4;p=binutils-gdb.git Fix soname for library found in search path. --- diff --git a/gold/dynobj.cc b/gold/dynobj.cc index 581772086de..805d869f2e9 100644 --- a/gold/dynobj.cc +++ b/gold/dynobj.cc @@ -42,7 +42,7 @@ Dynobj::soname() const { if (!this->soname_.empty()) return this->soname_.c_str(); - return this->name().c_str(); + return this->input_file()->found_name().c_str(); } // Class Sized_dynobj. diff --git a/gold/fileread.cc b/gold/fileread.cc index 1bbd8412a81..88ac12611a2 100644 --- a/gold/fileread.cc +++ b/gold/fileread.cc @@ -397,8 +397,10 @@ Input_file::open(const General_options& options, const Dirsearch& dirpath) if (IS_ABSOLUTE_PATH (this->input_argument_->name()) || (!this->input_argument_->is_lib() && this->input_argument_->extra_search_path() == NULL)) - name = this->input_argument_->name(); - + { + name = this->input_argument_->name(); + this->found_name_ = name; + } // Case 3: is_lib is true else if (this->input_argument_->is_lib()) { @@ -421,8 +423,11 @@ Input_file::open(const General_options& options, const Dirsearch& dirpath) this->input_argument_->name()); gold_exit(false); } + if (n2.empty() || name[name.length() - 1] == 'o') + this->found_name_ = n1; + else + this->found_name_ = n2; } - // Case 4: extra_search_path is not empty else { @@ -446,6 +451,7 @@ Input_file::open(const General_options& options, const Dirsearch& dirpath) gold_exit(false); } } + this->found_name_ = this->input_argument_->name(); } // Now that we've figured out where the file lives, try to open it. diff --git a/gold/fileread.h b/gold/fileread.h index abeb28e07b9..349a2b52173 100644 --- a/gold/fileread.h +++ b/gold/fileread.h @@ -260,7 +260,8 @@ class Input_file { public: Input_file(const Input_file_argument* input_argument) - : input_argument_(input_argument), file_(), is_in_sysroot_(false) + : input_argument_(input_argument), found_name_(), file_(), + is_in_sysroot_(false) { } // Create an input file with the contents already provided. This is @@ -272,16 +273,24 @@ class Input_file void open(const General_options&, const Dirsearch&); - // Return the name given by the user. + // Return the name given by the user. For -lc this will return "c". const char* name() const { return this->input_argument_->name(); } - // Return the file name. + // Return the file name. For -lc this will return something like + // "/usr/lib/libc.so". const std::string& filename() const { return this->file_.filename(); } + // Return the name under which we found the file, corresponding to + // the command line. For -lc this will return something like + // "libc.so". + const std::string& + found_name() const + { return this->found_name_; } + // Return the position dependent options. const Position_dependent_options& options() const @@ -303,6 +312,11 @@ class Input_file // The argument from the command line. const Input_file_argument* input_argument_; + // The name under which we opened the file. This is like the name + // on the command line, but -lc turns into libc.so (or whatever). + // It only includes the full path if the path was on the command + // line. + std::string found_name_; // The file after we open it. File_read file_; // Whether we found the file in a directory in the system root.