diff options
author | Ian Lance Taylor <iant@google.com> | 2007-09-19 23:51:52 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-09-19 23:51:52 +0000 |
commit | e698bc313f3200a27adca79b67b94f808dd71f05 (patch) | |
tree | e9db460fbde1cfc0c906251737cc42919272ce28 /elfcpp/elfcpp_file.h | |
parent | 192f9b850184bb882d2367ed9a842500e7519bfa (diff) | |
download | gdb-e698bc313f3200a27adca79b67b94f808dd71f05.zip gdb-e698bc313f3200a27adca79b67b94f808dd71f05.tar.gz gdb-e698bc313f3200a27adca79b67b94f808dd71f05.tar.bz2 |
Add support for returning the section type.
Diffstat (limited to 'elfcpp/elfcpp_file.h')
-rw-r--r-- | elfcpp/elfcpp_file.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/elfcpp/elfcpp_file.h b/elfcpp/elfcpp_file.h index c9563ee..1f6b8c0 100644 --- a/elfcpp/elfcpp_file.h +++ b/elfcpp/elfcpp_file.h @@ -106,6 +106,10 @@ class Elf_file typename Elf_types<size>::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<size, big_endian, File>::section_flags(unsigned int shndx) return shdr.get_sh_flags(); } +// Return the type of section SHNDX. + +template<int size, bool big_endian, typename File> +Elf_Word +Elf_file<size, big_endian, 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) |