Reworked from Andrew Chatham: report error locations.
This commit is contained in:
parent
6a7eedfedc
commit
f7e2ee4820
4 changed files with 131 additions and 11 deletions
|
@ -139,6 +139,10 @@ class Elf_file
|
|||
Elf_Word
|
||||
section_type(unsigned int shndx);
|
||||
|
||||
// Return the link field of section SHNDX.
|
||||
Elf_Word
|
||||
section_link(unsigned int shndx);
|
||||
|
||||
private:
|
||||
// Shared constructor code.
|
||||
void
|
||||
|
@ -325,6 +329,25 @@ Elf_file<size, big_endian, File>::section_type(unsigned int shndx)
|
|||
return shdr.get_sh_type();
|
||||
}
|
||||
|
||||
// Return the sh_link field of section SHNDX.
|
||||
|
||||
template<int size, bool big_endian, typename File>
|
||||
Elf_Word
|
||||
Elf_file<size, big_endian, File>::section_link(unsigned int shndx)
|
||||
{
|
||||
File* const file = this->file_;
|
||||
|
||||
if (shndx >= this->shnum())
|
||||
file->error(_("section_link: 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_link();
|
||||
}
|
||||
|
||||
} // End namespace elfcpp.
|
||||
|
||||
#endif // !defined(ELFCPP_FILE_H)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue