const auto &SymbolMap = Type == SymbolRef::ST_Function ? Functions : Objects;
if (SymbolMap.empty())
return false;
- SymbolDesc SD = { Address, Address };
+ SymbolDesc SD = {Address, UINT64_C(-1)};
+ // SymbolDescs are sorted by (Addr,Size), if several SymbolDescs share the
+ // same Addr, pick the one with the largest Size. This helps us avoid symbols
+ // with no size information (Size=0).
auto SymbolIterator = SymbolMap.upper_bound(SD);
if (SymbolIterator == SymbolMap.begin())
return false;
// the following symbol.
uint64_t Size;
- friend bool operator<(const SymbolDesc &s1, const SymbolDesc &s2) {
- return s1.Addr < s2.Addr;
+ bool operator<(const SymbolDesc &RHS) const {
+ return Addr != RHS.Addr ? Addr < RHS.Addr : Size < RHS.Size;
}
};
std::map<SymbolDesc, StringRef> Functions;