elfcpp/:
authorIan Lance Taylor <ian@airs.com>
Tue, 19 Jan 2010 17:55:49 +0000 (17:55 +0000)
committerIan Lance Taylor <ian@airs.com>
Tue, 19 Jan 2010 17:55:49 +0000 (17:55 +0000)
* elfcpp.h (PN_XNUM): Define.
gold/:
* output.cc (Output_section_headers::do_sized_write): Write large
segment count to sh_info field.
(Output_file_header::do_sized_write): For large segment count,
write PN_XNUM to e_phnum field.

elfcpp/ChangeLog
elfcpp/elfcpp.h
gold/ChangeLog
gold/output.cc

index d2d6251948638359b707d142b4cb9883c8c697e6..ab3d2df581615dbb6429613c72f75b9b7092e3c4 100644 (file)
@@ -1,3 +1,7 @@
+2010-01-19  Ian Lance Taylor  <iant@google.com>
+
+       * elfcpp.h (PN_XNUM): Define.
+
 2009-12-14  Ian Lance Taylor  <iant@google.com>
 
        * elfcpp_file.h: Revert last patch.
index 0b2c871d1939d159f35d577ff46e187d3a0c3ebf..8ecbc0ae4cdfbaa9380ed36d23b85cc2abba1500 100644 (file)
@@ -302,6 +302,15 @@ enum EM
   // Old MN10200 objects used 0xdead (EM_MN10200 is correct).
 };
 
+// A special value found in the Ehdr e_phnum field.
+
+enum
+{
+  // Number of program segments stored in sh_info field of first
+  // section headre.
+  PN_XNUM = 0xffff
+};
+
 // Special section indices.
 
 enum
index 0c6e1a02af3a91b194cab1cbe93ac5c1cc192c47..2bf56d41402a864bb9fdfbea91c2a3888e49113f 100644 (file)
@@ -1,3 +1,10 @@
+2010-01-19  Ian Lance Taylor  <iant@google.com>
+
+       * output.cc (Output_section_headers::do_sized_write): Write large
+       segment count to sh_info field.
+       (Output_file_header::do_sized_write): For large segment count,
+       write PN_XNUM to e_phnum field.
+
 2010-01-15  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
 
        * arm.cc (Arm_relocate_functions::thm_jump6): New function.
index 634249fa303137431ee0608a42e9196cdf871b29..2a97078c7410812581ec7a890bf248bf782d865e 100644 (file)
@@ -213,7 +213,9 @@ Output_section_headers::do_sized_write(Output_file* of)
     else
       oshdr.put_sh_link(shstrndx);
 
-    oshdr.put_sh_info(0);
+    size_t segment_count = this->segment_list_->size();
+    oshdr.put_sh_info(segment_count >= elfcpp::PN_XNUM ? segment_count : 0);
+
     oshdr.put_sh_addralign(0);
     oshdr.put_sh_entsize(0);
   }
@@ -470,8 +472,11 @@ Output_file_header::do_sized_write(Output_file* of)
   else
     {
       oehdr.put_e_phentsize(elfcpp::Elf_sizes<size>::phdr_size);
-      oehdr.put_e_phnum(this->segment_header_->data_size()
-                       / elfcpp::Elf_sizes<size>::phdr_size);
+      size_t phnum = (this->segment_header_->data_size()
+                     / elfcpp::Elf_sizes<size>::phdr_size);
+      if (phnum > elfcpp::PN_XNUM)
+       phnum = elfcpp::PN_XNUM;
+      oehdr.put_e_phnum(phnum);
     }
 
   oehdr.put_e_shentsize(elfcpp::Elf_sizes<size>::shdr_size);