[lld] r297725 - [ELF] - Devirtualize LinkerScriptBase::getOutputSection
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 14 03:15:53 PDT 2017
Author: grimar
Date: Tue Mar 14 05:15:53 2017
New Revision: 297725
URL: http://llvm.org/viewvc/llvm-project?rev=297725&view=rev
Log:
[ELF] - Devirtualize LinkerScriptBase::getOutputSection
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=297725&r1=297724&r2=297725&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Mar 14 05:15:53 2017
@@ -79,6 +79,18 @@ static bool isUnderSysroot(StringRef Pat
return false;
}
+OutputSection *LinkerScriptBase::getOutputSection(const Twine &Loc,
+ StringRef Name) {
+ static OutputSection FakeSec("", 0, 0);
+
+ for (OutputSection *Sec : *OutputSections)
+ if (Sec->Name == Name)
+ return Sec;
+
+ error(Loc + ": undefined section " + Name);
+ return &FakeSec;
+}
+
template <class ELFT>
void LinkerScript<ELFT>::setDot(Expr E, const Twine &Loc, bool InSec) {
uint64_t Val = E();
@@ -902,19 +914,6 @@ template <class ELFT> int LinkerScript<E
return INT_MAX;
}
-template <class ELFT>
-OutputSection *LinkerScript<ELFT>::getOutputSection(const Twine &Loc,
- StringRef Name) {
- static OutputSection FakeSec("", 0, 0);
-
- for (OutputSection *Sec : *OutputSections)
- if (Sec->Name == Name)
- return Sec;
-
- error(Loc + ": undefined section " + Name);
- 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.
//
Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=297725&r1=297724&r2=297725&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Tue Mar 14 05:15:53 2017
@@ -240,13 +240,15 @@ protected:
public:
bool hasPhdrsCommands() { return !Opt.PhdrsCommands.empty(); }
uint64_t getDot() { return Dot; }
+ OutputSection *getOutputSection(const Twine &Loc, 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 OutputSection *getOutputSection(const Twine &Loc, StringRef S) = 0;
virtual uint64_t getOutputSectionSize(StringRef S) = 0;
+
+ std::vector<OutputSection *> *OutputSections;
};
// This is a runner of the linker script.
@@ -275,11 +277,8 @@ public:
bool isDefined(StringRef S) override;
bool isAbsolute(StringRef S) override;
OutputSection *getSymbolSection(StringRef S) override;
- OutputSection *getOutputSection(const Twine &Loc, StringRef S) override;
uint64_t getOutputSectionSize(StringRef S) override;
- std::vector<OutputSection *> *OutputSections;
-
int getSectionIndex(StringRef Name);
private:
More information about the llvm-commits
mailing list