+// Writer class for an ELF symbol table entry.
+
+template<int size, bool big_endian>
+class Sym_write
+{
+ public:
+ Sym_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Sym_data<size>*>(p))
+ { }
+
+ void
+ put_st_name(Elf_Word v)
+ { this->p_->st_name = Convert<32, big_endian>::convert_host(v); }
+
+ void
+ put_st_value(typename Elf_types<size>::Elf_Addr v)
+ { this->p_->st_value = Convert<size, big_endian>::convert_host(v); }
+
+ void
+ put_st_size(typename Elf_types<size>::Elf_WXword v)
+ { this->p_->st_size = Convert<size, big_endian>::convert_host(v); }
+
+ void
+ put_st_info(unsigned char v)
+ { this->p_->st_info = v; }
+
+ void
+ put_st_info(STB bind, STT type)
+ { this->p_->st_info = elf_st_info(bind, type); }
+
+ void
+ put_st_other(unsigned char v)
+ { this->p_->st_other = v; }
+
+ void
+ put_st_other(STV vis, unsigned char nonvis)
+ { this->p_->st_other = elf_st_other(vis, nonvis); }
+
+ void
+ put_st_shndx(Elf_Half v)
+ { this->p_->st_shndx = Convert<16, big_endian>::convert_host(v); }
+
+ Sym<size, big_endian>
+ sym()
+ { return Sym<size, big_endian>(reinterpret_cast<unsigned char*>(this->p_)); }
+
+ private:
+ internal::Sym_data<size>* p_;
+};
+
+// Accessor classes for an ELF REL relocation entry.
+
+template<int size, bool big_endian>
+class Rel
+{
+ public:
+ Rel(const unsigned char* p)
+ : p_(reinterpret_cast<const internal::Rel_data<size>*>(p))
+ { }
+
+ template<typename File>
+ Rel(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Rel_data<size>*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
+ typename Elf_types<size>::Elf_Addr
+ get_r_offset() const
+ { return Convert<size, big_endian>::convert_host(this->p_->r_offset); }
+
+ typename Elf_types<size>::Elf_WXword
+ get_r_info() const
+ { return Convert<size, big_endian>::convert_host(this->p_->r_info); }
+
+ private:
+ const internal::Rel_data<size>* p_;
+};
+
+// Writer class for an ELF Rel relocation.
+
+template<int size, bool big_endian>
+class Rel_write
+{
+ public:
+ Rel_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Rel_data<size>*>(p))
+ { }
+
+ void
+ put_r_offset(typename Elf_types<size>::Elf_Addr v)
+ { this->p_->r_offset = Convert<size, big_endian>::convert_host(v); }
+
+ void
+ put_r_info(typename Elf_types<size>::Elf_WXword v)
+ { this->p_->r_info = Convert<size, big_endian>::convert_host(v); }
+
+ private:
+ internal::Rel_data<size>* p_;
+};
+
+// Accessor class for an ELF Rela relocation.
+
+template<int size, bool big_endian>
+class Rela
+{
+ public:
+ Rela(const unsigned char* p)
+ : p_(reinterpret_cast<const internal::Rela_data<size>*>(p))
+ { }
+
+ template<typename File>
+ Rela(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Rela_data<size>*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
+ typename Elf_types<size>::Elf_Addr
+ get_r_offset() const
+ { return Convert<size, big_endian>::convert_host(this->p_->r_offset); }
+
+ typename Elf_types<size>::Elf_WXword
+ get_r_info() const
+ { return Convert<size, big_endian>::convert_host(this->p_->r_info); }
+
+ typename Elf_types<size>::Elf_Swxword
+ get_r_addend() const
+ { return Convert<size, big_endian>::convert_host(this->p_->r_addend); }
+
+ private:
+ const internal::Rela_data<size>* p_;
+};
+
+// Writer class for an ELF Rela relocation.
+
+template<int size, bool big_endian>
+class Rela_write
+{
+ public:
+ Rela_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Rela_data<size>*>(p))
+ { }
+
+ void
+ put_r_offset(typename Elf_types<size>::Elf_Addr v)
+ { this->p_->r_offset = Convert<size, big_endian>::convert_host(v); }
+
+ void
+ put_r_info(typename Elf_types<size>::Elf_WXword v)
+ { this->p_->r_info = Convert<size, big_endian>::convert_host(v); }
+
+ void
+ put_r_addend(typename Elf_types<size>::Elf_Swxword v)
+ { this->p_->r_addend = Convert<size, big_endian>::convert_host(v); }
+
+ private:
+ internal::Rela_data<size>* p_;
+};
+
+// MIPS-64 has a non-standard relocation layout.
+
+template<bool big_endian>
+class Mips64_rel
+{
+ public:
+ Mips64_rel(const unsigned char* p)
+ : p_(reinterpret_cast<const internal::Mips64_rel_data*>(p))
+ { }
+
+ template<typename File>
+ Mips64_rel(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Mips64_rel_data*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
+ typename Elf_types<64>::Elf_Addr
+ get_r_offset() const
+ { return Convert<64, big_endian>::convert_host(this->p_->r_offset); }
+
+ Elf_Word
+ get_r_sym() const
+ { return Convert<32, big_endian>::convert_host(this->p_->r_sym); }
+
+ unsigned char
+ get_r_ssym() const
+ { return this->p_->r_ssym; }
+
+ unsigned char
+ get_r_type() const
+ { return this->p_->r_type; }
+
+ unsigned char
+ get_r_type2() const
+ { return this->p_->r_type2; }
+
+ unsigned char
+ get_r_type3() const
+ { return this->p_->r_type3; }
+
+ private:
+ const internal::Mips64_rel_data* p_;
+};
+
+template<bool big_endian>
+class Mips64_rel_write
+{
+ public:
+ Mips64_rel_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Mips64_rel_data*>(p))
+ { }
+
+ void
+ put_r_offset(typename Elf_types<64>::Elf_Addr v)
+ { this->p_->r_offset = Convert<64, big_endian>::convert_host(v); }
+
+ void
+ put_r_sym(Elf_Word v)
+ { this->p_->r_sym = Convert<32, big_endian>::convert_host(v); }
+
+ void
+ put_r_ssym(unsigned char v)
+ { this->p_->r_ssym = v; }
+
+ void
+ put_r_type(unsigned char v)
+ { this->p_->r_type = v; }
+
+ void
+ put_r_type2(unsigned char v)
+ { this->p_->r_type2 = v; }
+
+ void
+ put_r_type3(unsigned char v)
+ { this->p_->r_type3 = v; }
+
+ private:
+ internal::Mips64_rel_data* p_;
+};
+
+template<bool big_endian>
+class Mips64_rela
+{
+ public:
+ Mips64_rela(const unsigned char* p)
+ : p_(reinterpret_cast<const internal::Mips64_rela_data*>(p))
+ { }
+
+ template<typename File>
+ Mips64_rela(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Mips64_rela_data*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
+ typename Elf_types<64>::Elf_Addr
+ get_r_offset() const
+ { return Convert<64, big_endian>::convert_host(this->p_->r_offset); }
+
+ Elf_Word
+ get_r_sym() const
+ { return Convert<32, big_endian>::convert_host(this->p_->r_sym); }
+
+ unsigned char
+ get_r_ssym() const
+ { return this->p_->r_ssym; }
+
+ unsigned char
+ get_r_type() const
+ { return this->p_->r_type; }
+
+ unsigned char
+ get_r_type2() const
+ { return this->p_->r_type2; }
+
+ unsigned char
+ get_r_type3() const
+ { return this->p_->r_type3; }
+
+ typename Elf_types<64>::Elf_Swxword
+ get_r_addend() const
+ { return Convert<64, big_endian>::convert_host(this->p_->r_addend); }
+
+ private:
+ const internal::Mips64_rela_data* p_;
+};
+
+template<bool big_endian>
+class Mips64_rela_write
+{
+ public:
+ Mips64_rela_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Mips64_rela_data*>(p))
+ { }
+
+ void
+ put_r_offset(typename Elf_types<64>::Elf_Addr v)
+ { this->p_->r_offset = Convert<64, big_endian>::convert_host(v); }
+
+ void
+ put_r_sym(Elf_Word v)
+ { this->p_->r_sym = Convert<32, big_endian>::convert_host(v); }
+
+ void
+ put_r_ssym(unsigned char v)
+ { this->p_->r_ssym = v; }
+
+ void
+ put_r_type(unsigned char v)
+ { this->p_->r_type = v; }
+
+ void
+ put_r_type2(unsigned char v)
+ { this->p_->r_type2 = v; }
+
+ void
+ put_r_type3(unsigned char v)
+ { this->p_->r_type3 = v; }
+
+ void
+ put_r_addend(typename Elf_types<64>::Elf_Swxword v)
+ { this->p_->r_addend = Convert<64, big_endian>::convert_host(v); }
+
+ private:
+ internal::Mips64_rela_data* p_;
+};
+
+// Accessor classes for entries in the ELF SHT_DYNAMIC section aka
+// PT_DYNAMIC segment.
+
+template<int size, bool big_endian>
+class Dyn
+{
+ public:
+ Dyn(const unsigned char* p)
+ : p_(reinterpret_cast<const internal::Dyn_data<size>*>(p))
+ { }
+
+ template<typename File>
+ Dyn(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Dyn_data<size>*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
+ typename Elf_types<size>::Elf_Swxword
+ get_d_tag() const
+ { return Convert<size, big_endian>::convert_host(this->p_->d_tag); }
+
+ typename Elf_types<size>::Elf_WXword
+ get_d_val() const
+ { return Convert<size, big_endian>::convert_host(this->p_->d_val); }
+
+ typename Elf_types<size>::Elf_Addr
+ get_d_ptr() const
+ { return Convert<size, big_endian>::convert_host(this->p_->d_val); }
+
+ private:
+ const internal::Dyn_data<size>* p_;
+};
+
+// Write class for an entry in the SHT_DYNAMIC section.
+
+template<int size, bool big_endian>
+class Dyn_write
+{
+ public:
+ Dyn_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Dyn_data<size>*>(p))
+ { }
+
+ void
+ put_d_tag(typename Elf_types<size>::Elf_Swxword v)
+ { this->p_->d_tag = Convert<size, big_endian>::convert_host(v); }
+
+ void
+ put_d_val(typename Elf_types<size>::Elf_WXword v)
+ { this->p_->d_val = Convert<size, big_endian>::convert_host(v); }
+
+ void
+ put_d_ptr(typename Elf_types<size>::Elf_Addr v)
+ { this->p_->d_val = Convert<size, big_endian>::convert_host(v); }
+
+ private:
+ internal::Dyn_data<size>* p_;
+};
+
+// Accessor classes for entries in the ELF SHT_GNU_verdef section.
+
+template<int size, bool big_endian>
+class Verdef
+{
+ public:
+ Verdef(const unsigned char* p)
+ : p_(reinterpret_cast<const internal::Verdef_data*>(p))
+ { }
+
+ template<typename File>
+ Verdef(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Verdef_data*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
+ Elf_Half
+ get_vd_version() const
+ { return Convert<16, big_endian>::convert_host(this->p_->vd_version); }
+
+ Elf_Half
+ get_vd_flags() const
+ { return Convert<16, big_endian>::convert_host(this->p_->vd_flags); }
+
+ Elf_Half
+ get_vd_ndx() const
+ { return Convert<16, big_endian>::convert_host(this->p_->vd_ndx); }
+
+ Elf_Half
+ get_vd_cnt() const
+ { return Convert<16, big_endian>::convert_host(this->p_->vd_cnt); }
+
+ Elf_Word
+ get_vd_hash() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vd_hash); }
+
+ Elf_Word
+ get_vd_aux() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vd_aux); }
+
+ Elf_Word
+ get_vd_next() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vd_next); }
+
+ private:
+ const internal::Verdef_data* p_;
+};
+
+template<int size, bool big_endian>
+class Verdef_write
+{
+ public:
+ Verdef_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Verdef_data*>(p))
+ { }
+
+ void
+ set_vd_version(Elf_Half v)
+ { this->p_->vd_version = Convert<16, big_endian>::convert_host(v); }
+
+ void
+ set_vd_flags(Elf_Half v)
+ { this->p_->vd_flags = Convert<16, big_endian>::convert_host(v); }
+
+ void
+ set_vd_ndx(Elf_Half v)
+ { this->p_->vd_ndx = Convert<16, big_endian>::convert_host(v); }
+
+ void
+ set_vd_cnt(Elf_Half v)
+ { this->p_->vd_cnt = Convert<16, big_endian>::convert_host(v); }
+
+ void
+ set_vd_hash(Elf_Word v)
+ { this->p_->vd_hash = Convert<32, big_endian>::convert_host(v); }
+
+ void
+ set_vd_aux(Elf_Word v)
+ { this->p_->vd_aux = Convert<32, big_endian>::convert_host(v); }
+
+ void
+ set_vd_next(Elf_Word v)
+ { this->p_->vd_next = Convert<32, big_endian>::convert_host(v); }
+
+ private:
+ internal::Verdef_data* p_;
+};
+
+// Accessor classes for auxiliary entries in the ELF SHT_GNU_verdef
+// section.
+
+template<int size, bool big_endian>
+class Verdaux
+{
+ public:
+ Verdaux(const unsigned char* p)
+ : p_(reinterpret_cast<const internal::Verdaux_data*>(p))
+ { }
+
+ template<typename File>
+ Verdaux(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Verdaux_data*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
+ Elf_Word
+ get_vda_name() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vda_name); }
+
+ Elf_Word
+ get_vda_next() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vda_next); }
+
+ private:
+ const internal::Verdaux_data* p_;
+};
+
+template<int size, bool big_endian>
+class Verdaux_write
+{
+ public:
+ Verdaux_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Verdaux_data*>(p))
+ { }
+
+ void
+ set_vda_name(Elf_Word v)
+ { this->p_->vda_name = Convert<32, big_endian>::convert_host(v); }
+
+ void
+ set_vda_next(Elf_Word v)
+ { this->p_->vda_next = Convert<32, big_endian>::convert_host(v); }
+
+ private:
+ internal::Verdaux_data* p_;
+};
+
+// Accessor classes for entries in the ELF SHT_GNU_verneed section.
+
+template<int size, bool big_endian>
+class Verneed
+{
+ public:
+ Verneed(const unsigned char* p)
+ : p_(reinterpret_cast<const internal::Verneed_data*>(p))
+ { }
+
+ template<typename File>
+ Verneed(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Verneed_data*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
+ Elf_Half
+ get_vn_version() const
+ { return Convert<16, big_endian>::convert_host(this->p_->vn_version); }
+
+ Elf_Half
+ get_vn_cnt() const
+ { return Convert<16, big_endian>::convert_host(this->p_->vn_cnt); }
+
+ Elf_Word
+ get_vn_file() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vn_file); }
+
+ Elf_Word
+ get_vn_aux() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vn_aux); }
+
+ Elf_Word
+ get_vn_next() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vn_next); }
+
+ private:
+ const internal::Verneed_data* p_;
+};
+
+template<int size, bool big_endian>
+class Verneed_write
+{
+ public:
+ Verneed_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Verneed_data*>(p))
+ { }
+
+ void
+ set_vn_version(Elf_Half v)
+ { this->p_->vn_version = Convert<16, big_endian>::convert_host(v); }
+
+ void
+ set_vn_cnt(Elf_Half v)
+ { this->p_->vn_cnt = Convert<16, big_endian>::convert_host(v); }
+
+ void
+ set_vn_file(Elf_Word v)
+ { this->p_->vn_file = Convert<32, big_endian>::convert_host(v); }
+
+ void
+ set_vn_aux(Elf_Word v)
+ { this->p_->vn_aux = Convert<32, big_endian>::convert_host(v); }
+
+ void
+ set_vn_next(Elf_Word v)
+ { this->p_->vn_next = Convert<32, big_endian>::convert_host(v); }
+
+ private:
+ internal::Verneed_data* p_;
+};
+
+// Accessor classes for auxiliary entries in the ELF SHT_GNU_verneed
+// section.
+
+template<int size, bool big_endian>
+class Vernaux
+{
+ public:
+ Vernaux(const unsigned char* p)
+ : p_(reinterpret_cast<const internal::Vernaux_data*>(p))
+ { }
+
+ template<typename File>
+ Vernaux(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Vernaux_data*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
+ Elf_Word
+ get_vna_hash() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vna_hash); }
+
+ Elf_Half
+ get_vna_flags() const
+ { return Convert<16, big_endian>::convert_host(this->p_->vna_flags); }
+
+ Elf_Half
+ get_vna_other() const
+ { return Convert<16, big_endian>::convert_host(this->p_->vna_other); }
+
+ Elf_Word
+ get_vna_name() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vna_name); }
+
+ Elf_Word
+ get_vna_next() const
+ { return Convert<32, big_endian>::convert_host(this->p_->vna_next); }
+
+ private:
+ const internal::Vernaux_data* p_;
+};
+
+template<int size, bool big_endian>
+class Vernaux_write
+{
+ public:
+ Vernaux_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Vernaux_data*>(p))
+ { }
+
+ void
+ set_vna_hash(Elf_Word v)
+ { this->p_->vna_hash = Convert<32, big_endian>::convert_host(v); }
+
+ void
+ set_vna_flags(Elf_Half v)
+ { this->p_->vna_flags = Convert<16, big_endian>::convert_host(v); }
+
+ void
+ set_vna_other(Elf_Half v)
+ { this->p_->vna_other = Convert<16, big_endian>::convert_host(v); }
+
+ void
+ set_vna_name(Elf_Word v)
+ { this->p_->vna_name = Convert<32, big_endian>::convert_host(v); }
+
+ void
+ set_vna_next(Elf_Word v)
+ { this->p_->vna_next = Convert<32, big_endian>::convert_host(v); }
+
+ private:
+ internal::Vernaux_data* p_;
+};
+