bfd/
[deliverable/binutils-gdb.git] / elfcpp / elfcpp_file.h
index 1f6b8c05c9b15f8b7ac141f39c33c1b3fb09ce9e..3228332b8359bc56efdeebb9182ff35e7c5a528e 100644 (file)
@@ -1,5 +1,34 @@
 // elfcpp_file.h -- file access for elfcpp   -*- C++ -*-
 
+// Copyright 2006, 2007, Free Software Foundation, Inc.
+// Written by Ian Lance Taylor <iant@google.com>.
+
+// This file is part of elfcpp.
+   
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public License
+// as published by the Free Software Foundation; either version 2, or
+// (at your option) any later version.
+
+// In addition to the permissions in the GNU Library General Public
+// License, the Free Software Foundation gives you unlimited
+// permission to link the compiled version of this file into
+// combinations with other programs, and to distribute those
+// combinations without any restriction coming from the use of this
+// file.  (The Library Public License restrictions do apply in other
+// respects; for example, they cover modification of the file, and
+/// distribution when not linked into a combined executable.)
+
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Library General Public License for more details.
+
+// You should have received a copy of the GNU Library General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+// 02110-1301, USA.
+
 // This header file defines the class Elf_file which can be used to
 // read useful data from an ELF file.  The functions here are all
 // templates which take a file interface object as a parameter.  This
@@ -110,6 +139,15 @@ class Elf_file
   Elf_Word
   section_type(unsigned int shndx);
 
+  // Return the link field of section SHNDX.
+  Elf_Word
+  section_link(unsigned int shndx);
+
+  // Return the info field of section SHNDX.
+  Elf_Word
+  section_info(unsigned int shndx);
+
+
  private:
   // Shared constructor code.
   void
@@ -296,6 +334,44 @@ 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();
+}
+
+// Return the sh_info field of section SHNDX.
+
+template<int size, bool big_endian, typename File>
+Elf_Word
+Elf_file<size, big_endian, File>::section_info(unsigned int shndx)
+{
+  File* const file = this->file_;
+
+  if (shndx >= this->shnum())
+    file->error(_("section_info: 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_info();
+}
+
 } // End namespace elfcpp.
 
 #endif // !defined(ELFCPP_FILE_H)
This page took 0.023591 seconds and 4 git commands to generate.