diff options
author | Ian Lance Taylor <iant@google.com> | 2007-11-07 00:45:05 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-11-07 00:45:05 +0000 |
commit | a7a81c1d9d5e6191ec7a2c3ce2ecc03e1264e4df (patch) | |
tree | f1f2a8e096c9854921abc6abcc5ea35ca02b7ecf /gold/dynobj.cc | |
parent | 019cdb1a59d66739843fdb0e6221566bcf7d60bd (diff) | |
download | gdb-a7a81c1d9d5e6191ec7a2c3ce2ecc03e1264e4df.zip gdb-a7a81c1d9d5e6191ec7a2c3ce2ecc03e1264e4df.tar.gz gdb-a7a81c1d9d5e6191ec7a2c3ce2ecc03e1264e4df.tar.bz2 |
From Craig Silverstein: Handle a .so file in a .a file.
Diffstat (limited to 'gold/dynobj.cc')
-rw-r--r-- | gold/dynobj.cc | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/gold/dynobj.cc b/gold/dynobj.cc index 119f0c7..95ffe08 100644 --- a/gold/dynobj.cc +++ b/gold/dynobj.cc @@ -35,14 +35,37 @@ namespace gold // Class Dynobj. +// Sets up the default soname_ to use, in the (rare) cases we never +// see a DT_SONAME entry. + +Dynobj::Dynobj(const std::string& name, Input_file* input_file, off_t offset) + : Object(name, input_file, true, offset) +{ + // This will be overridden by a DT_SONAME entry, hopefully. But if + // we never see a DT_SONAME entry, our rule is to use the dynamic + // object's filename. The only exception is when the dynamic object + // is part of an archive (so the filename is the archive's + // filename). In that case, we use just the dynobj's name-in-archive. + this->soname_ = this->input_file()->found_name(); + if (this->offset() != 0) + { + std::string::size_type open_paren = this->name().find('('); + std::string::size_type close_paren = this->name().find(')'); + if (open_paren != std::string::npos && close_paren != std::string::npos) + { + // It's an archive, and name() is of the form 'foo.a(bar.so)'. + this->soname_ = this->name().substr(open_paren + 1, + close_paren - (open_paren + 1)); + } + } +} + // Return the string to use in a DT_NEEDED entry. const char* Dynobj::soname() const { - if (!this->soname_.empty()) - return this->soname_.c_str(); - return this->input_file()->found_name().c_str(); + return this->soname_.c_str(); } // Class Sized_dynobj. |