Index: lld/trunk/ELF/LinkerScript.h =================================================================== --- lld/trunk/ELF/LinkerScript.h +++ lld/trunk/ELF/LinkerScript.h @@ -205,20 +205,6 @@ uint32_t NegFlags; }; -class LinkerScriptBase { -protected: - ~LinkerScriptBase() = default; - OutputSection *Aether; - -public: - virtual uint64_t getSymbolValue(const Twine &Loc, StringRef S) = 0; - uint64_t getDot() { return getSymbolValue("", "."); } - virtual bool isDefined(StringRef S) = 0; - virtual bool isAbsolute(StringRef S) = 0; - virtual OutputSection *getSymbolSection(StringRef S) = 0; - virtual OutputSection *getOutputSection(const Twine &Loc, StringRef S) = 0; - virtual uint64_t getOutputSectionSize(StringRef S) = 0; -}; // ScriptConfiguration holds linker script parse results. struct ScriptConfiguration { @@ -240,6 +226,26 @@ extern ScriptConfiguration *ScriptConfig; +class LinkerScriptBase { +protected: + ~LinkerScriptBase() = default; + OutputSection *Aether; + + // "ScriptConfig" is a bit too long, so define a short name for it. + ScriptConfiguration &Opt = *ScriptConfig; + +public: + bool hasPhdrsCommands() { return !Opt.PhdrsCommands.empty(); } + + virtual uint64_t getSymbolValue(const Twine &Loc, StringRef S) = 0; + uint64_t getDot() { return getSymbolValue("", "."); } + virtual bool isDefined(StringRef S) = 0; + virtual bool isAbsolute(StringRef S) = 0; + virtual OutputSection *getSymbolSection(StringRef S) = 0; + virtual OutputSection *getOutputSection(const Twine &Loc, StringRef S) = 0; + virtual uint64_t getOutputSectionSize(StringRef S) = 0; +}; + // This is a runner of the linker script. template class LinkerScript final : public LinkerScriptBase { typedef typename ELFT::uint uintX_t; @@ -264,7 +270,6 @@ void assignOffsets(OutputSectionCommand *Cmd); void placeOrphanSections(); void assignAddresses(std::vector &Phdrs); - bool hasPhdrsCommands(); uint64_t getSymbolValue(const Twine &Loc, StringRef S) override; bool isDefined(StringRef S) override; bool isAbsolute(StringRef S) override; @@ -287,9 +292,6 @@ std::vector createInputSectionList(OutputSectionCommand &Cmd); - // "ScriptConfig" is a bit too long, so define a short name for it. - ScriptConfiguration &Opt = *ScriptConfig; - std::vector getPhdrIndices(StringRef SectionName); size_t getPhdrIndex(const Twine &Loc, StringRef PhdrName); Index: lld/trunk/ELF/LinkerScript.cpp =================================================================== --- lld/trunk/ELF/LinkerScript.cpp +++ lld/trunk/ELF/LinkerScript.cpp @@ -792,7 +792,7 @@ Sec->Addr = 0; } - allocateHeaders(Phdrs, *OutputSections, MinVA); + allocateHeaders(Phdrs, *OutputSections, MinVA); } // Creates program headers as instructed by PHDRS linker script command. @@ -902,10 +902,6 @@ return INT_MAX; } -template bool LinkerScript::hasPhdrsCommands() { - return !Opt.PhdrsCommands.empty(); -} - template OutputSection *LinkerScript::getOutputSection(const Twine &Loc, StringRef Name) { Index: lld/trunk/ELF/Writer.h =================================================================== --- lld/trunk/ELF/Writer.h +++ lld/trunk/ELF/Writer.h @@ -49,7 +49,6 @@ llvm::StringRef getOutputSectionName(llvm::StringRef Name); -template bool allocateHeaders(std::vector &, llvm::ArrayRef, uint64_t Min); Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -1439,7 +1439,6 @@ } } -template bool elf::allocateHeaders(std::vector &Phdrs, ArrayRef OutputSections, uint64_t Min) { @@ -1466,7 +1465,7 @@ Out::ElfHeader->Addr = Min; Out::ProgramHeaders->Addr = Min + Out::ElfHeader->Size; - if (Script::X->hasPhdrsCommands()) + if (ScriptBase->hasPhdrsCommands()) return true; if (FirstPTLoad->First) @@ -1495,7 +1494,7 @@ for (const auto &P : Config->SectionStartMap) Min = std::min(Min, P.second); - AllocateHeader = allocateHeaders(Phdrs, OutputSections, Min); + AllocateHeader = allocateHeaders(Phdrs, OutputSections, Min); } // Assign VAs (addresses at run-time) to output sections. @@ -1877,19 +1876,6 @@ template void elf::writeResult(); template void elf::writeResult(); -template bool elf::allocateHeaders(std::vector &, - ArrayRef, - uint64_t); -template bool elf::allocateHeaders(std::vector &, - ArrayRef, - uint64_t); -template bool elf::allocateHeaders(std::vector &, - ArrayRef, - uint64_t); -template bool elf::allocateHeaders(std::vector &, - ArrayRef, - uint64_t); - template bool elf::isRelroSection(const OutputSection *); template bool elf::isRelroSection(const OutputSection *); template bool elf::isRelroSection(const OutputSection *);