Add support for returning the section type.
This commit is contained in:
parent
192f9b8501
commit
e698bc313f
1 changed files with 23 additions and 0 deletions
|
@ -106,6 +106,10 @@ class Elf_file
|
||||||
typename Elf_types<size>::Elf_WXword
|
typename Elf_types<size>::Elf_WXword
|
||||||
section_flags(unsigned int shndx);
|
section_flags(unsigned int shndx);
|
||||||
|
|
||||||
|
// Return the type of section SHNDX.
|
||||||
|
Elf_Word
|
||||||
|
section_type(unsigned int shndx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Shared constructor code.
|
// Shared constructor code.
|
||||||
void
|
void
|
||||||
|
@ -273,6 +277,25 @@ Elf_file<size, big_endian, File>::section_flags(unsigned int shndx)
|
||||||
return shdr.get_sh_flags();
|
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.
|
} // End namespace elfcpp.
|
||||||
|
|
||||||
#endif // !defined(ELFCPP_FILE_H)
|
#endif // !defined(ELFCPP_FILE_H)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue