aboutsummaryrefslogtreecommitdiff
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
commit645f81233bd13bc6102580bac4b886c6056028e3 (patch)
treee104ddfc8f2a1f52326b8a2fa9c3b5c50ae43fa0 /elfcpp/elfcpp.h
parent9e59254c41b56b91b7640ed5b727430cc537daac (diff)
downloadgdb-645f81233bd13bc6102580bac4b886c6056028e3.zip
gdb-645f81233bd13bc6102580bac4b886c6056028e3.tar.gz
gdb-645f81233bd13bc6102580bac4b886c6056028e3.tar.bz2
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 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); }