aboutsummaryrefslogtreecommitdiff
path: root/elfcpp/elfcpp_file.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-11-02 03:28:52 +0000
committerIan Lance Taylor <iant@google.com>2007-11-02 03:28:52 +0000
commitf7e2ee482013bd5df3e3726305eab7c5ed5ce020 (patch)
tree769d43a72a997fd42bcebdacc315e1c938c3e5a6 /elfcpp/elfcpp_file.h
parent6a7eedfedcbe83b936a8be8abc489f0202205c7a (diff)
downloadbinutils-f7e2ee482013bd5df3e3726305eab7c5ed5ce020.zip
binutils-f7e2ee482013bd5df3e3726305eab7c5ed5ce020.tar.gz
binutils-f7e2ee482013bd5df3e3726305eab7c5ed5ce020.tar.bz2
Reworked from Andrew Chatham: report error locations.
Diffstat (limited to 'elfcpp/elfcpp_file.h')
-rw-r--r--elfcpp/elfcpp_file.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/elfcpp/elfcpp_file.h b/elfcpp/elfcpp_file.h
index 9adbb5f..7462bb8 100644
--- a/elfcpp/elfcpp_file.h
+++ b/elfcpp/elfcpp_file.h
@@ -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)