+// Accessor class for an ELF compression header.
+
+template<int size, bool big_endian>
+class Chdr
+{
+ public:
+ Chdr(const unsigned char* p)
+ : p_(reinterpret_cast<const internal::Chdr_data<size>*>(p))
+ { }
+
+ template<typename File>
+ Chdr(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Chdr_data<size>*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
+ Elf_Word
+ get_ch_type() const
+ { return Convert<size, big_endian>::convert_host(this->p_->ch_type); }
+
+ typename Elf_types<size>::Elf_WXword
+ get_ch_size() const
+ { return Convert<size, big_endian>::convert_host(this->p_->ch_size); }
+
+ typename Elf_types<size>::Elf_WXword
+ get_ch_addralign() const
+ { return
+ Convert<size, big_endian>::convert_host(this->p_->ch_addralign); }
+
+ private:
+ const internal::Chdr_data<size>* p_;
+};
+
+// Write class for an ELF compression header.
+
+template<int size, bool big_endian>
+class Chdr_write
+{
+ public:
+ Chdr_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Chdr_data<size>*>(p))
+ { }
+
+ void
+ put_ch_type(typename Elf_types<size>::Elf_WXword v)
+ { this->p_->ch_type = Convert<size, big_endian>::convert_host(v); }
+
+ void
+ put_ch_size(typename Elf_types<size>::Elf_WXword v)
+ { this->p_->ch_size = Convert<size, big_endian>::convert_host(v); }
+
+ void
+ put_ch_addralign(typename Elf_types<size>::Elf_WXword v)
+ { this->p_->ch_addralign = Convert<size, big_endian>::convert_host(v); }
+
+ private:
+ internal::Chdr_data<size>* p_;
+};
+