aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-07-03 18:19:00 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-07-03 18:19:00 +0000
commited067c45d4b668db740fbb1728200fc51f4b9b51 (patch)
treecc50ae3d78954ad1e634cbd4278eec6095a50bdb /llvm/lib/Object/COFFObjectFile.cpp
parente2df87f24b0af7fa80789e8da15c9cef9e6996f7 (diff)
downloadllvm-ed067c45d4b668db740fbb1728200fc51f4b9b51.zip
llvm-ed067c45d4b668db740fbb1728200fc51f4b9b51.tar.gz
llvm-ed067c45d4b668db740fbb1728200fc51f4b9b51.tar.bz2
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
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp9
1 files changed, 4 insertions, 5 deletions
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<uint64_t> 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 {