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.
This commit is contained in:
H.J. Lu 2017-07-28 13:39:42 -07:00
parent 894dde0ba7
commit 49ba15a23a
4 changed files with 34 additions and 0 deletions

View 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>