]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* layout.cc (Layout::layout): If the output section flags change,
authorIan Lance Taylor <ian@airs.com>
Fri, 6 May 2011 14:58:17 +0000 (14:58 +0000)
committerIan Lance Taylor <ian@airs.com>
Fri, 6 May 2011 14:58:17 +0000 (14:58 +0000)
update the ordering.

gold/ChangeLog
gold/layout.cc

index cf93c509c77cca6e79ae316488dfb0be4442f816..081f900c05d9c066207bc715fc943a1ae6c209ee 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-06  Ian Lance Taylor  <iant@google.com>
+
+       * layout.cc (Layout::layout): If the output section flags change,
+       update the ordering.
+
 2011-03-14  Ian Lance Taylor  <iant@google.com>
 
        * script-sections.cc (Sort_output_sections::script_compare):
index 70efef9743d61088df3e33e5796625c87ce19869..b7c4fa5944022d0402a6b06ee88094471a4032e1 100644 (file)
@@ -674,8 +674,21 @@ Layout::layout(Sized_relobj<size, big_endian>* object, unsigned int shndx,
 
   // FIXME: Handle SHF_LINK_ORDER somewhere.
 
+  elfcpp::Elf_Xword orig_flags = os->flags();
+
   *off = os->add_input_section(this, object, shndx, name, shdr, reloc_shndx,
                               this->script_options_->saw_sections_clause());
+
+  // If the flags changed, we may have to change the order.
+  if ((orig_flags & elfcpp::SHF_ALLOC) != 0)
+    {
+      orig_flags &= (elfcpp::SHF_WRITE | elfcpp::SHF_EXECINSTR);
+      elfcpp::Elf_Xword new_flags =
+       os->flags() & (elfcpp::SHF_WRITE | elfcpp::SHF_EXECINSTR);
+      if (orig_flags != new_flags)
+       os->set_order(this->default_section_order(os, false));
+    }
+
   this->have_added_input_section_ = true;
 
   return os;