[llvm] r264187 - Fix a crash in running llvm-objdump -t with an invalid Mach-O file already
Rafael Espíndola via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 23 14:27:09 PDT 2016
tools/llvm-objdump/X86/macho-symbolized-disassembly.test is crashing on linux.
I have attached the log.
On 23 March 2016 at 16:27, Kevin Enderby via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: enderby
> Date: Wed Mar 23 15:27:00 2016
> New Revision: 264187
>
> URL: http://llvm.org/viewvc/llvm-project?rev=264187&view=rev
> Log:
> Fix a crash in running llvm-objdump -t with an invalid Mach-O file already
> in the test suite. While this is not really an interesting tool and option to run
> on a Mach-O file to show the symbol table in a generic libObject format
> it shouldn’t crash.
>
> The reason for the crash was in MachOObjectFile::getSymbolType() when it was
> calling MachOObjectFile::getSymbolSection() without checking its return value
> for the error case.
>
> What makes this fix require a fair bit of diffs is that the method getSymbolType() is
> in the class ObjectFile defined without an ErrorOr<> so I needed to add that all
> the sub classes. And all of the uses needed to be updated and the return value
> needed to be checked for the error case.
>
> The MachOObjectFile version of getSymbolType() “can” get an error in trying to
> come up with the libObject’s internal SymbolRef::Type when the Mach-O symbol
> symbol type is an N_SECT type because the code is trying to select from the
> SymbolRef::ST_Data or SymbolRef::ST_Function values for the SymbolRef::Type.
> And it needs the Mach-O section to use isData() and isBSS to determine if
> it will return SymbolRef::ST_Data.
>
> One other possible fix I considered is to simply return SymbolRef::ST_Other
> when MachOObjectFile::getSymbolSection() returned an error. But since in
> the past when I did such changes that “ate an error in the libObject code” I
> was asked instead to push the error out of the libObject code I chose not
> to implement the fix this way.
>
> As currently written both the COFF and ELF versions of getSymbolType()
> can’t get an error. But if isReservedSectionNumber() wanted to check for
> the two known negative values rather than allowing all negative values or
> the code wanted to add the same check as in getSymbolAddress() to use
> getSection() and check for the error then these versions of getSymbolType()
> could return errors.
>
> At the end of the day the error printed now is the generic “Invalid data was
> encountered while parsing the file” for object_error::parse_failed. In the
> future when we thread Lang’s new TypedError for recoverable error handling
> though libObject this will improve. And where the added // Diagnostic(…
> comment is, it would be changed to produce and error message
> like “bad section index (42) for symbol at index 8” for this case.
>
> Modified:
> llvm/trunk/include/llvm/Object/COFF.h
> llvm/trunk/include/llvm/Object/ELFObjectFile.h
> llvm/trunk/include/llvm/Object/MachO.h
> llvm/trunk/include/llvm/Object/ObjectFile.h
> llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
> llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
> llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
> llvm/trunk/lib/Object/COFFObjectFile.cpp
> llvm/trunk/lib/Object/MachOObjectFile.cpp
> llvm/trunk/test/Object/macho-invalid.test
> llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp
> llvm/trunk/tools/llvm-objdump/MachODump.cpp
> llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
> llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp
> llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp
>
> Modified: llvm/trunk/include/llvm/Object/COFF.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Object/COFF.h (original)
> +++ llvm/trunk/include/llvm/Object/COFF.h Wed Mar 23 15:27:00 2016
> @@ -684,7 +684,7 @@ protected:
> uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
> uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
> uint32_t getSymbolFlags(DataRefImpl Symb) const override;
> - SymbolRef::Type getSymbolType(DataRefImpl Symb) const override;
> + ErrorOr<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
> ErrorOr<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
> void moveSectionNext(DataRefImpl &Sec) const override;
> std::error_code getSectionName(DataRefImpl Sec,
>
> Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
> +++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Wed Mar 23 15:27:00 2016
> @@ -205,7 +205,7 @@ protected:
> uint32_t getSymbolFlags(DataRefImpl Symb) const override;
> uint8_t getSymbolOther(DataRefImpl Symb) const override;
> uint8_t getSymbolELFType(DataRefImpl Symb) const override;
> - SymbolRef::Type getSymbolType(DataRefImpl Symb) const override;
> + ErrorOr<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
> ErrorOr<section_iterator> getSymbolSection(const Elf_Sym *Symb,
> const Elf_Shdr *SymTab) const;
> ErrorOr<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
> @@ -445,7 +445,8 @@ uint8_t ELFObjectFile<ELFT>::getSymbolEL
> }
>
> template <class ELFT>
> -SymbolRef::Type ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
> +ErrorOr<SymbolRef::Type>
> +ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
> const Elf_Sym *ESym = getSymbol(Symb);
>
> switch (ESym->getType()) {
>
> Modified: llvm/trunk/include/llvm/Object/MachO.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Object/MachO.h (original)
> +++ llvm/trunk/include/llvm/Object/MachO.h Wed Mar 23 15:27:00 2016
> @@ -208,7 +208,7 @@ public:
> ErrorOr<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
> uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
> uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
> - SymbolRef::Type getSymbolType(DataRefImpl Symb) const override;
> + ErrorOr<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
> uint32_t getSymbolFlags(DataRefImpl Symb) const override;
> ErrorOr<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
> unsigned getSymbolSectionID(SymbolRef Symb) const;
>
> Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
> +++ llvm/trunk/include/llvm/Object/ObjectFile.h Wed Mar 23 15:27:00 2016
> @@ -143,7 +143,7 @@ public:
> /// @brief Get the alignment of this symbol as the actual value (not log 2).
> uint32_t getAlignment() const;
> uint64_t getCommonSize() const;
> - SymbolRef::Type getType() const;
> + ErrorOr<SymbolRef::Type> getType() const;
>
> /// @brief Get section this symbol is defined in reference to. Result is
> /// end_sections() if it is undefined or is an absolute symbol.
> @@ -201,7 +201,7 @@ protected:
> virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
> virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
> virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const = 0;
> - virtual SymbolRef::Type getSymbolType(DataRefImpl Symb) const = 0;
> + virtual ErrorOr<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
> virtual ErrorOr<section_iterator>
> getSymbolSection(DataRefImpl Symb) const = 0;
>
> @@ -329,7 +329,7 @@ inline ErrorOr<section_iterator> SymbolR
> return getObject()->getSymbolSection(getRawDataRefImpl());
> }
>
> -inline SymbolRef::Type SymbolRef::getType() const {
> +inline ErrorOr<SymbolRef::Type> SymbolRef::getType() const {
> return getObject()->getSymbolType(getRawDataRefImpl());
> }
>
>
> Modified: llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp Wed Mar 23 15:27:00 2016
> @@ -119,7 +119,10 @@ std::error_code SymbolizableObjectFile::
> uint64_t SymbolSize,
> DataExtractor *OpdExtractor,
> uint64_t OpdAddress) {
> - SymbolRef::Type SymbolType = Symbol.getType();
> + ErrorOr<SymbolRef::Type> SymbolTypeOrErr = Symbol.getType();
> + if (auto EC = SymbolTypeOrErr.getError())
> + return EC;
> + SymbolRef::Type SymbolType = *SymbolTypeOrErr;
> if (SymbolType != SymbolRef::ST_Function && SymbolType != SymbolRef::ST_Data)
> return std::error_code();
> ErrorOr<uint64_t> SymbolAddressOrErr = Symbol.getAddress();
>
> Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Wed Mar 23 15:27:00 2016
> @@ -169,7 +169,9 @@ RuntimeDyldImpl::loadObjectImpl(const ob
> if (Flags & SymbolRef::SF_Common)
> CommonSymbols.push_back(*I);
> else {
> - object::SymbolRef::Type SymType = I->getType();
> + ErrorOr<object::SymbolRef::Type> SymTypeOrErr = I->getType();
> + Check(SymTypeOrErr.getError());
> + object::SymbolRef::Type SymType = *SymTypeOrErr;
>
> // Get symbol name.
> ErrorOr<StringRef> NameOrErr = I->getName();
>
> Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Wed Mar 23 15:27:00 2016
> @@ -1190,7 +1190,10 @@ relocation_iterator RuntimeDyldELF::proc
> RTDyldSymbolTable::const_iterator gsi = GlobalSymbolTable.end();
> if (Symbol != Obj.symbol_end()) {
> gsi = GlobalSymbolTable.find(TargetName.data());
> - SymType = Symbol->getType();
> + ErrorOr<SymbolRef::Type> SymTypeOrErr = Symbol->getType();
> + if (std::error_code EC = SymTypeOrErr.getError())
> + report_fatal_error(EC.message());
> + SymType = *SymTypeOrErr;
> }
> if (gsi != GlobalSymbolTable.end()) {
> const auto &SymInfo = gsi->second;
>
> Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/COFFObjectFile.cpp Wed Mar 23 15:27:00 2016
> @@ -179,7 +179,7 @@ ErrorOr<uint64_t> COFFObjectFile::getSym
> 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();
>
>
> Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/MachOObjectFile.cpp Wed Mar 23 15:27:00 2016
> @@ -443,7 +443,8 @@ uint64_t MachOObjectFile::getCommonSymbo
> 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::getSymb
> 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(DataRe
> 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));
> }
>
>
> Modified: llvm/trunk/test/Object/macho-invalid.test
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/macho-invalid.test?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/test/Object/macho-invalid.test (original)
> +++ llvm/trunk/test/Object/macho-invalid.test Wed Mar 23 15:27:00 2016
> @@ -54,6 +54,9 @@ INVALID-SECTION-IDX-SYMBOL-SEC-m: 000000
> RUN: llvm-nm -pax %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
> RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-pax %s
> INVALID-SECTION-IDX-SYMBOL-SEC-pax: 0000000100000000 0f 42 0010 00000065 __mh_execute_header
> +RUN: not llvm-objdump -t %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
> +RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-objdump %s
> +INVALID-SECTION-IDX-SYMBOL-SEC-objdump: Invalid data was encountered while parsing the file.
>
> RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-header 2>&1 | FileCheck -check-prefix INVALID-HEADER %s
> INVALID-HEADER: The file was not recognized as a valid object file.
>
> Modified: llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp (original)
> +++ llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp Wed Mar 23 15:27:00 2016
> @@ -437,7 +437,10 @@ void MachODebugMapParser::loadMainBinary
> section_iterator Section = MainBinary.section_end();
> MainBinarySymbolAddresses.clear();
> for (const auto &Sym : MainBinary.symbols()) {
> - SymbolRef::Type Type = Sym.getType();
> + ErrorOr<SymbolRef::Type> TypeOrErr = Sym.getType();
> + if (!TypeOrErr)
> + continue;
> + SymbolRef::Type Type = *TypeOrErr;
> // Skip undefined and STAB entries.
> if ((Type & SymbolRef::ST_Debug) || (Type & SymbolRef::ST_Unknown))
> continue;
>
> Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
> +++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Wed Mar 23 15:27:00 2016
> @@ -172,8 +172,16 @@ static const Target *GetTarget(const Mac
>
> struct SymbolSorter {
> bool operator()(const SymbolRef &A, const SymbolRef &B) {
> - uint64_t AAddr = (A.getType() != SymbolRef::ST_Function) ? 0 : A.getValue();
> - uint64_t BAddr = (B.getType() != SymbolRef::ST_Function) ? 0 : B.getValue();
> + ErrorOr<SymbolRef::Type> ATypeOrErr = A.getType();
> + if (std::error_code EC = ATypeOrErr.getError())
> + report_fatal_error(EC.message());
> + SymbolRef::Type AType = *ATypeOrErr;
> + ErrorOr<SymbolRef::Type> BTypeOrErr = B.getType();
> + if (std::error_code EC = BTypeOrErr.getError())
> + report_fatal_error(EC.message());
> + SymbolRef::Type BType = *ATypeOrErr;
> + uint64_t AAddr = (AType != SymbolRef::ST_Function) ? 0 : A.getValue();
> + uint64_t BAddr = (BType != SymbolRef::ST_Function) ? 0 : B.getValue();
> return AAddr < BAddr;
> }
> };
> @@ -573,7 +581,10 @@ static void CreateSymbolAddressMap(MachO
> SymbolAddressMap *AddrMap) {
> // Create a map of symbol addresses to symbol names.
> for (const SymbolRef &Symbol : O->symbols()) {
> - SymbolRef::Type ST = Symbol.getType();
> + ErrorOr<SymbolRef::Type> STOrErr = Symbol.getType();
> + if (std::error_code EC = STOrErr.getError())
> + report_fatal_error(EC.message());
> + SymbolRef::Type ST = *STOrErr;
> if (ST == SymbolRef::ST_Function || ST == SymbolRef::ST_Data ||
> ST == SymbolRef::ST_Other) {
> uint64_t Address = Symbol.getValue();
> @@ -6083,7 +6094,10 @@ static void DisassembleMachO(StringRef F
> SymbolAddressMap AddrMap;
> bool DisSymNameFound = false;
> for (const SymbolRef &Symbol : MachOOF->symbols()) {
> - SymbolRef::Type ST = Symbol.getType();
> + ErrorOr<SymbolRef::Type> STOrErr = Symbol.getType();
> + if (std::error_code EC = STOrErr.getError())
> + report_fatal_error(EC.message());
> + SymbolRef::Type ST = *STOrErr;
> if (ST == SymbolRef::ST_Function || ST == SymbolRef::ST_Data ||
> ST == SymbolRef::ST_Other) {
> uint64_t Address = Symbol.getValue();
> @@ -6134,7 +6148,10 @@ static void DisassembleMachO(StringRef F
> report_fatal_error(EC.message());
> StringRef SymName = *SymNameOrErr;
>
> - SymbolRef::Type ST = Symbols[SymIdx].getType();
> + ErrorOr<SymbolRef::Type> STOrErr = Symbols[SymIdx].getType();
> + if (std::error_code EC = STOrErr.getError())
> + report_fatal_error(EC.message());
> + SymbolRef::Type ST = *STOrErr;
> if (ST != SymbolRef::ST_Function && ST != SymbolRef::ST_Data)
> continue;
>
> @@ -6158,7 +6175,10 @@ static void DisassembleMachO(StringRef F
> uint64_t NextSym = 0;
> uint64_t NextSymIdx = SymIdx + 1;
> while (Symbols.size() > NextSymIdx) {
> - SymbolRef::Type NextSymType = Symbols[NextSymIdx].getType();
> + ErrorOr<SymbolRef::Type> STOrErr = Symbols[NextSymIdx].getType();
> + if (std::error_code EC = STOrErr.getError())
> + report_fatal_error(EC.message());
> + SymbolRef::Type NextSymType = *STOrErr;
> if (NextSymType == SymbolRef::ST_Function) {
> containsNextSym =
> Sections[SectIdx].containsSymbol(Symbols[NextSymIdx]);
>
> Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
> +++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Wed Mar 23 15:27:00 2016
> @@ -1293,7 +1293,9 @@ void llvm::PrintSymbolTable(const Object
> ErrorOr<uint64_t> AddressOrError = Symbol.getAddress();
> error(AddressOrError.getError());
> uint64_t Address = *AddressOrError;
> - SymbolRef::Type Type = Symbol.getType();
> + ErrorOr<SymbolRef::Type> TypeOrError = Symbol.getType();
> + error(TypeOrError.getError());
> + SymbolRef::Type Type = *TypeOrError;
> uint32_t Flags = Symbol.getFlags();
> ErrorOr<section_iterator> SectionOrErr = Symbol.getSection();
> error(SectionOrErr.getError());
>
> Modified: llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp (original)
> +++ llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp Wed Mar 23 15:27:00 2016
> @@ -198,7 +198,10 @@ Decoder::getSectionContaining(const COFF
> ErrorOr<object::SymbolRef> Decoder::getSymbol(const COFFObjectFile &COFF,
> uint64_t VA, bool FunctionOnly) {
> for (const auto &Symbol : COFF.symbols()) {
> - if (FunctionOnly && Symbol.getType() != SymbolRef::ST_Function)
> + ErrorOr<SymbolRef::Type> Type = Symbol.getType();
> + if (std::error_code EC = Type.getError())
> + return EC;
> + if (FunctionOnly && *Type != SymbolRef::ST_Function)
> continue;
>
> ErrorOr<uint64_t> Address = Symbol.getAddress();
>
> Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=264187&r1=264186&r2=264187&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original)
> +++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Wed Mar 23 15:27:00 2016
> @@ -330,7 +330,11 @@ static int printLineInfoForInput(bool Lo
> // Use symbol info to iterate functions in the object.
> for (const auto &P : SymAddr) {
> object::SymbolRef Sym = P.first;
> - if (Sym.getType() == object::SymbolRef::ST_Function) {
> + ErrorOr<SymbolRef::Type> TypeOrErr = Sym.getType();
> + if (!TypeOrErr)
> + continue;
> + SymbolRef::Type Type = *TypeOrErr;
> + if (Type == object::SymbolRef::ST_Function) {
> ErrorOr<StringRef> Name = Sym.getName();
> if (!Name)
> continue;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
-------------- next part --------------
A non-text attachment was scrubbed...
Name: log
Type: application/octet-stream
Size: 17936 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160323/cea1266b/attachment.obj>
More information about the llvm-commits
mailing list