PR gold/10708
authorCary Coutant <ccoutant@google.com>
Fri, 5 Nov 2010 21:14:33 +0000 (21:14 +0000)
committerCary Coutant <ccoutant@google.com>
Fri, 5 Nov 2010 21:14:33 +0000 (21:14 +0000)
* copy-relocs.cc (Copy_relocs::emit_copy_reloc): Hold a lock on the
object when reading from the file.
* gold.cc (queue_middle_tasks): Hold a lock on the object when doing
second layout pass.
* icf.cc (preprocess_for_unique_sections): Hold a lock on the object
when reading section contents.
(get_section_contents): Likewise.
(icf::find_identical_sections): Likewise.
* mapfile.cc (Mapfile::print_discarded_sections): Hold a lock on the
object when reading from the file.
* plugin.cc (Plugin_manager::layout_deferred_objects): Hold a lock on
the object when doing deferred section layout.

gold/ChangeLog
gold/copy-relocs.cc
gold/gold.cc
gold/icf.cc
gold/mapfile.cc
gold/plugin.cc

index 53bc3639d271258252698205b4bfdef66826f3fb..ee2b86587db5ee52d301f1e127d15b704f62019c 100644 (file)
@@ -1,3 +1,19 @@
+2010-11-05  Cary Coutant  <ccoutant@google.com>
+
+       PR gold/10708
+       * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Hold a lock on the
+       object when reading from the file.
+       * gold.cc (queue_middle_tasks): Hold a lock on the object when doing
+       second layout pass.
+       * icf.cc (preprocess_for_unique_sections): Hold a lock on the object
+       when reading section contents.
+       (get_section_contents): Likewise.
+       (icf::find_identical_sections): Likewise.
+       * mapfile.cc (Mapfile::print_discarded_sections): Hold a lock on the
+       object when reading from the file.
+       * plugin.cc (Plugin_manager::layout_deferred_objects): Hold a lock on
+       the object when doing deferred section layout.
+
 2010-11-03  Nick Clifton  <nickc@redhat.com>
 
        PR gold/12001
index ed8002fff660ed05add6a5cc0bcde7176493900d..4931aa06b659c1694d929a21433a951b2240322e 100644 (file)
@@ -125,8 +125,17 @@ Copy_relocs<sh_type, size, big_endian>::emit_copy_reloc(
   bool is_ordinary;
   unsigned int shndx = sym->shndx(&is_ordinary);
   gold_assert(is_ordinary);
-  typename elfcpp::Elf_types<size>::Elf_WXword addralign =
-    sym->object()->section_addralign(shndx);
+  typename elfcpp::Elf_types<size>::Elf_WXword addralign;
+
+  {
+    // Lock the object so we can read from it.  This is only called
+    // single-threaded from scan_relocs, so it is OK to lock.
+    // Unfortunately we have no way to pass in a Task token.
+    const Task* dummy_task = reinterpret_cast<const Task*>(-1);
+    Object* obj = sym->object();
+    Task_lock_obj<Object> tl(dummy_task, obj);
+    addralign = obj->section_addralign(shndx);
+  }
 
   typename Sized_symbol<size>::Value_type value = sym->value();
   while ((value & (addralign - 1)) != 0)
index 6bbf02e4b751c6ce55d2934e878dcb9cdc2a519c..564ca39ebba2a1e5dc10f931690540ac9b66b9cb 100644 (file)
@@ -359,6 +359,7 @@ queue_middle_tasks(const General_options& options,
            p != input_objects->relobj_end();
            ++p)
         {
+          Task_lock_obj<Object> tlo(task, *p);
           (*p)->layout(symtab, layout, NULL);
         }
     }
