diff options
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r-- | llvm/lib/Object/COFFObjectFile.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 25145471382..3d144089a20 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -179,7 +179,7 @@ ErrorOr<uint64_t> COFFObjectFile::getSymbolAddress(DataRefImpl Ref) const { return Result; } -SymbolRef::Type COFFObjectFile::getSymbolType(DataRefImpl Ref) const { +ErrorOr<SymbolRef::Type> COFFObjectFile::getSymbolType(DataRefImpl Ref) const { COFFSymbolRef Symb = getCOFFSymbol(Ref); int32_t SectionNumber = Symb.getSectionNumber(); diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 3a892d21db3..340faa44a31 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -443,7 +443,8 @@ uint64_t MachOObjectFile::getCommonSymbolSizeImpl(DataRefImpl DRI) const { return getNValue(DRI); } -SymbolRef::Type MachOObjectFile::getSymbolType(DataRefImpl Symb) const { +ErrorOr<SymbolRef::Type> +MachOObjectFile::getSymbolType(DataRefImpl Symb) const { MachO::nlist_base Entry = getSymbolTableEntryBase(this, Symb); uint8_t n_type = Entry.n_type; @@ -455,7 +456,10 @@ SymbolRef::Type MachOObjectFile::getSymbolType(DataRefImpl Symb) const { case MachO::N_UNDF : return SymbolRef::ST_Unknown; case MachO::N_SECT : - section_iterator Sec = *getSymbolSection(Symb); + ErrorOr<section_iterator> SecOrError = getSymbolSection(Symb); + if (!SecOrError) + return SecOrError.getError(); + section_iterator Sec = *SecOrError; if (Sec->isData() || Sec->isBSS()) return SymbolRef::ST_Data; return SymbolRef::ST_Function; @@ -511,8 +515,11 @@ MachOObjectFile::getSymbolSection(DataRefImpl Symb) const { return section_end(); DataRefImpl DRI; DRI.d.a = index - 1; - if (DRI.d.a >= Sections.size()) + if (DRI.d.a >= Sections.size()){ + // Diagnostic("bad section index (" + index + ") for symbol at index " + + // SymbolIndex); return object_error::parse_failed; + } return section_iterator(SectionRef(DRI, this)); } |