summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-02-27 02:31:48 +0000
committerRui Ueyama <ruiu@google.com>2017-02-27 02:31:48 +0000
commit02a036f2e6706c09ac7b43a1d2027c64c0dd9d6d (patch)
tree3a3fbf14d22b513b78e746b0f4afd3f968cedf15
parent9d1bacb1b4c1701e47e106eb7e779221d860e8f6 (diff)
downloadbcm5719-llvm-02a036f2e6706c09ac7b43a1d2027c64c0dd9d6d.tar.gz
bcm5719-llvm-02a036f2e6706c09ac7b43a1d2027c64c0dd9d6d.zip
De-template OutputSectionFactory.
Since OutputSection is no longer a template, it doesn't make much sense to tempalte its factory class. llvm-svn: 296308
-rw-r--r--lld/ELF/LinkerScript.cpp9
-rw-r--r--lld/ELF/LinkerScript.h6
-rw-r--r--lld/ELF/OutputSections.cpp23
-rw-r--r--lld/ELF/OutputSections.h7
-rw-r--r--lld/ELF/Writer.cpp4
5 files changed, 25 insertions, 24 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index f71f877cd8e..bb104090eb1 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -321,7 +321,7 @@ LinkerScript<ELFT>::createInputSectionList(OutputSectionCommand &OutCmd) {
}
template <class ELFT>
-void LinkerScript<ELFT>::processCommands(OutputSectionFactory<ELFT> &Factory) {
+void LinkerScript<ELFT>::processCommands(OutputSectionFactory &Factory) {
for (unsigned I = 0; I < Opt.Commands.size(); ++I) {
auto Iter = Opt.Commands.begin() + I;
const std::unique_ptr<BaseCommand> &Base1 = *Iter;
@@ -383,18 +383,17 @@ void LinkerScript<ELFT>::processCommands(OutputSectionFactory<ELFT> &Factory) {
// Add input sections to an output section.
for (InputSectionBase *S : V)
- Factory.addInputSec(S, Cmd->Name);
+ Factory.addInputSec<ELFT>(S, Cmd->Name);
}
}
}
// Add sections that didn't match any sections command.
template <class ELFT>
-void LinkerScript<ELFT>::addOrphanSections(
- OutputSectionFactory<ELFT> &Factory) {
+void LinkerScript<ELFT>::addOrphanSections(OutputSectionFactory &Factory) {
for (InputSectionBase *S : Symtab<ELFT>::X->Sections)
if (S->Live && !S->OutSec)
- Factory.addInputSec(S, getOutputSectionName(S->Name));
+ Factory.addInputSec<ELFT>(S, getOutputSectionName(S->Name));
}
template <class ELFT> static bool isTbss(OutputSection *Sec) {
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index 4dbd5af919c..bf3dd182cc8 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -34,7 +34,7 @@ class SymbolBody;
class InputSectionBase;
class InputSection;
class OutputSection;
-template <class ELFT> class OutputSectionFactory;
+class OutputSectionFactory;
class InputSectionBase;
// This represents an expression in the linker script.
@@ -247,8 +247,8 @@ public:
LinkerScript();
~LinkerScript();
- void processCommands(OutputSectionFactory<ELFT> &Factory);
- void addOrphanSections(OutputSectionFactory<ELFT> &Factory);
+ void processCommands(OutputSectionFactory &Factory);
+ void addOrphanSections(OutputSectionFactory &Factory);
void removeEmptyCommands();
void adjustSectionsBeforeSorting();
void adjustSectionsAfterSorting();
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index ae325b08119..89bc4408fd0 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -339,8 +339,7 @@ static SectionKey createKey(InputSectionBase *C, StringRef OutsecName) {
return SectionKey{OutsecName, Flags, Alignment};
}
-template <class ELFT>
-OutputSectionFactory<ELFT>::OutputSectionFactory(
+OutputSectionFactory::OutputSectionFactory(
std::vector<OutputSection *> &OutputSections)
: OutputSections(OutputSections) {}
@@ -368,15 +367,15 @@ template <class ELFT> static void reportDiscarded(InputSectionBase *IS) {
}
template <class ELFT>
-void OutputSectionFactory<ELFT>::addInputSec(InputSectionBase *IS,
- StringRef OutsecName) {
+void OutputSectionFactory::addInputSec(InputSectionBase *IS,
+ StringRef OutsecName) {
if (!IS->Live) {
reportDiscarded<ELFT>(IS);
return;
}
SectionKey Key = createKey<ELFT>(IS, OutsecName);
- uintX_t Flags = getOutFlags<ELFT>(IS);
+ uint64_t Flags = getOutFlags<ELFT>(IS);
OutputSection *&Sec = Map[Key];
if (Sec) {
if (getIncompatibleFlags(Sec->Flags) != getIncompatibleFlags(IS->Flags))
@@ -403,7 +402,7 @@ void OutputSectionFactory<ELFT>::addInputSec(InputSectionBase *IS,
Sec->addSection(IS);
}
-template <class ELFT> OutputSectionFactory<ELFT>::~OutputSectionFactory() {}
+OutputSectionFactory::~OutputSectionFactory() {}
SectionKey DenseMapInfo<SectionKey>::getEmptyKey() {
return SectionKey{DenseMapInfo<StringRef>::getEmptyKey(), 0, 0};
@@ -446,9 +445,13 @@ template void OutputSection::writeTo<ELF32BE>(uint8_t *Buf);
template void OutputSection::writeTo<ELF64LE>(uint8_t *Buf);
template void OutputSection::writeTo<ELF64BE>(uint8_t *Buf);
-template class OutputSectionFactory<ELF32LE>;
-template class OutputSectionFactory<ELF32BE>;
-template class OutputSectionFactory<ELF64LE>;
-template class OutputSectionFactory<ELF64BE>;
+template void OutputSectionFactory::addInputSec<ELF32LE>(InputSectionBase *,
+ StringRef);
+template void OutputSectionFactory::addInputSec<ELF32BE>(InputSectionBase *,
+ StringRef);
+template void OutputSectionFactory::addInputSec<ELF64LE>(InputSectionBase *,
+ StringRef);
+template void OutputSectionFactory::addInputSec<ELF64BE>(InputSectionBase *,
+ StringRef);
}
}
diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index 69875137cdd..aeb4617facc 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -134,13 +134,12 @@ namespace elf {
// input section. Output section type is determined by various
// factors, including input section's sh_flags, sh_type and
// linker scripts.
-template <class ELFT> class OutputSectionFactory {
- typedef typename ELFT::Shdr Elf_Shdr;
- typedef typename ELFT::uint uintX_t;
-
+class OutputSectionFactory {
public:
OutputSectionFactory(std::vector<OutputSection *> &OutputSections);
~OutputSectionFactory();
+
+ template <class ELFT>
void addInputSec(InputSectionBase *IS, StringRef OutsecName);
private:
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index e8adcfa6b15..4d7755714a8 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -78,7 +78,7 @@ private:
std::unique_ptr<FileOutputBuffer> Buffer;
std::vector<OutputSection *> OutputSections;
- OutputSectionFactory<ELFT> Factory{OutputSections};
+ OutputSectionFactory Factory{OutputSections};
void addRelIpltSymbols();
void addStartEndSymbols();
@@ -920,7 +920,7 @@ void Writer<ELFT>::forEachRelSec(std::function<void(InputSectionBase &)> Fn) {
template <class ELFT> void Writer<ELFT>::createSections() {
for (InputSectionBase *IS : Symtab<ELFT>::X->Sections)
if (IS)
- Factory.addInputSec(IS, getOutputSectionName(IS->Name));
+ Factory.addInputSec<ELFT>(IS, getOutputSectionName(IS->Name));
sortBySymbolsOrder<ELFT>(OutputSections);
sortInitFini<ELFT>(findSection(".init_array"));
OpenPOWER on IntegriCloud