From Craig Silverstein: don't get confused if the same file name
authorIan Lance Taylor <iant@google.com>
Wed, 10 Oct 2007 06:33:56 +0000 (06:33 +0000)
committerIan Lance Taylor <iant@google.com>
Wed, 10 Oct 2007 06:33:56 +0000 (06:33 +0000)
occurs in an archive.

gold/merge.cc
gold/object.h

index 0db62ef7c822f67cc682f7d46e1634bf46b9449f..75cbc18666bccd54b7487d451965da3bc80a2475 100644 (file)
@@ -40,7 +40,15 @@ Output_merge_base::Merge_key_less::operator()(const Merge_key& mk1,
   // matter.  We want to get consistent results across links so we
   // don't use pointer comparison.
   if (mk1.object != mk2.object)
-    return mk1.object->name() < mk2.object->name();
+    {
+      // Two different object files can have the same name: if foo.a
+      // includes both bar/qux.o and baz/qux.o, then both end up with
+      // the name foo.a(qux.o).  But it's impossible for two different
+      // object files to have both the same name and the same offset.
+      if (mk1.object->offset() != mk2.object->offset())
+        return mk1.object->offset() < mk2.object->offset();
+      return mk1.object->name() < mk2.object->name();
+    }
   if (mk1.shndx != mk2.shndx)
     return mk1.shndx < mk2.shndx;
   return mk1.offset < mk2.offset;
index 2baf2da87a6666c214166ffa3363379615575486..8f0a3b7726e41c8c6a2bde09fe2605f38629c936 100644 (file)
@@ -130,6 +130,11 @@ class Object
   name() const
   { return this->name_; }
 
+  // Get the offset into the file.
+  off_t
+  offset() const
+  { return this->offset_; }
+
   // Return whether this is a dynamic object.
   bool
   is_dynamic() const
@@ -277,11 +282,6 @@ class Object
   input_file() const
   { return this->input_file_; }
 
-  // Get the offset into the file.
-  off_t
-  offset() const
-  { return this->offset_; }
-
   // Get a view into the underlying file.
   const unsigned char*
   get_view(off_t start, off_t size, bool cache)
This page took 0.029071 seconds and 4 git commands to generate.