diff options
Diffstat (limited to 'elfcpp')
-rw-r--r-- | elfcpp/ChangeLog | 8 | ||||
-rw-r--r-- | elfcpp/elfcpp_file.h | 38 |
2 files changed, 42 insertions, 4 deletions
diff --git a/elfcpp/ChangeLog b/elfcpp/ChangeLog index eafa25238bb..b554287d672 100644 --- a/elfcpp/ChangeLog +++ b/elfcpp/ChangeLog @@ -1,3 +1,11 @@ +2014-09-02 Cary Coutant <ccoutant@google.com> + + * elfcpp_file.h (Elf_file::shnum): New const function. + (Elf_file::shstrndx): New const function. + (Elf_file::large_shndx_offset): New const function. + (Elf_file::section_name): Add const attribute. + (Elf_file::section_header_offset): Likewise. + 2014-08-08 Han Shen <shenhan@google.com> * aarch64.h (withdrawn): Replaced with R_AARCH64_withdrawn. diff --git a/elfcpp/elfcpp_file.h b/elfcpp/elfcpp_file.h index bcb0275413c..a8daf91ff0c 100644 --- a/elfcpp/elfcpp_file.h +++ b/elfcpp/elfcpp_file.h @@ -144,6 +144,15 @@ class Elf_file return this->shnum_; } + unsigned int + shnum() const + { + if (this->shnum_ == 0 && this->shoff_ != 0) + this->file_->error(_("ELF file has not been initialized yet" + " (internal error)")); + return this->shnum_; + } + // Return the section index of the section name string table. unsigned int shstrndx() @@ -152,6 +161,18 @@ class Elf_file return this->shstrndx_; } + unsigned int + shstrndx() const + { + if (this->shstrndx_ == SHN_XINDEX && this->shoff_ != 0) + { + this->file_->error(_("ELF file has not been initialized yet" + " (internal error)")); + return 0; + } + return this->shstrndx_; + } + // Return the value to subtract from section indexes >= // SHN_LORESERVE. See the comment in initialize_shnum. int @@ -161,6 +182,15 @@ class Elf_file return this->large_shndx_offset_; } + int + large_shndx_offset() const + { + if (this->shstrndx_ == SHN_XINDEX && this->shoff_ != 0) + this->file_->error(_("ELF file has not been initialized yet" + " (internal error)")); + return this->large_shndx_offset_; + } + // Return the location of the header of section SHNDX. typename File::Location section_header(unsigned int shndx) @@ -171,7 +201,7 @@ class Elf_file // Return the name of section SHNDX. std::string - section_name(unsigned int shndx); + section_name(unsigned int shndx) const; // Return the location of the contents of section SHNDX. typename File::Location @@ -216,7 +246,7 @@ class Elf_file // Return the file offset of the header of section SHNDX. off_t - section_header_offset(unsigned int shndx); + section_header_offset(unsigned int shndx) const; // The file we are reading. File* file_; @@ -465,7 +495,7 @@ Elf_file<size, big_endian, File>::find_section_by_type(unsigned int type) template<int size, bool big_endian, typename File> off_t -Elf_file<size, big_endian, File>::section_header_offset(unsigned int shndx) +Elf_file<size, big_endian, File>::section_header_offset(unsigned int shndx) const { if (shndx >= this->shnum()) this->file_->error(_("section_header_offset: bad shndx %u >= %u"), @@ -477,7 +507,7 @@ Elf_file<size, big_endian, File>::section_header_offset(unsigned int shndx) template<int size, bool big_endian, typename File> std::string -Elf_file<size, big_endian, File>::section_name(unsigned int shndx) +Elf_file<size, big_endian, File>::section_name(unsigned int shndx) const { File* const file = this->file_; |