[ELF] - Introduce std::vector<InputFile *> global arrays.
This patch removes lot of static Instances arrays from different input file
classes and introduces global arrays for access instead. Similar to arrays we
have for InputSections/OutputSectionCommands.
It allows to iterate over input files in a non-templated code.
Differential revision: https://reviews.llvm.org/D35987
llvm-svn: 313619
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 4f5a450..9f1cea5 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -115,9 +115,9 @@
return Name;
}
-template <class ELFT> static bool needsInterpSection() {
- return !SharedFile<ELFT>::Instances.empty() &&
- !Config->DynamicLinker.empty() && !Script->ignoreInterpSection();
+static bool needsInterpSection() {
+ return !SharedFiles.empty() && !Config->DynamicLinker.empty() &&
+ !Script->ignoreInterpSection();
}
template <class ELFT> void elf::writeResult() { Writer<ELFT>().run(); }
@@ -273,7 +273,7 @@
Out::ProgramHeaders = make<OutputSection>("", 0, SHF_ALLOC);
Out::ProgramHeaders->updateAlignment(Config->Wordsize);
- if (needsInterpSection<ELFT>()) {
+ if (needsInterpSection()) {
InX::Interp = createInterpSection();
Add(InX::Interp);
} else {
@@ -454,7 +454,8 @@
template <class ELFT> void Writer<ELFT>::copyLocalSymbols() {
if (!InX::SymTab)
return;
- for (ObjFile<ELFT> *F : ObjFile<ELFT>::Instances) {
+ for (InputFile *File : ObjectFiles) {
+ ObjFile<ELFT> *F = cast<ObjFile<ELFT>>(File);
for (SymbolBody *B : F->getLocalSymbols()) {
if (!B->IsLocal)
fatal(toString(F) +
@@ -862,12 +863,12 @@
}
// Sort input sections using the list provided by --symbol-ordering-file.
-template <class ELFT> static void sortBySymbolsOrder() {
+static void sortBySymbolsOrder() {
if (Config->SymbolOrderingFile.empty())
return;
// Sort sections by priority.
- DenseMap<SectionBase *, int> SectionOrder = buildSectionOrder<ELFT>();
+ DenseMap<SectionBase *, int> SectionOrder = buildSectionOrder();
for (BaseCommand *Base : Script->Opt.Commands)
if (auto *Sec = dyn_cast<OutputSection>(Base))
Sec->sort([&](InputSectionBase *S) { return SectionOrder.lookup(S); });
@@ -897,7 +898,7 @@
Old.end());
Script->fabricateDefaultCommands();
- sortBySymbolsOrder<ELFT>();
+ sortBySymbolsOrder();
sortInitFini(findSection(".init_array"));
sortInitFini(findSection(".fini_array"));
sortCtorsDtors(findSection(".ctors"));