summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ScriptParser.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2018-03-28 11:33:00 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2018-03-28 11:33:00 +0000
commitfd11560f6e6ae03c3026f25956339c81c627408d (patch)
tree4896cc3b51d9f9e9909d31ed19f24bc96778d521 /lld/ELF/ScriptParser.cpp
parentcdac172e2a6d8b1efc130ede138e157e21568c85 (diff)
downloadbcm5719-llvm-fd11560f6e6ae03c3026f25956339c81c627408d.tar.gz
bcm5719-llvm-fd11560f6e6ae03c3026f25956339c81c627408d.zip
[ELF] - Linkerscript: support MIN and MAX.
Sample for the OVERLAY command from the spec (https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/sections.html) uses MAX command that we do not support currently: . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1)); This patch implements support for MIN and MAX. Differential revision: https://reviews.llvm.org/D44734 llvm-svn: 328696
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r--lld/ELF/ScriptParser.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 6f16c45baab..ff650d8ef87 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -1097,6 +1097,16 @@ Expr ScriptParser::readPrimary() {
return Cmd->getLMA();
};
}
+ if (Tok == "MAX" || Tok == "MIN") {
+ expect("(");
+ Expr A = readExpr();
+ expect(",");
+ Expr B = readExpr();
+ expect(")");
+ if (Tok == "MIN")
+ return [=] { return std::min(A().getValue(), B().getValue()); };
+ return [=] { return std::max(A().getValue(), B().getValue()); };
+ }
if (Tok == "ORIGIN") {
StringRef Name = readParenLiteral();
if (Script->MemoryRegions.count(Name) == 0) {
OpenPOWER on IntegriCloud