diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-04-26 17:58:58 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-04-26 17:58:58 +0000 |
commit | ab0cce5f1f0aac2699b9efb4c6d8021497439e9d (patch) | |
tree | 35d07030db7ba38409bec214ff467303df057563 /lld/ELF/MapFile.cpp | |
parent | b09308d82abecaa8505728ceffa28b36c57eb761 (diff) | |
download | bcm5719-llvm-ab0cce5f1f0aac2699b9efb4c6d8021497439e9d.tar.gz bcm5719-llvm-ab0cce5f1f0aac2699b9efb4c6d8021497439e9d.zip |
Replace SharedSymbols with Defined when creating copy relocations.
This is slightly simpler to read IMHO. Now if a symbol has a position
in the file, it is Defined.
The main motivation is that with this a SharedSymbol doesn't need a
section, which reduces the size of SymbolUnion.
With this the peak allocation when linking chromium goes from 568.1 to
564.2 MB.
llvm-svn: 330966
Diffstat (limited to 'lld/ELF/MapFile.cpp')
-rw-r--r-- | lld/ELF/MapFile.cpp | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/lld/ELF/MapFile.cpp b/lld/ELF/MapFile.cpp index 4e8e045783e..c5984c9ebc3 100644 --- a/lld/ELF/MapFile.cpp +++ b/lld/ELF/MapFile.cpp @@ -38,7 +38,7 @@ using namespace llvm::object; using namespace lld; using namespace lld::elf; -typedef DenseMap<const SectionBase *, SmallVector<Symbol *, 4>> SymbolMapTy; +typedef DenseMap<const SectionBase *, SmallVector<Defined *, 4>> SymbolMapTy; static const std::string Indent8 = " "; // 8 spaces static const std::string Indent16 = " "; // 16 spaces @@ -53,44 +53,29 @@ static void writeHeader(raw_ostream &OS, uint64_t VMA, uint64_t LMA, } // Returns a list of all symbols that we want to print out. -static std::vector<Symbol *> getSymbols() { - std::vector<Symbol *> V; - for (InputFile *File : ObjectFiles) { - for (Symbol *B : File->getSymbols()) { - if (auto *SS = dyn_cast<SharedSymbol>(B)) - if (SS->CopyRelSec || SS->NeedsPltAddr) - V.push_back(SS); +static std::vector<Defined *> getSymbols() { + std::vector<Defined *> V; + for (InputFile *File : ObjectFiles) + for (Symbol *B : File->getSymbols()) if (auto *DR = dyn_cast<Defined>(B)) - if (DR->File == File && !DR->isSection() && DR->Section && - DR->Section->Live) + if (!DR->isSection() && DR->Section && DR->Section->Live && + (DR->File == File || DR->NeedsPltAddr || DR->Section->Bss)) V.push_back(DR); - } - } return V; } // Returns a map from sections to their symbols. -static SymbolMapTy getSectionSyms(ArrayRef<Symbol *> Syms) { +static SymbolMapTy getSectionSyms(ArrayRef<Defined *> Syms) { SymbolMapTy Ret; - for (Symbol *S : Syms) { - if (auto *DR = dyn_cast<Defined>(S)) { - Ret[DR->Section].push_back(S); - continue; - } - - SharedSymbol *SS = cast<SharedSymbol>(S); - if (SS->CopyRelSec) - Ret[SS->CopyRelSec].push_back(S); - else - Ret[InX::Plt].push_back(S); - } + for (Defined *DR : Syms) + Ret[DR->Section].push_back(DR); // Sort symbols by address. We want to print out symbols in the // order in the output file rather than the order they appeared // in the input files. for (auto &It : Ret) { - SmallVectorImpl<Symbol *> &V = It.second; - std::stable_sort(V.begin(), V.end(), [](Symbol *A, Symbol *B) { + SmallVectorImpl<Defined *> &V = It.second; + std::stable_sort(V.begin(), V.end(), [](Defined *A, Defined *B) { return A->getVA() < B->getVA(); }); } @@ -101,7 +86,7 @@ static SymbolMapTy getSectionSyms(ArrayRef<Symbol *> Syms) { // Demangling symbols (which is what toString() does) is slow, so // we do that in batch using parallel-for. static DenseMap<Symbol *, std::string> -getSymbolStrings(ArrayRef<Symbol *> Syms) { +getSymbolStrings(ArrayRef<Defined *> Syms) { std::vector<std::string> Str(Syms.size()); parallelForEachN(0, Syms.size(), [&](size_t I) { raw_string_ostream OS(Str[I]); @@ -169,7 +154,7 @@ void elf::writeMapFile() { } // Collect symbol info that we want to print out. - std::vector<Symbol *> Syms = getSymbols(); + std::vector<Defined *> Syms = getSymbols(); SymbolMapTy SectionSyms = getSectionSyms(Syms); DenseMap<Symbol *, std::string> SymStr = getSymbolStrings(Syms); |