/// Load the current object file symbols into CurrentObjectAddresses. void MachODebugMapParser::loadCurrentObjectFileSymbols( const object::MachOObjectFile &Obj) { CurrentObjectAddresses.clear(); for (auto Sym : Obj.symbols()) { uint64_t Addr = Sym.getValue(); Expected<StringRef> Name = Sym.getName(); if (!Name) { // TODO: Actually report errors helpfully. consumeError(Name.takeError()); continue; } // The value of some categories of symbols isn't meaningful. For // example common symbols store their size in the value field, not // their address. Absolute symbols have a fixed address that can // conflict with standard symbols. These symbols (especially the // common ones), might still be referenced by relocations. These // relocations will use the symbol itself, and won't need an // object file address. The object file address field is optional // in the DebugMap, leave it unassigned for these symbols. if (Sym.getFlags() & (SymbolRef::SF_Absolute | SymbolRef::SF_Common)) CurrentObjectAddresses[*Name] = None; else CurrentObjectAddresses[*Name] = Addr; } }
/// Load the current object file symbols into CurrentObjectAddresses. void MachODebugMapParser::loadCurrentObjectFileSymbols( const object::MachOObjectFile &Obj) { CurrentObjectAddresses.clear(); for (auto Sym : Obj.symbols()) { uint64_t Addr = Sym.getValue(); ErrorOr<StringRef> Name = Sym.getName(); if (!Name) continue; CurrentObjectAddresses[*Name] = Addr; } }
/// Load the current object file symbols into CurrentObjectAddresses. void MachODebugMapParser::loadCurrentObjectFileSymbols( const object::MachOObjectFile &Obj) { CurrentObjectAddresses.clear(); for (auto Sym : Obj.symbols()) { uint64_t Addr = Sym.getValue(); ErrorOr<StringRef> Name = Sym.getName(); if (!Name) continue; // Objective-C on i386 uses artificial absolute symbols to // perform some link time checks. Those symbols have a fixed 0 // address that might conflict with real symbols in the object // file. As I cannot see a way for absolute symbols to find // their way into the debug information, let's just ignore those. if (Sym.getFlags() & SymbolRef::SF_Absolute) CurrentObjectAddresses[*Name] = None; else CurrentObjectAddresses[*Name] = Addr; } }
/// Load the current object file symbols into CurrentObjectAddresses. void MachODebugMapParser::loadCurrentObjectFileSymbols( const object::MachOObjectFile &Obj) { CurrentObjectAddresses.clear(); for (auto Sym : Obj.symbols()) { StringRef Name; uint64_t Addr = UnknownAddressOrSize; SymbolRef::Type Type; StringRef SecName; // Undefined symbols won't have an address, but we still want // them, because they might be referenced in the debug information. Sym.getAddress(Addr); object::section_iterator Section = Obj.section_end(); if (!Sym.getSection(Section) && Section != Obj.section_end()) Section->getName(SecName); if (Sym.getName(Name) || Name.empty() || Sym.getType(Type) || Type == SymbolRef::ST_Other) continue; CurrentObjectAddresses.insert(std::make_pair(Name, std::make_pair(Addr, SecName))); uint32_t Flags; Flags = Sym.getFlags(); uint64_t Value; // FIXME: We put every symbol in the debug map, because of the // behavior expected from lookupObjectAddress. Value = getMainBinarySymbolAddress(Name); // Symbols with no known address on either side are of absolutely // no use. if (Addr != UnknownAddressOrSize || Value != UnknownAddressOrSize) CurrentDebugMapObject->addSymbol(Name, Addr, Value, 0, SecName, true); } }