[lld] r297727 - [ELF] - Devirtualize LinkerScriptBase::getOutputSectionSize. NFC.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 14 03:24:47 PDT 2017
Author: grimar
Date: Tue Mar 14 05:24:47 2017
New Revision: 297727
URL: http://llvm.org/viewvc/llvm-project?rev=297727&view=rev
Log:
[ELF] - Devirtualize LinkerScriptBase::getOutputSectionSize. NFC.
It does not use ELFT templates so can be non-virtual.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/LinkerScript.h
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=297727&r1=297726&r2=297727&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Mar 14 05:24:47 2017
@@ -91,6 +91,19 @@ OutputSection *LinkerScriptBase::getOutp
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 @@ template <class ELFT> int LinkerScript<E
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 == ".")
Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=297727&r1=297726&r2=297727&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Tue Mar 14 05:24:47 2017
@@ -241,12 +241,12 @@ public:
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 @@ public:
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);
More information about the llvm-commits
mailing list