using namespace lld;
using namespace lld::elf;
-using SymbolMapTy = DenseMap<const SectionBase *, SmallVector<Defined *, 4>>;
+using SymbolMapTy = DenseMap<const SectionBase *,
+ SmallVector<std::pair<Defined *, uint64_t>, 0>>;
static constexpr char indent8[] = " "; // 8 spaces
static constexpr char indent16[] = " "; // 16 spaces
static SymbolMapTy getSectionSyms(ArrayRef<Defined *> syms) {
SymbolMapTy ret;
for (Defined *dr : syms)
- ret[dr->section].push_back(dr);
+ ret[dr->section].emplace_back(dr, dr->getVA());
// Sort symbols by address. We want to print out symbols in the
// order in the output file rather than the order they appeared
for (auto &it : ret) {
// Deduplicate symbols which need a canonical PLT entry/copy relocation.
set.clear();
- llvm::erase_if(it.second,
- [&](Defined *sym) { return !set.insert(sym).second; });
-
- llvm::stable_sort(it.second, [](Defined *a, Defined *b) {
- return a->getVA() < b->getVA();
+ llvm::erase_if(it.second, [&](std::pair<Defined *, uint64_t> a) {
+ return !set.insert(a.first).second;
});
+
+ llvm::stable_sort(it.second, llvm::less_second());
}
return ret;
}
writeHeader(os, isec->getVA(), osec->getLMA() + isec->outSecOff,
isec->getSize(), isec->alignment);
os << indent8 << toString(isec) << '\n';
- for (Symbol *sym : sectionSyms[isec])
+ for (Symbol *sym : llvm::make_first_range(sectionSyms[isec]))
os << symStr[sym] << '\n';
}
continue;