summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ScriptParser.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2018-07-03 14:02:52 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2018-07-03 14:02:52 +0000
commita50054829dbf2a43d1174c05a0ba69de9099641d (patch)
treeeb862c5a4a53222edad6bc24ef835cc9dd8ff278 /lld/ELF/ScriptParser.cpp
parent3074b9e53f46f7ea398b34c325553dcccf02607a (diff)
downloadbcm5719-llvm-a50054829dbf2a43d1174c05a0ba69de9099641d.tar.gz
bcm5719-llvm-a50054829dbf2a43d1174c05a0ba69de9099641d.zip
[ELF] - Add support for '||' and '&&' in linker scripts.
This is https://bugs.llvm.org//show_bug.cgi?id=37976, we had no support, but seems someone faced it. llvm-svn: 336197
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r--lld/ELF/ScriptParser.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 1d6a2174832..b0982f57bc5 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -524,12 +524,14 @@ void ScriptParser::readSections() {
static int precedence(StringRef Op) {
return StringSwitch<int>(Op)
- .Cases("*", "/", "%", 6)
- .Cases("+", "-", 5)
- .Cases("<<", ">>", 4)
- .Cases("<", "<=", ">", ">=", "==", "!=", 3)
- .Case("&", 2)
- .Case("|", 1)
+ .Cases("*", "/", "%", 8)
+ .Cases("+", "-", 7)
+ .Cases("<<", ">>", 6)
+ .Cases("<", "<=", ">", ">=", "==", "!=", 5)
+ .Case("&", 4)
+ .Case("|", 3)
+ .Case("&&", 2)
+ .Case("||", 1)
.Default(-1);
}
@@ -924,6 +926,10 @@ Expr ScriptParser::combine(StringRef Op, Expr L, Expr R) {
return [=] { return L().getValue() == R().getValue(); };
if (Op == "!=")
return [=] { return L().getValue() != R().getValue(); };
+ if (Op == "||")
+ return [=] { return L().getValue() || R().getValue(); };
+ if (Op == "&&")
+ return [=] { return L().getValue() && R().getValue(); };
if (Op == "&")
return [=] { return bitAnd(L(), R()); };
if (Op == "|")
OpenPOWER on IntegriCloud