From Craig Silverstein: Handle a .so file in a .a file.
authorIan Lance Taylor <iant@google.com>
Wed, 7 Nov 2007 00:45:05 +0000 (00:45 +0000)
committerIan Lance Taylor <iant@google.com>
Wed, 7 Nov 2007 00:45:05 +0000 (00:45 +0000)
gold/dynobj.cc
gold/dynobj.h

index 119f0c74ca6a50626894ceb8fe446b3fa19dc8b3..95ffe087337a6346080afc2460c023331d240ee6 100644 (file)
@@ -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.
index aea004d3f76411f6c08ebf2d5f54dda9734c9b2d..d9c3e107530e576e96cd134d7beb7fb4a48e4f21 100644 (file)
@@ -39,9 +39,7 @@ class General_options;
 class Dynobj : public Object
 {
  public:
-  Dynobj(const std::string& name, Input_file* input_file, off_t offset = 0)
-    : Object(name, input_file, true, offset), soname_()
-  { }
+  Dynobj(const std::string& name, Input_file* input_file, off_t offset = 0);
 
   // Return the name to use in a DT_NEEDED entry for this object.
   const char*
This page took 0.026924 seconds and 4 git commands to generate.