mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +00:00
Return ErrorOr from getSymbolAddress.
It can fail trying to get the section on ELF and COFF. This makes sure the error is handled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241366 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user