From ed067c45d4b668db740fbb1728200fc51f4b9b51 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 3 Jul 2015 18:19:00 +0000 Subject: Return ErrorOr from getSymbolAddress. It can fail trying to get the section on ELF and COFF. This makes sure the error is handled. llvm-svn: 241366 --- llvm/lib/Object/COFFObjectFile.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Object/COFFObjectFile.cpp') diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 64bb0d5..9c9a6df 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -163,21 +163,20 @@ uint64_t COFFObjectFile::getSymbolValue(DataRefImpl Ref) const { return Sym.getValue(); } -std::error_code COFFObjectFile::getSymbolAddress(DataRefImpl Ref, - uint64_t &Result) const { - Result = getSymbolValue(Ref); +ErrorOr COFFObjectFile::getSymbolAddress(DataRefImpl Ref) const { + uint64_t Result = getSymbolValue(Ref); COFFSymbolRef Symb = getCOFFSymbol(Ref); int32_t SectionNumber = Symb.getSectionNumber(); if (Symb.isAnyUndefined() || Symb.isCommon() || COFF::isReservedSectionNumber(SectionNumber)) - return std::error_code(); + return Result; const coff_section *Section = nullptr; if (std::error_code EC = getSection(SectionNumber, Section)) return EC; Result += Section->VirtualAddress; - return std::error_code(); + return Result; } SymbolRef::Type COFFObjectFile::getSymbolType(DataRefImpl Ref) const { -- cgit v1.1