public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* gold patch committed: Correct handling of writable .eh_frame section
@ 2011-06-18 22:32 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2011-06-18 22:32 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 349 bytes --]

This gold patch corrects the handling of a writable .eh_frame section by
making sure that the writable .eh_frame winds up as a relro section.
This fixes PR 12745.  Committed to mainline.

Ian


2011-06-18  Ian Lance Taylor  <iant@google.com>

	PR gold/12745
	* layout.cc (Layout::layout_eh_frame): Correct handling of
	writable .eh_frame section.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1603 bytes --]

Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.200
diff -u -p -r1.200 layout.cc
--- layout.cc	17 Jun 2011 13:00:01 -0000	1.200
+++ layout.cc	18 Jun 2011 22:27:02 -0000
@@ -1140,6 +1140,8 @@ Layout::layout_eh_frame(Sized_relobj_fil
 
   gold_assert(this->eh_frame_section_ == os);
 
+  elfcpp::Elf_Xword orig_flags = os->flags();
+
   if (!parameters->incremental()
       && this->eh_frame_data_->add_ehframe_input_section(object,
 							 symbols,
@@ -1153,8 +1155,12 @@ Layout::layout_eh_frame(Sized_relobj_fil
       os->update_flags_for_input_section(shdr.get_sh_flags());
 
       // A writable .eh_frame section is a RELRO section.
-      if ((shdr.get_sh_flags() & elfcpp::SHF_WRITE) != 0)
-	os->set_is_relro();
+      if ((orig_flags & (elfcpp::SHF_WRITE | elfcpp::SHF_EXECINSTR))
+	  != (os->flags() & (elfcpp::SHF_WRITE | elfcpp::SHF_EXECINSTR)))
+	{
+	  os->set_is_relro();
+	  os->set_order(ORDER_RELRO);
+	}
 
       // We found a .eh_frame section we are going to optimize, so now
       // we can add the set of optimized sections to the output
@@ -1176,6 +1182,10 @@ Layout::layout_eh_frame(Sized_relobj_fil
       *off = os->add_input_section(this, object, shndx, name, shdr, reloc_shndx,
 				   saw_sections_clause);
       this->have_added_input_section_ = true;
+
+      if ((orig_flags & (elfcpp::SHF_WRITE | elfcpp::SHF_EXECINSTR))
+	  != (os->flags() & (elfcpp::SHF_WRITE | elfcpp::SHF_EXECINSTR)))
+	os->set_order(this->default_section_order(os, false));
     }
 
   return os;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-18 22:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-18 22:32 gold patch committed: Correct handling of writable .eh_frame section Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).