This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/binutils-2_28-branch] gold: Add put_ch_reserved to 64-bit Chdr_write
- From: H.J.Lu <hjl at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 28 Jul 2017 20:48:56 -0000
- Subject: [binutils-gdb/binutils-2_28-branch] gold: Add put_ch_reserved to 64-bit Chdr_write
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a595e022494154dcc2472784252394a035c16cb7
commit a595e022494154dcc2472784252394a035c16cb7
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Jul 28 13:39:42 2017 -0700
gold: Add put_ch_reserved to 64-bit Chdr_write
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.
(cherry picked from commit 49ba15a23a9d3d8a109ce2fd5053822eee7f1fdf)
Diff:
---
elfcpp/ChangeLog | 7 +++++++
elfcpp/elfcpp.h | 17 +++++++++++++++++
gold/ChangeLog | 6 ++++++
gold/compressed_output.cc | 4 ++++
4 files changed, 34 insertions(+)
diff --git a/elfcpp/ChangeLog b/elfcpp/ChangeLog
index 6a61d61..b1db015 100644
--- a/elfcpp/ChangeLog
+++ b/elfcpp/ChangeLog
@@ -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-01-02 Alan Modra <amodra@gmail.com>
Update year range in copyright notice of all files.
diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h
index 43ba5c4..98e1ada 100644
--- a/elfcpp/elfcpp.h
+++ b/elfcpp/elfcpp.h
@@ -1345,10 +1345,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>
diff --git a/gold/ChangeLog b/gold/ChangeLog
index d27713d..7be51ff 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -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-06 Han Shen <shenhan@google.com>
PR gold/21491
diff --git a/gold/compressed_output.cc b/gold/compressed_output.cc
index 4374ba1..45077f7 100644
--- a/gold/compressed_output.cc
+++ b/gold/compressed_output.cc
@@ -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