PR 5990
authorIan Lance Taylor <ian@airs.com>
Sat, 28 Feb 2009 03:05:08 +0000 (03:05 +0000)
committerIan Lance Taylor <ian@airs.com>
Sat, 28 Feb 2009 03:05:08 +0000 (03:05 +0000)
* descriptors.h (Open_descriptor): Add is_on_stack field.
* descriptors.cc (Descriptors::open): If the descriptor is on the
top of the stack, remove it.  Initialize is_on_stack field.
(Descriptors::release): Only add pod to stack if it is not on the
stack already.
(Descriptors::close_some_descriptor): Clear stack_next and
is_on_stack fields.

gold/ChangeLog
gold/descriptors.cc
gold/descriptors.h

index 5c0f9c39e4ad26b37920a82baae669565fb1b16b..dfc99b728df3fd8fd4d8271c103077f43a8d0f96 100644 (file)
@@ -1,5 +1,14 @@
 2009-02-27  Ian Lance Taylor  <iant@google.com>
 
+       PR 5990
+       * descriptors.h (Open_descriptor): Add is_on_stack field.
+       * descriptors.cc (Descriptors::open): If the descriptor is on the
+       top of the stack, remove it.  Initialize is_on_stack field.
+       (Descriptors::release): Only add pod to stack if it is not on the
+       stack already.
+       (Descriptors::close_some_descriptor): Clear stack_next and
+       is_on_stack fields.
+
        PR 7091
        * output.cc (Output_section::find_starting_output_address): Rename
        from starting_output_address; add PADDR parameter; change return
index 18498efd7c7ef9ca32bb49546c26f7ae1181147e..862edae7fb37dcfe4c1627f9cb06851149f55aa1 100644 (file)
@@ -75,6 +75,12 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
        {
          gold_assert(!pod->inuse);
          pod->inuse = true;
+         if (descriptor == this->stack_top_)
+           {
+             this->stack_top_ = pod->stack_next;
+             pod->stack_next = -1;
+             pod->is_on_stack = false;
+           }
          return descriptor;
        }
     }
@@ -114,6 +120,7 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
          pod->stack_next = -1;
          pod->inuse = true;
          pod->is_write = (flags & O_ACCMODE) != O_RDONLY;
+         pod->is_on_stack = false;
 
          ++this->current_;
          if (this->current_ >= this->limit_)
@@ -158,10 +165,11 @@ Descriptors::release(int descriptor, bool permanent)
   else
     {
       pod->inuse = false;
-      if (!pod->is_write)
+      if (!pod->is_write && !pod->is_on_stack)
        {
          pod->stack_next = this->stack_top_;
          this->stack_top_ = descriptor;
+         pod->is_on_stack = true;
        }
     }
 }
@@ -193,6 +201,8 @@ Descriptors::close_some_descriptor()
            this->stack_top_ = pod->stack_next;
          else
            this->open_descriptors_[last].stack_next = pod->stack_next;
+         pod->stack_next = -1;
+         pod->is_on_stack = false;
          return true;
        }
       last = i;
index 19333149287637dd9b22748ce9e324e03a00da45..44c2475087efd734cbeff36a74615b5c1f69f976 100644 (file)
@@ -69,6 +69,8 @@ class Descriptors
     bool inuse;
     // Whether this is a write descriptor.
     bool is_write;
+    // Whether the descriptor is on the stack.
+    bool is_on_stack;
   };
 
   bool
This page took 0.03037 seconds and 4 git commands to generate.