diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index b9131dd1bb7..37cefd8478c 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -441,10 +441,10 @@ struct Elf_Ehdr_Impl { }; template -struct Elf_Phdr; +struct Elf_Phdr_Impl; template -struct Elf_Phdr { +struct Elf_Phdr_Impl { 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 { }; template -struct Elf_Phdr { +struct Elf_Phdr_Impl { 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 Elf_Shdr; typedef Elf_Sym_Impl Elf_Sym; typedef Elf_Dyn_Impl Elf_Dyn; + typedef Elf_Phdr_Impl Elf_Phdr; typedef Elf_Rel_Impl Elf_Rel; typedef @@ -740,6 +741,21 @@ public: (base() + sec->sh_offset + sec->sh_size)); } + /// \brief Iterate over program header table. + typedef ELFEntityIterator 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"; }