summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.h
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/LinkerScript.h')
-rw-r--r--lld/ELF/LinkerScript.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index bdfcb7d4256..edda27bdb94 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -20,7 +20,23 @@ namespace lld {
namespace elf2 {
class ScriptParser;
+template <class ELFT> class InputSectionBase;
+// This class represents each rule in SECTIONS command.
+class SectionRule {
+public:
+ SectionRule(StringRef D, StringRef S) : Dest(D), SectionPattern(S) {}
+
+ // Returns true if S should be in Dest section.
+ template <class ELFT> bool match(InputSectionBase<ELFT> *S);
+
+ StringRef Dest;
+
+private:
+ StringRef SectionPattern;
+};
+
+// This is a runner of the linker script.
class LinkerScript {
friend class ScriptParser;
@@ -29,14 +45,13 @@ public:
// this object and Config.
void read(MemoryBufferRef MB);
- StringRef getOutputSection(StringRef InputSection);
- bool isDiscarded(StringRef InputSection);
+ template <class ELFT> StringRef getOutputSection(InputSectionBase<ELFT> *S);
+ template <class ELFT> bool isDiscarded(InputSectionBase<ELFT> *S);
int compareSections(StringRef A, StringRef B);
private:
- // A map for SECTIONS command. The key is input section name
- // and the value is the corresponding output section name.
- llvm::DenseMap<StringRef, StringRef> Sections;
+ // SECTIONS commands.
+ std::vector<SectionRule> Sections;
// Output sections are sorted by this order.
std::vector<StringRef> SectionOrder;
OpenPOWER on IntegriCloud