2008-04-23 Elliott Hughes <enh@google.com>
authorChris Demetriou <cgd@google.com>
Fri, 24 Apr 2009 19:48:21 +0000 (19:48 +0000)
committerChris Demetriou <cgd@google.com>
Fri, 24 Apr 2009 19:48:21 +0000 (19:48 +0000)
        * output.cc (Output_file::close): After short writes, continue
        writing from the correct offset in the buffer being written.

gold/ChangeLog
gold/output.cc

index bec3a75..c9a42a8 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-23  Elliott Hughes  <enh@google.com>
+
+       * output.cc (Output_file::close): After short writes, continue
+       writing from the correct offset in the buffer being written.
+
 2009-04-23  Chris Demetriou  <cgd@google.com>
 
        * configure.ac (HAVE_TR1_UNORDERED_MAP_REHASH): New define.
index d70c37a..b532136 100644 (file)
@@ -3460,15 +3460,20 @@ Output_file::close()
   if (this->map_is_anonymous_ && !this->is_temporary_)
     {
       size_t bytes_to_write = this->file_size_;
+      size_t offset = 0;
       while (bytes_to_write > 0)
         {
-          ssize_t bytes_written = ::write(this->o_, this->base_, bytes_to_write);
+          ssize_t bytes_written = ::write(this->o_, this->base_ + offset,
+                                          bytes_to_write);
           if (bytes_written == 0)
             gold_error(_("%s: write: unexpected 0 return-value"), this->name_);
           else if (bytes_written < 0)
             gold_error(_("%s: write: %s"), this->name_, strerror(errno));
           else
-            bytes_to_write -= bytes_written;
+            {
+              bytes_to_write -= bytes_written;
+              offset += bytes_written;
+            }
         }
     }
   this->unmap();