diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-04-08 10:29:23 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-04-08 10:29:40 -0700 |
commit | febdfe65a81629bc2a764820c94f9d2912a90e38 (patch) | |
tree | c88e3d281ee942fbe9c69827dea9116bfcfdabd3 /elfcpp/elfcpp.h | |
parent | 91fb4b1a83cb06e3e6d7b90075f4d8fda0a709d4 (diff) | |
download | gdb-febdfe65a81629bc2a764820c94f9d2912a90e38.zip gdb-febdfe65a81629bc2a764820c94f9d2912a90e38.tar.gz gdb-febdfe65a81629bc2a764820c94f9d2912a90e38.tar.bz2 |
Add chdr_size, Chdr, Chdr_write and Chdr_data
* elfcpp.h (Elf_sizes): Add chdr_size.
(Chdr): New.
(Chdr_write): Likewise.
* elfcpp_internal.h (Chdr_data): Likewise.
Diffstat (limited to 'elfcpp/elfcpp.h')
-rw-r--r-- | elfcpp/elfcpp.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h index f5a3efc..722984e 100644 --- a/elfcpp/elfcpp.h +++ b/elfcpp/elfcpp.h @@ -1009,6 +1009,8 @@ struct Elf_sizes static const int phdr_size = sizeof(internal::Phdr_data<size>); // Size of ELF section header. static const int shdr_size = sizeof(internal::Shdr_data<size>); + // Size of ELF compression header. + static const int chdr_size = sizeof(internal::Chdr_data<size>); // Size of ELF symbol table entry. static const int sym_size = sizeof(internal::Sym_data<size>); // Sizes of ELF reloc entries. @@ -1284,6 +1286,65 @@ class Shdr_write internal::Shdr_data<size>* p_; }; +// 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())) + { } + + typename Elf_types<size>::Elf_WXword + 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_; +}; + // Accessor class for an ELF segment header. template<int size, bool big_endian> |