summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ScriptParser.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-05-09 18:24:38 +0000
committerRui Ueyama <ruiu@google.com>2017-05-09 18:24:38 +0000
commit91b95b61f8b815e45ad6c3cdb1d35c70bb9e7bff (patch)
treeef2a8bc1ddef7132e9e58c04df4ecee47a31cd48 /lld/ELF/ScriptParser.cpp
parent41ffc70484532c3cb2bb8110fe585aa7200ebee6 (diff)
downloadbcm5719-llvm-91b95b61f8b815e45ad6c3cdb1d35c70bb9e7bff.tar.gz
bcm5719-llvm-91b95b61f8b815e45ad6c3cdb1d35c70bb9e7bff.zip
Add memory ORIGIN and LENGTH expression support
Adds support for the ORIGIN and LENGTH linker script built in functions. ORIGIN(memory) Return the origin of the memory region LENGTH(memory) Return the length of the memory region Redo of D29775 for refactored linker script parsing. Patch by Robert Clarke Differential Revision: https://reviews.llvm.org/D32934 llvm-svn: 302564
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r--lld/ELF/ScriptParser.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 032ecd50f3e..ca4f4cd2773 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -900,10 +900,22 @@ Expr ScriptParser::readPrimary() {
StringRef Name = readParenLiteral();
return [=] { return Script->isDefined(Name) ? 1 : 0; };
}
+ if (Tok == "LENGTH") {
+ StringRef Name = readParenLiteral();
+ if (Script->Opt.MemoryRegions.count(Name) == 0)
+ setError("memory region not defined: " + Name);
+ return [=] { return Script->Opt.MemoryRegions[Name].Length; };
+ }
if (Tok == "LOADADDR") {
StringRef Name = readParenLiteral();
return [=] { return Script->getOutputSection(Location, Name)->getLMA(); };
}
+ if (Tok == "ORIGIN") {
+ StringRef Name = readParenLiteral();
+ if (Script->Opt.MemoryRegions.count(Name) == 0)
+ setError("memory region not defined: " + Name);
+ return [=] { return Script->Opt.MemoryRegions[Name].Origin; };
+ }
if (Tok == "SEGMENT_START") {
expect("(");
skip();
OpenPOWER on IntegriCloud