index 09cb1d4892b84d5d983368c13b559c33d1dd965e..a132875873ec9ea50fdc06f2a0974107409a11ab 100644 (file)
@@ -182,6 +182,11 @@ preprocess_for_unique_sections(const std::vector<Section_id>& id_section,
       section_size_type plen;
       if (section_contents == NULL)
         {
+          // Lock the object so we can read from it.  This is only called
+          // single-threaded from queue_middle_tasks, so it is OK to lock.
+          // Unfortunately we have no way to pass in a Task token.
+          const Task* dummy_task = reinterpret_cast<const Task*>(-1);
+          Task_lock_obj<Object> tl(dummy_task, secn.first);
           const unsigned char* contents;
           contents = secn.first->section_contents(secn.second,
                                                   &plen,
@@ -237,6 +242,11 @@ get_section_contents(bool first_iteration,
 
   if (first_iteration)
     {
+      // Lock the object so we can read from it.  This is only called
+      // single-threaded from queue_middle_tasks, so it is OK to lock.
+      // Unfortunately we have no way to pass in a Task token.
+      const Task* dummy_task = reinterpret_cast<const Task*>(-1);
+      Task_lock_obj<Object> tl(dummy_task, secn.first);
       contents = secn.first->section_contents(secn.second,
                                               &plen,
                                               false);
@@ -363,6 +373,12 @@ get_section_contents(bool first_iteration,
               if (!first_iteration)
                 continue;
 
+              // Lock the object so we can read from it.  This is only called
+              // single-threaded from queue_middle_tasks, so it is OK to lock.
+              // Unfortunately we have no way to pass in a Task token.
+              const Task* dummy_task = reinterpret_cast<const Task*>(-1);
+              Task_lock_obj<Object> tl(dummy_task, it_v->first);
+
               uint64_t secn_flags = (it_v->first)->section_flags(it_v->second);
               // This reloc points to a merge section.  Hash the
               // contents of this section.
@@ -682,6 +698,12 @@ Icf::find_identical_sections(const Input_objects* input_objects,
        p != input_objects->relobj_end();
        ++p)
     {
+      // Lock the object so we can read from it.  This is only called
+      // single-threaded from queue_middle_tasks, so it is OK to lock.
+      // Unfortunately we have no way to pass in a Task token.
+      const Task* dummy_task = reinterpret_cast<const Task*>(-1);
+      Task_lock_obj<Object> tl(dummy_task, *p);
+
       for (unsigned int i = 0;i < (*p)->shnum(); ++i)
         {
          const char* section_name = (*p)->section_name(i).c_str();
index a3ba52ba611b73b69ec8245549704701741ad153..0cde51e21465a947a1eb6f43050c06c3b117989a 100644 (file)
@@ -347,6 +347,12 @@ Mapfile::print_discarded_sections(const Input_objects* input_objects)
        ++p)
     {
       Relobj* relobj = *p;
+      // Lock the object so we can read from it.  This is only called
+      // single-threaded from Layout_task_runner, so it is OK to lock.
+      // Unfortunately we have no way to pass in a Task token.
+      const Task* dummy_task = reinterpret_cast<const Task*>(-1);
+      Task_lock_obj<Object> tl(dummy_task, relobj);
+
       unsigned int shnum = relobj->shnum();
       for (unsigned int i = 0; i < shnum; ++i)
        {
index 7dd1fa389f095be66091fc0bfb0380a49d5efffa..a3569c928c67cac0ff8b738071201f350686bda4 100644 (file)
@@ -361,7 +361,14 @@ Plugin_manager::layout_deferred_objects()
   for (obj = this->deferred_layout_objects_.begin();
        obj != this->deferred_layout_objects_.end();
        ++obj)
-    (*obj)->layout_deferred_sections(this->layout_);
+    {
+      // Lock the object so we can read from it.  This is only called
+      // single-threaded from queue_middle_tasks, so it is OK to lock.
+      // Unfortunately we have no way to pass in a Task token.
+      const Task* dummy_task = reinterpret_cast<const Task*>(-1);
+      Task_lock_obj<Object> tl(dummy_task, *obj);
+      (*obj)->layout_deferred_sections(this->layout_);
+    }
 }
 
 // Call the cleanup handlers.
This page took 0.034516 seconds and 4 git commands to generate.