aboutsummaryrefslogtreecommitdiff
path: root/elfcpp/elfcpp.h
diff options
context:
space:
mode:
Diffstat (limited to 'elfcpp/elfcpp.h')
-rw-r--r--elfcpp/elfcpp.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h
index d92b46d..322afb4 100644
--- a/elfcpp/elfcpp.h
+++ b/elfcpp/elfcpp.h
@@ -570,6 +570,12 @@ class Ehdr
: p_(reinterpret_cast<const internal::Ehdr_data<size>*>(p))
{ }
+ template<typename File>
+ Ehdr(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Ehdr_data<size>*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
const unsigned char*
get_e_ident() const
{ return this->p_->e_ident; }
@@ -710,6 +716,12 @@ class Shdr
: p_(reinterpret_cast<const internal::Shdr_data<size>*>(p))
{ }
+ template<typename File>
+ Shdr(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Shdr_data<size>*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
Elf_Word
get_sh_name() const
{ return Convert<32, big_endian>::convert_host(this->p_->sh_name); }
@@ -819,6 +831,12 @@ class Phdr
: p_(reinterpret_cast<const internal::Phdr_data<size>*>(p))
{ }
+ template<typename File>
+ Phdr(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<internal::Phdr_data<size>*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
Elf_Word
get_p_type() const
{ return Convert<32, big_endian>::convert_host(this->p_->p_type); }
@@ -911,6 +929,12 @@ class Sym
: p_(reinterpret_cast<const internal::Sym_data<size>*>(p))
{ }
+ template<typename File>
+ Sym(File* file, typename File::Location loc)
+ : p_(reinterpret_cast<const internal::Sym_data<size>*>(
+ file->view(loc.file_offset, loc.data_size).data()))
+ { }
+
Elf_Word
get_st_name() const
{ return Convert<32, big_endian>::convert_host(this->p_->st_name); }
@@ -1015,6 +1039,12 @@ class Rel
: 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); }
@@ -1035,6 +1065,12 @@ class Rela
: 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); }