diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-01-06 03:56:27 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-01-06 03:56:27 +0000 |
commit | 3e5d8ade393d347a1483bf39d48ffebe9541b2b0 (patch) | |
tree | ad4a4638294d34a5066bcf89cfe2bfbc128bc44d | |
parent | fe23da794930e01701ee1ee4fdb2b91db59c2be5 (diff) |
[Object][ELF] Add program header iterator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171648 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Object/ELF.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index b9131dd1bb..37cefd8478 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -441,10 +441,10 @@ struct Elf_Ehdr_Impl { }; template<endianness target_endianness, std::size_t max_alignment, bool is64Bits> -struct Elf_Phdr; +struct Elf_Phdr_Impl; template<endianness target_endianness, std::size_t max_alignment> -struct Elf_Phdr<target_endianness, max_alignment, false> { +struct Elf_Phdr_Impl<target_endianness, max_alignment, false> { LLVM_ELF_IMPORT_TYPES(target_endianness, max_alignment, false) Elf_Word p_type; // Type of segment Elf_Off p_offset; // FileOffset where segment is located, in bytes @@ -457,7 +457,7 @@ struct Elf_Phdr<target_endianness, max_alignment, false> { }; template<endianness target_endianness, std::size_t max_alignment> -struct Elf_Phdr<target_endianness, max_alignment, true> { +struct Elf_Phdr_Impl<target_endianness, max_alignment, true> { LLVM_ELF_IMPORT_TYPES(target_endianness, max_alignment, true) Elf_Word p_type; // Type of segment Elf_Word p_flags; // Segment flags @@ -477,6 +477,7 @@ class ELFObjectFile : public ObjectFile { typedef Elf_Shdr_Impl<target_endianness, max_alignment, is64Bits> Elf_Shdr; typedef Elf_Sym_Impl<target_endianness, max_alignment, is64Bits> Elf_Sym; typedef Elf_Dyn_Impl<target_endianness, max_alignment, is64Bits> Elf_Dyn; + typedef Elf_Phdr_Impl<target_endianness, max_alignment, is64Bits> Elf_Phdr; typedef Elf_Rel_Impl<target_endianness, max_alignment, is64Bits, false> Elf_Rel; typedef @@ -740,6 +741,21 @@ public: (base() + sec->sh_offset + sec->sh_size)); } + /// \brief Iterate over program header table. + typedef ELFEntityIterator<const Elf_Phdr> Elf_Phdr_Iter; + + Elf_Phdr_Iter begin_program_headers() const { + return Elf_Phdr_Iter(Header->e_phentsize, + (const char*)base() + Header->e_phoff); + } + + Elf_Phdr_Iter end_program_headers() const { + return Elf_Phdr_Iter(Header->e_phentsize, + (const char*)base() + + Header->e_phoff + + (Header->e_phnum * Header->e_phentsize)); + } + virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; virtual StringRef getObjectType() const { return "ELF"; } |