diff options
Diffstat (limited to 'tools/dsymutil/MachODebugMapParser.cpp')
-rw-r--r-- | tools/dsymutil/MachODebugMapParser.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/tools/dsymutil/MachODebugMapParser.cpp b/tools/dsymutil/MachODebugMapParser.cpp index b803e410199d..c58545aec999 100644 --- a/tools/dsymutil/MachODebugMapParser.cpp +++ b/tools/dsymutil/MachODebugMapParser.cpp @@ -160,7 +160,7 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex, // symbol table to find its address as it might not be in the // debug map (for common symbols). Value = getMainBinarySymbolAddress(Name); - if (Value == UnknownAddressOrSize) + if (Value == UnknownAddress) return; break; case MachO::N_FUN: @@ -197,12 +197,14 @@ void MachODebugMapParser::loadCurrentObjectFileSymbols() { CurrentObjectAddresses.clear(); for (auto Sym : CurrentObjectHolder.Get().symbols()) { - StringRef Name; + uint64_t Addr; - if (Sym.getAddress(Addr) || Addr == UnknownAddressOrSize || - Sym.getName(Name)) + if (Sym.getAddress(Addr) || Addr == UnknownAddress) + continue; + ErrorOr<StringRef> Name = Sym.getName(); + if (!Name) continue; - CurrentObjectAddresses[Name] = Addr; + CurrentObjectAddresses[*Name] = Addr; } } @@ -212,7 +214,7 @@ void MachODebugMapParser::loadCurrentObjectFileSymbols() { uint64_t MachODebugMapParser::getMainBinarySymbolAddress(StringRef Name) { auto Sym = MainBinarySymbolAddresses.find(Name); if (Sym == MainBinarySymbolAddresses.end()) - return UnknownAddressOrSize; + return UnknownAddress; return Sym->second; } @@ -222,21 +224,24 @@ void MachODebugMapParser::loadMainBinarySymbols() { const MachOObjectFile &MainBinary = MainBinaryHolder.GetAs<MachOObjectFile>(); section_iterator Section = MainBinary.section_end(); for (const auto &Sym : MainBinary.symbols()) { - SymbolRef::Type Type; + SymbolRef::Type Type = Sym.getType(); // Skip undefined and STAB entries. - if (Sym.getType(Type) || (Type & SymbolRef::ST_Debug) || - (Type & SymbolRef::ST_Unknown)) + 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 // of common data won't be described in the debug map. All other // addresses should be fetched for the debug map. - if (Sym.getAddress(Addr) || Addr == UnknownAddressOrSize || + 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; } |