From 3ac256073b0d3c8f4a05f324314062ba7bbe8fba Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 7 Nov 2006 18:51:39 +0000 Subject: Add Elf_file interface which can be used by both Sized_relobj and Sized_dynobj. --- elfcpp/elfcpp.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'elfcpp/elfcpp.h') 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*>(p)) { } + template + Ehdr(File* file, typename File::Location loc) + : p_(reinterpret_cast*>( + 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*>(p)) { } + template + Shdr(File* file, typename File::Location loc) + : p_(reinterpret_cast*>( + 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*>(p)) { } + template + Phdr(File* file, typename File::Location loc) + : p_(reinterpret_cast*>( + 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*>(p)) { } + template + Sym(File* file, typename File::Location loc) + : p_(reinterpret_cast*>( + 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*>(p)) { } + template + Rel(File* file, typename File::Location loc) + : p_(reinterpret_cast*>( + file->view(loc.file_offset, loc.data_size).data())) + { } + typename Elf_types::Elf_Addr get_r_offset() const { return Convert::convert_host(this->p_->r_offset); } @@ -1035,6 +1065,12 @@ class Rela : p_(reinterpret_cast*>(p)) { } + template + Rela(File* file, typename File::Location loc) + : p_(reinterpret_cast*>( + file->view(loc.file_offset, loc.data_size).data())) + { } + typename Elf_types::Elf_Addr get_r_offset() const { return Convert::convert_host(this->p_->r_offset); } -- cgit v1.2.1