summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.h
diff options
context:
space:
mode:
authorMeador Inge <meadori@codesourcery.com>2017-01-24 02:34:00 +0000
committerMeador Inge <meadori@codesourcery.com>2017-01-24 02:34:00 +0000
commitb889744e5bb7d307872d33dfb3e22cd8416a3a2a (patch)
tree227e327368f448e331c2c8552644e2659c2ae10a /lld/ELF/LinkerScript.h
parente1a56302137f1e2a4874b11a149298bcec8e3ce9 (diff)
downloadbcm5719-llvm-b889744e5bb7d307872d33dfb3e22cd8416a3a2a.tar.gz
bcm5719-llvm-b889744e5bb7d307872d33dfb3e22cd8416a3a2a.zip
[LinkerScript] Implement `MEMORY` command
As specified here: * https://sourceware.org/binutils/docs/ld/MEMORY.html#MEMORY There are two deviations from what is specified for GNU ld: 1. Only integer constants and *not* constant expressions are allowed in `LENGTH` and `ORIGIN` initializations. 2. The `I` and `L` attributes are *not* implemented. With (1) there is currently no easy way to evaluate integer only constant expressions. This can be enhanced in the future. With (2) it isn't clear how these flags map to the `SHF_*` flags or if they even make sense for an ELF linker. Differential Revision: https://reviews.llvm.org/D28911 llvm-svn: 292875
Diffstat (limited to 'lld/ELF/LinkerScript.h')
-rw-r--r--lld/ELF/LinkerScript.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index 505162f0ab4..8dd60405433 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -15,6 +15,7 @@
#include "Writer.h"
#include "lld/Core/LLVM.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -127,6 +128,7 @@ struct OutputSectionCommand : BaseCommand {
uint32_t Filler = 0;
ConstraintKind Constraint = ConstraintKind::NoConstraint;
std::string Location;
+ std::string MemoryRegionName;
};
// This struct represents one section match pattern in SECTIONS() command.
@@ -187,6 +189,18 @@ struct PhdrsCommand {
Expr LMAExpr;
};
+// This struct is used to represent the location and size of regions of
+// target memory. Instances of the struct are created by parsing the
+// MEMORY command.
+struct MemoryRegion {
+ std::string Name;
+ uint64_t Origin;
+ uint64_t Length;
+ uint64_t Offset;
+ uint32_t Flags;
+ uint32_t NotFlags;
+};
+
class LinkerScriptBase {
protected:
~LinkerScriptBase() = default;
@@ -215,6 +229,9 @@ struct ScriptConfiguration {
// List of section patterns specified with KEEP commands. They will
// be kept even if they are unused and --gc-sections is specified.
std::vector<InputSectionDescription *> KeptSections;
+
+ // A map from memory region name to a memory region descriptor.
+ llvm::DenseMap<llvm::StringRef, MemoryRegion> MemoryRegions;
};
extern ScriptConfiguration *ScriptConfig;
@@ -273,9 +290,13 @@ private:
std::vector<size_t> getPhdrIndices(StringRef SectionName);
size_t getPhdrIndex(const Twine &Loc, StringRef PhdrName);
+ MemoryRegion *findMemoryRegion(OutputSectionCommand *Cmd,
+ OutputSectionBase *Sec);
+
uintX_t Dot;
uintX_t LMAOffset = 0;
OutputSectionBase *CurOutSec = nullptr;
+ MemoryRegion *CurMemRegion = nullptr;
uintX_t ThreadBssOffset = 0;
void switchTo(OutputSectionBase *Sec);
void flush();
OpenPOWER on IntegriCloud