[lld] r323780 - Move function to the file where it is used.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 30 08:24:05 PST 2018
Author: rafael
Date: Tue Jan 30 08:24:04 2018
New Revision: 323780
URL: http://llvm.org/viewvc/llvm-project?rev=323780&view=rev
Log:
Move function to the file where it is used.
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/InputSection.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=323780&r1=323779&r2=323780&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Jan 30 08:24:04 2018
@@ -45,32 +45,6 @@ std::string lld::toString(const InputSec
return (toString(Sec->File) + ":(" + Sec->Name + ")").str();
}
-DenseMap<SectionBase *, int> elf::buildSectionOrder() {
- DenseMap<SectionBase *, int> SectionOrder;
- if (Config->SymbolOrderingFile.empty())
- return SectionOrder;
-
- // Build a map from symbols to their priorities. Symbols that didn't
- // appear in the symbol ordering file have the lowest priority 0.
- // All explicitly mentioned symbols have negative (higher) priorities.
- DenseMap<StringRef, int> SymbolOrder;
- int Priority = -Config->SymbolOrderingFile.size();
- for (StringRef S : Config->SymbolOrderingFile)
- SymbolOrder.insert({S, Priority++});
-
- // Build a map from sections to their priorities.
- for (InputFile *File : ObjectFiles) {
- for (Symbol *Sym : File->getSymbols()) {
- auto *D = dyn_cast<Defined>(Sym);
- if (!D || !D->Section)
- continue;
- int &Priority = SectionOrder[D->Section];
- Priority = std::min(Priority, SymbolOrder.lookup(D->getName()));
- }
- }
- return SectionOrder;
-}
-
template <class ELFT>
static ArrayRef<uint8_t> getSectionContents(ObjFile<ELFT> &File,
const typename ELFT::Shdr &Hdr) {
Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=323780&r1=323779&r2=323780&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Tue Jan 30 08:24:04 2018
@@ -342,10 +342,6 @@ private:
// The list of all input sections.
extern std::vector<InputSectionBase *> InputSections;
-
-// Builds section order for handling --symbol-ordering-file.
-llvm::DenseMap<SectionBase *, int> buildSectionOrder();
-
} // namespace elf
std::string toString(const elf::InputSectionBase *);
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=323780&r1=323779&r2=323780&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jan 30 08:24:04 2018
@@ -1017,6 +1017,33 @@ findOrphanPos(std::vector<BaseCommand *>
return I;
}
+// Builds section order for handling --symbol-ordering-file.
+static DenseMap<SectionBase *, int> buildSectionOrder() {
+ DenseMap<SectionBase *, int> SectionOrder;
+ if (Config->SymbolOrderingFile.empty())
+ return SectionOrder;
+
+ // Build a map from symbols to their priorities. Symbols that didn't
+ // appear in the symbol ordering file have the lowest priority 0.
+ // All explicitly mentioned symbols have negative (higher) priorities.
+ DenseMap<StringRef, int> SymbolOrder;
+ int Priority = -Config->SymbolOrderingFile.size();
+ for (StringRef S : Config->SymbolOrderingFile)
+ SymbolOrder.insert({S, Priority++});
+
+ // Build a map from sections to their priorities.
+ for (InputFile *File : ObjectFiles) {
+ for (Symbol *Sym : File->getSymbols()) {
+ auto *D = dyn_cast<Defined>(Sym);
+ if (!D || !D->Section)
+ continue;
+ int &Priority = SectionOrder[D->Section];
+ Priority = std::min(Priority, SymbolOrder.lookup(D->getName()));
+ }
+ }
+ return SectionOrder;
+}
+
// If no layout was provided by linker script, we want to apply default
// sorting for special input sections. This also handles --symbol-ordering-file.
template <class ELFT> void Writer<ELFT>::sortInputSections() {
More information about the llvm-commits
mailing list