[ELF] - Linkerscript: simplify access to templated methods from parser.
Previous way of accessing templated methods was a bit bulky,
Patch introduces small interface based solution.
Differential revision: https://reviews.llvm.org/D23872
llvm-svn: 280910
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index b27d1da..5b40324 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -123,6 +123,14 @@
unsigned Flags;
};
+class LinkerScriptBase {
+public:
+ virtual uint64_t getOutputSectionAddress(StringRef Name) = 0;
+ virtual uint64_t getOutputSectionSize(StringRef Name) = 0;
+ virtual uint64_t getHeaderSize() = 0;
+ virtual uint64_t getSymbolValue(StringRef S) = 0;
+};
+
// ScriptConfiguration holds linker script parse results.
struct ScriptConfiguration {
// Used to create symbol assignments outside SECTIONS command.
@@ -145,7 +153,7 @@
extern ScriptConfiguration *ScriptConfig;
// This is a runner of the linker script.
-template <class ELFT> class LinkerScript {
+template <class ELFT> class LinkerScript final : public LinkerScriptBase {
typedef typename ELFT::uint uintX_t;
public:
@@ -163,9 +171,10 @@
void assignAddresses();
int compareSections(StringRef A, StringRef B);
bool hasPhdrsCommands();
- uintX_t getOutputSectionAddress(StringRef Name);
- uintX_t getOutputSectionSize(StringRef Name);
- uintX_t getHeaderSize();
+ uint64_t getOutputSectionAddress(StringRef Name) override;
+ uint64_t getOutputSectionSize(StringRef Name) override;
+ uint64_t getHeaderSize() override;
+ uint64_t getSymbolValue(StringRef S) override;
std::vector<OutputSectionBase<ELFT> *> *OutputSections;
@@ -193,6 +202,8 @@
template <class ELFT> struct Script { static LinkerScript<ELFT> *X; };
template <class ELFT> LinkerScript<ELFT> *Script<ELFT>::X;
+extern LinkerScriptBase *ScriptBase;
+
} // namespace elf
} // namespace lld