PR gold/13850
authorIan Lance Taylor <ian@airs.com>
Thu, 15 Mar 2012 16:32:22 +0000 (16:32 +0000)
committerIan Lance Taylor <ian@airs.com>
Thu, 15 Mar 2012 16:32:22 +0000 (16:32 +0000)
* layout.cc (Layout::make_output_section): Correctly mark
SHT_INIT_ARRAY, et. al., as relro.

gold/ChangeLog
gold/layout.cc

index 5bdda03..0c1a7e1 100644 (file)
@@ -1,3 +1,9 @@
+2012-03-15  Ian Lance Taylor  <iant@google.com>
+
+       PR gold/13850
+       * layout.cc (Layout::make_output_section): Correctly mark
+       SHT_INIT_ARRAY, et. al., as relro.
+
 2012-03-14  Doug Kwan  <dougkwan@google.com>
 
        * gold/arm.cc (Target_arm::Scan::global): Generate R_ARM_GLOB_DAT
index a4ef31a..c120376 100644 (file)
@@ -1379,25 +1379,27 @@ Layout::make_output_section(const char* name, elfcpp::Elf_Word type,
   bool is_relro_local = false;
   if (!this->script_options_->saw_sections_clause()
       && parameters->options().relro()
-      && type == elfcpp::SHT_PROGBITS
       && (flags & elfcpp::SHF_ALLOC) != 0
       && (flags & elfcpp::SHF_WRITE) != 0)
     {
-      if (strcmp(name, ".data.rel.ro") == 0)
-       is_relro = true;
-      else if (strcmp(name, ".data.rel.ro.local") == 0)
+      if (type == elfcpp::SHT_PROGBITS)
        {
-         is_relro = true;
-         is_relro_local = true;
+         if (strcmp(name, ".data.rel.ro") == 0)
+           is_relro = true;
+         else if (strcmp(name, ".data.rel.ro.local") == 0)
+           {
+             is_relro = true;
+             is_relro_local = true;
+           }
+         else if (strcmp(name, ".ctors") == 0
+                  || strcmp(name, ".dtors") == 0
+                  || strcmp(name, ".jcr") == 0)
+           is_relro = true;
        }
       else if (type == elfcpp::SHT_INIT_ARRAY
               || type == elfcpp::SHT_FINI_ARRAY
               || type == elfcpp::SHT_PREINIT_ARRAY)
        is_relro = true;
-      else if (strcmp(name, ".ctors") == 0
-              || strcmp(name, ".dtors") == 0
-              || strcmp(name, ".jcr") == 0)
-       is_relro = true;
     }
 
   if (is_relro)