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
This commit is contained in:
Rafael Espindola
2015-07-03 18:19:00 +00:00
parent e2df87f24b
commit ed067c45d4
18 changed files with 80 additions and 61 deletions

View File

@@ -161,8 +161,10 @@ static std::error_code
resolveSectionAndAddress(const COFFObjectFile *Obj, const SymbolRef &Sym,
const coff_section *&ResolvedSection,
uint64_t &ResolvedAddr) {
if (std::error_code EC = Sym.getAddress(ResolvedAddr))
ErrorOr<uint64_t> ResolvedAddrOrErr = Sym.getAddress();
if (std::error_code EC = ResolvedAddrOrErr.getError())
return EC;
ResolvedAddr = *ResolvedAddrOrErr;
section_iterator iter(Obj->section_begin());
if (std::error_code EC = Sym.getSection(iter))
return EC;