From 108219accf68983446fdb28238c53fd44205506b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 19 Sep 2007 23:51:52 +0000 Subject: Add support for returning the section type. --- elfcpp/elfcpp_file.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'elfcpp') diff --git a/elfcpp/elfcpp_file.h b/elfcpp/elfcpp_file.h index c9563eeed7..1f6b8c05c9 100644 --- a/elfcpp/elfcpp_file.h +++ b/elfcpp/elfcpp_file.h @@ -106,6 +106,10 @@ class Elf_file typename Elf_types::Elf_WXword section_flags(unsigned int shndx); + // Return the type of section SHNDX. + Elf_Word + section_type(unsigned int shndx); + private: // Shared constructor code. void @@ -273,6 +277,25 @@ Elf_file::section_flags(unsigned int shndx) return shdr.get_sh_flags(); } +// Return the type of section SHNDX. + +template +Elf_Word +Elf_file::section_type(unsigned int shndx) +{ + File* const file = this->file_; + + if (shndx >= this->shnum()) + file->error(_("section_type: bad shndx %u >= %u"), + shndx, this->shnum()); + + typename File::View v(file->view(this->section_header_offset(shndx), + This::shdr_size)); + + Ef_shdr shdr(v.data()); + return shdr.get_sh_type(); +} + } // End namespace elfcpp. #endif // !defined(ELFCPP_FILE_H) -- cgit v1.2.1