gold: Add put_ch_reserved to 64-bit Chdr_write
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 28 Jul 2017 20:39:42 +0000 (13:39 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 28 Jul 2017 20:40:01 +0000 (13:40 -0700)
The 64-bit ELF compression header has a reserved field.  It should be
cleared to avoid random bits in it.

elfcpp/

PR gold/21857
* elfcpp.h (Chdr_write): Add put_ch_reserved.
(Chdr_write<64, true>::put_ch_reserved): New.
(Chdr_write<64, false>::put_ch_reserved): Likewise.

gold/

PR gold/21857
* compressed_output.cc (Output_compressed_section::set_final_data_size):
Call put_ch_reserved to clear the reserved field for 64-bit ELF.

elfcpp/ChangeLog
elfcpp/elfcpp.h
gold/ChangeLog
gold/compressed_output.cc

index fc864bf6fadc4e6719971fb0efe97d6915ac878f..f669248626837b93180e6d65bc7f1826518ae230 100644 (file)
@@ -1,3 +1,10 @@
+2017-07-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gold/21857
+       * elfcpp.h (Chdr_write): Add put_ch_reserved.
+       (Chdr_write<64, true>::put_ch_reserved): New.
+       (Chdr_write<64, false>::put_ch_reserved): Likewise.
+
 2017-07-03  Alan Modra  <amodra@gmail.com>
 
        * dwarf.h (DW_FIRST_IDX, DW_IDX, DW_IDX_DUP, DW_END_IDX): Define,
index a57f5476f1205f1d1d7c558d4c77f74cbfcde872..cccec4c2560832edd73986d4c70f52ff15327cb9 100644 (file)
@@ -1351,10 +1351,27 @@ class Chdr_write
   put_ch_addralign(typename Elf_types<size>::Elf_WXword v)
   { this->p_->ch_addralign = Convert<size, big_endian>::convert_host(v); }
 
+  void
+  put_ch_reserved(Elf_Word);
+
  private:
   internal::Chdr_data<size>* p_;
 };
 
+template<>
+inline void
+elfcpp::Chdr_write<64, true>::put_ch_reserved(Elf_Word v)
+{
+  this->p_->ch_reserved = v;
+}
+
+template<>
+inline void
+elfcpp::Chdr_write<64, false>::put_ch_reserved(Elf_Word v)
+{
+  this->p_->ch_reserved = v;
+}
+
 // Accessor class for an ELF segment header.
 
 template<int size, bool big_endian>
index 502af851c55d7d25b3a4f79ca96e461aeb9629e6..fdac9313c3c3463872784273502741ca2f3e7848 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gold/21857
+       * compressed_output.cc (Output_compressed_section::set_final_data_size):
+       Call put_ch_reserved to clear the reserved field for 64-bit ELF.
+
 2017-07-26  H.J. Lu  <hongjiu.lu@intel.com>
 
        * mips.cc (Mips_relocate_functions): Add "llu" suffix to
index 4374ba1bb74182e4e467d03c219d52e84395ee75..45077f70203d89b8ffe94a1c9f3aa8856c1b00e9 100644 (file)
@@ -286,6 +286,8 @@ Output_compressed_section::set_final_data_size()
                  chdr.put_ch_type(elfcpp::ELFCOMPRESS_ZLIB);
                  chdr.put_ch_size(uncompressed_size);
                  chdr.put_ch_addralign(addralign);
+                 // Clear the reserved field.
+                 chdr.put_ch_reserved(0);
                }
              else
                {
@@ -293,6 +295,8 @@ Output_compressed_section::set_final_data_size()
                  chdr.put_ch_type(elfcpp::ELFCOMPRESS_ZLIB);
                  chdr.put_ch_size(uncompressed_size);
                  chdr.put_ch_addralign(addralign);
+                 // Clear the reserved field.
+                 chdr.put_ch_reserved(0);
                }
            }
          else
This page took 0.027928 seconds and 4 git commands to generate.