diff options
-rw-r--r-- | llvm/include/llvm/Object/ELF.h | 5 | ||||
-rw-r--r-- | llvm/include/llvm/Object/Error.h | 1 | ||||
-rw-r--r-- | llvm/lib/Object/Error.cpp | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index 71f30ab16dd..71e27042af9 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -158,10 +158,11 @@ public: ArrayRef<Elf_Word> ShndxTable) const; ErrorOr<const Elf_Shdr *> getSection(uint32_t Index) const; - const Elf_Sym *getSymbol(const Elf_Shdr *Sec, uint32_t Index) const { + ErrorOr<const Elf_Sym *> getSymbol(const Elf_Shdr *Sec, + uint32_t Index) const { Elf_Sym_Range Symbols = symbols(Sec); if (Index >= Symbols.size()) - report_fatal_error("Invalid symbol index"); + return object_error::invalid_symbol_index; return &Symbols[Index]; } diff --git a/llvm/include/llvm/Object/Error.h b/llvm/include/llvm/Object/Error.h index cd55e5dc26d..eb938338715 100644 --- a/llvm/include/llvm/Object/Error.h +++ b/llvm/include/llvm/Object/Error.h @@ -34,6 +34,7 @@ enum class object_error { string_table_non_null_end, invalid_section_index, bitcode_section_not_found, + invalid_symbol_index, }; inline std::error_code make_error_code(object_error e) { diff --git a/llvm/lib/Object/Error.cpp b/llvm/lib/Object/Error.cpp index c1dfe673b61..578da22c044 100644 --- a/llvm/lib/Object/Error.cpp +++ b/llvm/lib/Object/Error.cpp @@ -50,6 +50,8 @@ std::string _object_error_category::message(int EV) const { return "Invalid section index"; case object_error::bitcode_section_not_found: return "Bitcode section not found in object file"; + case object_error::invalid_symbol_index: + return "Invalid symbol index"; } llvm_unreachable("An enumerator of object_error does not have a message " "defined."); |