mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Return ErrorOr from SymbolRef::getName.
This function can really fail since the string table offset can be out of bounds. Using ErrorOr makes sure the error is checked. Hopefully a lot of the boilerplate code in tools/* can go away once we have a diagnostic manager in Object. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241297 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -197,11 +197,14 @@ void MachODebugMapParser::loadCurrentObjectFileSymbols() {
|
||||
CurrentObjectAddresses.clear();
|
||||
|
||||
for (auto Sym : CurrentObjectHolder.Get().symbols()) {
|
||||
StringRef Name;
|
||||
|
||||
uint64_t Addr;
|
||||
if (Sym.getAddress(Addr) || Addr == UnknownAddress || Sym.getName(Name))
|
||||
if (Sym.getAddress(Addr) || Addr == UnknownAddress)
|
||||
continue;
|
||||
CurrentObjectAddresses[Name] = Addr;
|
||||
ErrorOr<StringRef> Name = Sym.getName();
|
||||
if (!Name)
|
||||
continue;
|
||||
CurrentObjectAddresses[*Name] = Addr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +228,6 @@ void MachODebugMapParser::loadMainBinarySymbols() {
|
||||
// Skip undefined and STAB entries.
|
||||
if ((Type & SymbolRef::ST_Debug) || (Type & SymbolRef::ST_Unknown))
|
||||
continue;
|
||||
StringRef Name;
|
||||
uint64_t Addr;
|
||||
// The only symbols of interest are the global variables. These
|
||||
// are the only ones that need to be queried because the address
|
||||
@@ -233,8 +235,13 @@ void MachODebugMapParser::loadMainBinarySymbols() {
|
||||
// addresses should be fetched for the debug map.
|
||||
if (Sym.getAddress(Addr) || Addr == UnknownAddress ||
|
||||
!(Sym.getFlags() & SymbolRef::SF_Global) || Sym.getSection(Section) ||
|
||||
Section->isText() || Sym.getName(Name) || Name.size() == 0 ||
|
||||
Name[0] == '\0')
|
||||
Section->isText())
|
||||
continue;
|
||||
ErrorOr<StringRef> NameOrErr = Sym.getName();
|
||||
if (!NameOrErr)
|
||||
continue;
|
||||
StringRef Name = *NameOrErr;
|
||||
if (Name.size() == 0 || Name[0] == '\0')
|
||||
continue;
|
||||
MainBinarySymbolAddresses[Name] = Addr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user