summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/LinkerScript.cpp6
-rw-r--r--lld/ELF/LinkerScript.h38
-rw-r--r--lld/ELF/Writer.cpp18
-rw-r--r--lld/ELF/Writer.h1
4 files changed, 23 insertions, 40 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 7f68b5b6e46..85312fb165c 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -792,7 +792,7 @@ void LinkerScript<ELFT>::assignAddresses(std::vector<PhdrEntry> &Phdrs) {
Sec->Addr = 0;
}
- allocateHeaders<ELFT>(Phdrs, *OutputSections, MinVA);
+ allocateHeaders(Phdrs, *OutputSections, MinVA);
}
// Creates program headers as instructed by PHDRS linker script command.
@@ -902,10 +902,6 @@ template <class ELFT> int LinkerScript<ELFT>::getSectionIndex(StringRef Name) {
return INT_MAX;
}
-template <class ELFT> bool LinkerScript<ELFT>::hasPhdrsCommands() {
- return !Opt.PhdrsCommands.empty();
-}
-
template <class ELFT>
OutputSection *LinkerScript<ELFT>::getOutputSection(const Twine &Loc,
StringRef Name) {
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index a268f4fd1ce..6d53cf71ce4 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -205,20 +205,6 @@ struct MemoryRegion {
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 @@ struct ScriptConfiguration {
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 ELFT> class LinkerScript final : public LinkerScriptBase {
typedef typename ELFT::uint uintX_t;
@@ -264,7 +270,6 @@ public:
void assignOffsets(OutputSectionCommand *Cmd);
void placeOrphanSections();
void assignAddresses(std::vector<PhdrEntry> &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 @@ private:
std::vector<InputSectionBase *>
createInputSectionList(OutputSectionCommand &Cmd);
- // "ScriptConfig" is a bit too long, so define a short name for it.
- ScriptConfiguration &Opt = *ScriptConfig;
-
std::vector<size_t> getPhdrIndices(StringRef SectionName);
size_t getPhdrIndex(const Twine &Loc, StringRef PhdrName);
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 3375fc25b54..c3f68ab4747 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1439,7 +1439,6 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {
}
}
-template <class ELFT>
bool elf::allocateHeaders(std::vector<PhdrEntry> &Phdrs,
ArrayRef<OutputSection *> OutputSections,
uint64_t Min) {
@@ -1466,7 +1465,7 @@ bool elf::allocateHeaders(std::vector<PhdrEntry> &Phdrs,
Out::ElfHeader->Addr = Min;
Out::ProgramHeaders->Addr = Min + Out::ElfHeader->Size;
- if (Script<ELFT>::X->hasPhdrsCommands())
+ if (ScriptBase->hasPhdrsCommands())
return true;
if (FirstPTLoad->First)
@@ -1495,7 +1494,7 @@ template <class ELFT> void Writer<ELFT>::fixHeaders() {
for (const auto &P : Config->SectionStartMap)
Min = std::min(Min, P.second);
- AllocateHeader = allocateHeaders<ELFT>(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<ELF32BE>();
template void elf::writeResult<ELF64LE>();
template void elf::writeResult<ELF64BE>();
-template bool elf::allocateHeaders<ELF32LE>(std::vector<PhdrEntry> &,
- ArrayRef<OutputSection *>,
- uint64_t);
-template bool elf::allocateHeaders<ELF32BE>(std::vector<PhdrEntry> &,
- ArrayRef<OutputSection *>,
- uint64_t);
-template bool elf::allocateHeaders<ELF64LE>(std::vector<PhdrEntry> &,
- ArrayRef<OutputSection *>,
- uint64_t);
-template bool elf::allocateHeaders<ELF64BE>(std::vector<PhdrEntry> &,
- ArrayRef<OutputSection *>,
- uint64_t);
-
template bool elf::isRelroSection<ELF32LE>(const OutputSection *);
template bool elf::isRelroSection<ELF32BE>(const OutputSection *);
template bool elf::isRelroSection<ELF64LE>(const OutputSection *);
diff --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h
index b89e984c9e5..a669e42ef20 100644
--- a/lld/ELF/Writer.h
+++ b/lld/ELF/Writer.h
@@ -49,7 +49,6 @@ struct PhdrEntry {
llvm::StringRef getOutputSectionName(llvm::StringRef Name);
-template <class ELFT>
bool allocateHeaders(std::vector<PhdrEntry> &, llvm::ArrayRef<OutputSection *>,
uint64_t Min);
OpenPOWER on IntegriCloud