This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gold patch committed: Correctly mark .init_array as relro


PR 13850 points out that gold does not correctly mark .init_array and
friends as relro.  This patch fixes the problem.  Committed to mainline.

Ian


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.


Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.222
diff -u -r1.222 layout.cc
--- layout.cc	19 Oct 2011 15:05:58 -0000	1.222
+++ layout.cc	15 Mar 2012 16:29:33 -0000
@@ -1379,25 +1379,27 @@
   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)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]