[ELF] - Devirtualize LinkerScriptBase::getOutputSectionSize. NFC.
It does not use ELFT templates so can be non-virtual.
llvm-svn: 297727
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index bbe0e45..67dda41 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -91,6 +91,19 @@
return &FakeSec;
}
+// This function is essentially the same as getOutputSection(Name)->Size,
+// but it won't print out an error message if a given section is not found.
+//
+// Linker script does not create an output section if its content is empty.
+// We want to allow SIZEOF(.foo) where .foo is a section which happened to
+// be empty. That is why this function is different from getOutputSection().
+uint64_t LinkerScriptBase::getOutputSectionSize(StringRef Name) {
+ for (OutputSection *Sec : *OutputSections)
+ if (Sec->Name == Name)
+ return Sec->Size;
+ return 0;
+}
+
template <class ELFT>
void LinkerScript<ELFT>::setDot(Expr E, const Twine &Loc, bool InSec) {
uint64_t Val = E();
@@ -914,20 +927,6 @@
return INT_MAX;
}
-// This function is essentially the same as getOutputSection(Name)->Size,
-// but it won't print out an error message if a given section is not found.
-//
-// Linker script does not create an output section if its content is empty.
-// We want to allow SIZEOF(.foo) where .foo is a section which happened to
-// be empty. That is why this function is different from getOutputSection().
-template <class ELFT>
-uint64_t LinkerScript<ELFT>::getOutputSectionSize(StringRef Name) {
- for (OutputSection *Sec : *OutputSections)
- if (Sec->Name == Name)
- return Sec->Size;
- return 0;
-}
-
template <class ELFT>
uint64_t LinkerScript<ELFT>::getSymbolValue(const Twine &Loc, StringRef S) {
if (S == ".")
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index 51f8a06..fa8b4ce 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -241,12 +241,12 @@
bool hasPhdrsCommands() { return !Opt.PhdrsCommands.empty(); }
uint64_t getDot() { return Dot; }
OutputSection *getOutputSection(const Twine &Loc, StringRef S);
+ uint64_t getOutputSectionSize(StringRef S);
virtual uint64_t getSymbolValue(const Twine &Loc, StringRef S) = 0;
virtual bool isDefined(StringRef S) = 0;
virtual bool isAbsolute(StringRef S) = 0;
virtual OutputSection *getSymbolSection(StringRef S) = 0;
- virtual uint64_t getOutputSectionSize(StringRef S) = 0;
std::vector<OutputSection *> *OutputSections;
};
@@ -277,7 +277,6 @@
bool isDefined(StringRef S) override;
bool isAbsolute(StringRef S) override;
OutputSection *getSymbolSection(StringRef S) override;
- uint64_t getOutputSectionSize(StringRef S) override;
int getSectionIndex(StringRef Name);