[PATCH] D43880: Fix linker script operator precedence.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 10:10:46 PST 2018
ruiu created this revision.
ruiu added a reviewer: rafael.
Herald added subscribers: arichardson, emaste.
"&" should have higher priority than "|" [1]. Previously,
they had the same priority.
[1] https://sourceware.org/binutils/docs/ld/Operators.html
https://reviews.llvm.org/D43880
Files:
lld/ELF/ScriptParser.cpp
lld/test/ELF/linkerscript/operators.s
Index: lld/test/ELF/linkerscript/operators.s
===================================================================
--- lld/test/ELF/linkerscript/operators.s
+++ lld/test/ELF/linkerscript/operators.s
@@ -22,6 +22,8 @@
# RUN: unary = -1 + 3; \
# RUN: lshift = 1 << 5; \
# RUN: rshift = 0xff >> 3; \
+# RUN: precedence1 = 1 | 0xff & 1 << 1 + 1 * 2; \
+# RUN: precedence2 = (1 | (0xff & (1 << (1 + (1 * 2))))); \
# RUN: maxpagesize = CONSTANT (MAXPAGESIZE); \
# RUN: commonpagesize = CONSTANT (COMMONPAGESIZE); \
# RUN: . = 0xfff0; \
@@ -53,6 +55,8 @@
# CHECK: 00000000000002 *ABS* 00000000 unary
# CHECK: 00000000000020 *ABS* 00000000 lshift
# CHECK: 0000000000001f *ABS* 00000000 rshift
+# CHECK: 00000000000009 *ABS* 00000000 precedence1
+# CHECK: 00000000000009 *ABS* 00000000 precedence2
# CHECK: 00000000001000 *ABS* 00000000 maxpagesize
# CHECK: 00000000001000 *ABS* 00000000 commonpagesize
# CHECK: 0000000000ffff *ABS* 00000000 datasegmentalign
Index: lld/ELF/ScriptParser.cpp
===================================================================
--- lld/ELF/ScriptParser.cpp
+++ lld/ELF/ScriptParser.cpp
@@ -461,11 +461,12 @@
static int precedence(StringRef Op) {
return StringSwitch<int>(Op)
- .Cases("*", "/", 5)
- .Cases("+", "-", 4)
- .Cases("<<", ">>", 3)
- .Cases("<", "<=", ">", ">=", "==", "!=", 2)
- .Cases("&", "|", 1)
+ .Cases("*", "/", 6)
+ .Cases("+", "-", 5)
+ .Cases("<<", ">>", 4)
+ .Cases("<", "<=", ">", ">=", "==", "!=", 3)
+ .Case("&", 2)
+ .Case("|", 1)
.Default(-1);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43880.136326.patch
Type: text/x-patch
Size: 1584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180228/b99e52ac/attachment.bin>
More information about the llvm-commits
mailing list