diff options
Diffstat (limited to 'include/llvm/Object/ELF.h')
-rw-r--r-- | include/llvm/Object/ELF.h | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 80b8be03810c..e00d34f160e7 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -109,11 +109,7 @@ public: Header->getDataEncoding() == ELF::ELFDATA2LSB; } - const Elf_Shdr *section_begin() const; - const Elf_Shdr *section_end() const; - Elf_Shdr_Range sections() const { - return makeArrayRef(section_begin(), section_end()); - } + ErrorOr<Elf_Shdr_Range> sections() const; const Elf_Sym *symbol_begin(const Elf_Shdr *Sec) const { if (!Sec) @@ -389,16 +385,12 @@ static bool compareAddr(uint64_t VAddr, const Elf_Phdr_Impl<ELFT> *Phdr) { } template <class ELFT> -const typename ELFFile<ELFT>::Elf_Shdr *ELFFile<ELFT>::section_begin() const { +ErrorOr<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const { + // Invalid section header entry size (e_shentsize) in ELF header if (Header->e_shentsize != sizeof(Elf_Shdr)) - report_fatal_error( - "Invalid section header entry size (e_shentsize) in ELF header"); - return reinterpret_cast<const Elf_Shdr *>(base() + Header->e_shoff); -} - -template <class ELFT> -const typename ELFFile<ELFT>::Elf_Shdr *ELFFile<ELFT>::section_end() const { - return section_begin() + getNumSections(); + return object_error::parse_failed; + auto *Begin = reinterpret_cast<const Elf_Shdr *>(base() + Header->e_shoff); + return makeArrayRef(Begin, Begin + getNumSections()); } template <class ELFT> |