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: Set PT_TLS to always have PF_R


In PR 10450 HJ points out that the ELF ABI says that a PT_TLS segment
should always have a p_flags value of PF_R.  I committed this patch to
implement that in gold.

Ian


2009-12-30  Ian Lance Taylor  <iant@google.com>

	PR 10450
	* output.cc (Output_segment::Output_segment): If PT_TLS, set the
	flags to PF_R.
	(Output_segment::add_output_section): Don't change the flags if
	the type is PT_TLS.


Index: output.cc
===================================================================
RCS file: /cvs/src/src/gold/output.cc,v
retrieving revision 1.110
diff -p -u -r1.110 output.cc
--- output.cc	30 Dec 2009 06:57:17 -0000	1.110
+++ output.cc	30 Dec 2009 19:28:33 -0000
@@ -3063,6 +3063,10 @@ Output_segment::Output_segment(elfcpp::E
     are_addresses_set_(false),
     is_large_data_segment_(false)
 {
+  // The ELF ABI specifies that a PT_TLS segment always has PF_R as
+  // the flags.
+  if (type == elfcpp::PT_TLS)
+    this->flags_ = elfcpp::PF_R;
 }
 
 // Add an Output_section to an Output_segment.
@@ -3077,8 +3081,11 @@ Output_segment::add_output_section(Outpu
   gold_assert(os->is_large_data_section() == this->is_large_data_segment());
   gold_assert(this->type() == elfcpp::PT_LOAD || !do_sort);
 
-  // Update the segment flags.
-  this->flags_ |= seg_flags;
+  // Update the segment flags.  The ELF ABI specifies that a PT_TLS
+  // segment should always have PF_R as the flags, regardless of the
+  // associated sections.
+  if (this->type() != elfcpp::PT_TLS)
+    this->flags_ |= seg_flags;
 
   Output_segment::Output_data_list* pdl;
   if (os->type() == elfcpp::SHT_NOBITS)

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