mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-18 10:24:45 +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:
@@ -455,13 +455,12 @@ static void printRelocationTargetName(const MachOObjectFile *O,
|
||||
|
||||
for (const SymbolRef &Symbol : O->symbols()) {
|
||||
std::error_code ec;
|
||||
uint64_t Addr;
|
||||
ErrorOr<StringRef> Name = Symbol.getName();
|
||||
|
||||
if ((ec = Symbol.getAddress(Addr)))
|
||||
ErrorOr<uint64_t> Addr = Symbol.getAddress();
|
||||
if ((ec = Addr.getError()))
|
||||
report_fatal_error(ec.message());
|
||||
if (Addr != Val)
|
||||
if (*Addr != Val)
|
||||
continue;
|
||||
ErrorOr<StringRef> Name = Symbol.getName();
|
||||
if (std::error_code EC = Name.getError())
|
||||
report_fatal_error(EC.message());
|
||||
fmt << *Name;
|
||||
@@ -824,9 +823,10 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||
std::vector<std::pair<uint64_t, StringRef>> Symbols;
|
||||
for (const SymbolRef &Symbol : Obj->symbols()) {
|
||||
if (Section.containsSymbol(Symbol)) {
|
||||
uint64_t Address;
|
||||
if (error(Symbol.getAddress(Address)))
|
||||
ErrorOr<uint64_t> AddressOrErr = Symbol.getAddress();
|
||||
if (error(AddressOrErr.getError()))
|
||||
break;
|
||||
uint64_t Address = *AddressOrErr;
|
||||
if (Address == UnknownAddress)
|
||||
continue;
|
||||
Address -= SectionAddr;
|
||||
@@ -1113,12 +1113,13 @@ void llvm::PrintSymbolTable(const ObjectFile *o) {
|
||||
return;
|
||||
}
|
||||
for (const SymbolRef &Symbol : o->symbols()) {
|
||||
uint64_t Address;
|
||||
ErrorOr<uint64_t> AddressOrError = Symbol.getAddress();
|
||||
if (error(AddressOrError.getError()))
|
||||
continue;
|
||||
uint64_t Address = *AddressOrError;
|
||||
SymbolRef::Type Type = Symbol.getType();
|
||||
uint32_t Flags = Symbol.getFlags();
|
||||
section_iterator Section = o->section_end();
|
||||
if (error(Symbol.getAddress(Address)))
|
||||
continue;
|
||||
if (error(Symbol.getSection(Section)))
|
||||
continue;
|
||||
StringRef Name;
|
||||
|
Reference in New Issue
Block a user