* powerpc.cc (Stub_control::can_add_to_stub_group): Don't set
[deliverable/binutils-gdb.git] / gold / output.cc
index f2321b77fc54188a0b41afb9affb560aced4dfdc..22c0bf02b56f7b6cdcc914478b88baba0e037ae3 100644 (file)
@@ -2422,7 +2422,7 @@ Output_section::add_input_section(Layout* layout,
     input_section_size = uncompressed_size;
 
   off_t offset_in_section;
-  off_t aligned_offset_in_section;
+
   if (this->has_fixed_layout())
     {
       // For incremental updates, find a chunk of unused space in the section.
@@ -2432,17 +2432,15 @@ Output_section::add_input_section(Layout* layout,
         gold_fallback(_("out of patch space in section %s; "
                        "relink with --incremental-full"),
                      this->name());
-      aligned_offset_in_section = offset_in_section;
-    }
-  else
-    {
-      offset_in_section = this->current_data_size_for_child();
-      aligned_offset_in_section = align_address(offset_in_section,
-                                               addralign);
-      this->set_current_data_size_for_child(aligned_offset_in_section
-                                           + input_section_size);
+      return offset_in_section;
     }
 
+  offset_in_section = this->current_data_size_for_child();
+  off_t aligned_offset_in_section = align_address(offset_in_section,
+                                                 addralign);
+  this->set_current_data_size_for_child(aligned_offset_in_section
+                                       + input_section_size);
+
   // Determine if we want to delay code-fill generation until the output
   // section is written.  When the target is relaxing, we want to delay fill
   // generating to avoid adjusting them during relaxation.  Also, if we are
@@ -2507,14 +2505,6 @@ Output_section::add_input_section(Layout* layout,
               this->set_input_section_order_specified();
             }
         }
-      if (this->has_fixed_layout())
-       {
-         // For incremental updates, finalize the address and offset now.
-         uint64_t addr = this->address();
-         isecn.set_address_and_file_offset(addr + aligned_offset_in_section,
-                                           aligned_offset_in_section,
-                                           this->offset());
-       }
       this->input_sections_.push_back(isecn);
     }
 
@@ -3399,19 +3389,6 @@ Output_section::Input_section_sort_compare::operator()(
       return s1.index() < s2.index();
     }
 
-  // Some input section names have special ordering requirements.
-  int o1 = Layout::special_ordering_of_input_section(s1.section_name().c_str());
-  int o2 = Layout::special_ordering_of_input_section(s2.section_name().c_str());
-  if (o1 != o2)
-    {
-      if (o1 < 0)
-       return false;
-      else if (o2 < 0)
-       return true;
-      else
-       return o1 < o2;
-    }
-
   // A section with a priority follows a section without a priority.
   bool s1_has_priority = s1.has_priority();
   bool s2_has_priority = s2.has_priority();
@@ -3518,6 +3495,42 @@ Output_section::Input_section_sort_section_order_index_compare::operator()(
   return s1_secn_index < s2_secn_index;
 }
 
+// Return true if S1 should come before S2.  This is the sort comparison
+// function for .text to sort sections with prefixes
+// .text.{unlikely,exit,startup,hot} before other sections.
+bool
+Output_section::Input_section_sort_section_name_special_ordering_compare
+  ::operator()(
+    const Output_section::Input_section_sort_entry& s1,
+    const Output_section::Input_section_sort_entry& s2) const
+{
+  // We sort all the sections with no names to the end.
+  if (!s1.section_has_name() || !s2.section_has_name())
+    {
+      if (s1.section_has_name())
+       return true;
+      if (s2.section_has_name())
+       return false;
+      return s1.index() < s2.index();
+    }
+  // Some input section names have special ordering requirements.
+  int o1 = Layout::special_ordering_of_input_section(s1.section_name().c_str());
+  int o2 = Layout::special_ordering_of_input_section(s2.section_name().c_str());
+  if (o1 != o2)
+    {
+      if (o1 < 0)
+       return false;
+      else if (o2 < 0)
+       return true;
+      else
+       return o1 < o2;
+    }
+
+  // Keep input order otherwise.
+  return s1.index() < s2.index();  
+}
+
 // This updates the section order index of input sections according to the
 // the order specified in the mapping from Section id to order index.
 
@@ -3586,6 +3599,9 @@ Output_section::sort_attached_input_sections()
           || this->type() == elfcpp::SHT_FINI_ARRAY)
         std::sort(sort_list.begin(), sort_list.end(),
                  Input_section_sort_init_fini_compare());
+      else if (strcmp(this->name(), ".text") == 0)
+        std::sort(sort_list.begin(), sort_list.end(),
+                 Input_section_sort_section_name_special_ordering_compare());
       else
         std::sort(sort_list.begin(), sort_list.end(),
                  Input_section_sort_compare());
This page took 0.024036 seconds and 4 git commands to generate.