De-template OutputSectionFactory.

Since OutputSection is no longer a template, it doesn't make much
sense to tempalte its factory class.

llvm-svn: 296308
This commit is contained in:
Rui Ueyama 2017-02-27 02:31:48 +00:00
parent 9d1bacb1b4
commit 02a036f2e6
5 changed files with 25 additions and 24 deletions

View File

@ -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) {

View File

@ -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();

View File

@ -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);
}
}

View File

@ -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:

View File

@ -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"));