aboutsummaryrefslogtreecommitdiff
path: root/elfcpp
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2008-02-04 05:43:05 +0000
committerIan Lance Taylor <iant@google.com>2008-02-04 05:43:05 +0000
commita445fddf828b0e8251fbdce91bc9372e7efd24f0 (patch)
tree6af0ee8254a9432643798126eef663603d92eb08 /elfcpp
parentd16c732117ed4b752abd51dd1598c9cec9d2b26c (diff)
downloadgdb-a445fddf828b0e8251fbdce91bc9372e7efd24f0.zip
gdb-a445fddf828b0e8251fbdce91bc9372e7efd24f0.tar.gz
gdb-a445fddf828b0e8251fbdce91bc9372e7efd24f0.tar.bz2
Fully implement the SECTIONS clause.
Diffstat (limited to 'elfcpp')
-rw-r--r--elfcpp/elfcpp_file.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/elfcpp/elfcpp_file.h b/elfcpp/elfcpp_file.h
index 3228332..f9f28ef 100644
--- a/elfcpp/elfcpp_file.h
+++ b/elfcpp/elfcpp_file.h
@@ -131,6 +131,10 @@ class Elf_file
typename File::Location
section_contents(unsigned int shndx);
+ // Return the size of section SHNDX.
+ typename Elf_types<size>::Elf_WXword
+ section_size(unsigned int shndx);
+
// Return the flags of section SHNDX.
typename Elf_types<size>::Elf_WXword
section_flags(unsigned int shndx);
@@ -147,6 +151,9 @@ class Elf_file
Elf_Word
section_info(unsigned int shndx);
+ // Return the addralign field of section SHNDX.
+ typename Elf_types<size>::Elf_WXword
+ section_addralign(unsigned int shndx);
private:
// Shared constructor code.
@@ -296,6 +303,25 @@ Elf_file<size, big_endian, File>::section_contents(unsigned int shndx)
return typename File::Location(shdr.get_sh_offset(), shdr.get_sh_size());
}
+// Get the size of section SHNDX.
+
+template<int size, bool big_endian, typename File>
+typename Elf_types<size>::Elf_WXword
+Elf_file<size, big_endian, File>::section_size(unsigned int shndx)
+{
+ File* const file = this->file_;
+
+ if (shndx >= this->shnum())
+ file->error(_("section_size: 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_size();
+}
+
// Return the section flags of section SHNDX.
template<int size, bool big_endian, typename File>
@@ -372,6 +398,25 @@ Elf_file<size, big_endian, File>::section_info(unsigned int shndx)
return shdr.get_sh_info();
}
+// Return the sh_addralign field of section SHNDX.
+
+template<int size, bool big_endian, typename File>
+typename Elf_types<size>::Elf_WXword
+Elf_file<size, big_endian, File>::section_addralign(unsigned int shndx)
+{
+ File* const file = this->file_;
+
+ if (shndx >= this->shnum())
+ file->error(_("section_addralign: 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_addralign();
+}
+
} // End namespace elfcpp.
#endif // !defined(ELFCPP_FILE_H)