summaryrefslogtreecommitdiff
path: root/elfcpp/elfcpp.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2006-11-07 18:51:39 +0000
committerIan Lance Taylor <iant@google.com>2006-11-07 18:51:39 +0000
commit3ac256073b0d3c8f4a05f324314062ba7bbe8fba (patch)
tree9e59b8f9d208b714b129bbaae5352cfc1eb48560 /elfcpp/elfcpp.h
parent51a2735610ebccd3021cf3ba410820cdd31158b1 (diff)
downloadbinutils-redhat-3ac256073b0d3c8f4a05f324314062ba7bbe8fba.tar.gz
Add Elf_file interface which can be used by both Sized_relobj and
Sized_dynobj.
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 d92b46d382..322afb47d7 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); }