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.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index e4a7a900bfd..c67ab1fc317 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -21,6 +21,7 @@ namespace elf {
class ScriptParser;
template <class ELFT> class InputSectionBase;
+template <class ELFT> class OutputSectionBase;
// This class represents each rule in SECTIONS command.
class SectionRule {
@@ -40,6 +41,17 @@ private:
StringRef SectionPattern;
};
+// This enum represents what we can observe in SECTIONS tag of script:
+// Expr is a location counter change, like ". = . + 0x1000"
+// Section is a description of output section, like ".data :..."
+enum class Command { Expr, Section };
+
+struct LocationNode {
+ Command Type;
+ std::vector<StringRef> Expr;
+ StringRef SectionName;
+};
+
// This is a runner of the linker script.
class LinkerScript {
friend class ScriptParser;
@@ -53,9 +65,16 @@ public:
ArrayRef<uint8_t> getFiller(StringRef Name);
template <class ELFT> bool isDiscarded(InputSectionBase<ELFT> *S);
template <class ELFT> bool shouldKeep(InputSectionBase<ELFT> *S);
+ template <class ELFT>
+ void assignAddresses(std::vector<OutputSectionBase<ELFT> *> &S);
int compareSections(StringRef A, StringRef B);
+ bool DoLayout = false;
+
private:
+ template <class ELFT>
+ void fixupLocations(std::vector<OutputSectionBase<ELFT> *> &);
+ uint64_t evaluate(std::vector<StringRef> &Tokens, uint64_t LocCounter);
template <class ELFT> SectionRule *find(InputSectionBase<ELFT> *S);
// SECTIONS commands.
@@ -67,6 +86,9 @@ private:
// Section fill attribute for each section.
llvm::StringMap<std::vector<uint8_t>> Filler;
+ // Used to assign addresses to sections.
+ std::vector<LocationNode> Locations;
+
llvm::BumpPtrAllocator Alloc;
};
OpenPOWER on IntegriCloud