2 # RUN: llvm-mc -filetype=obj -triple=x86_64 /dev/null -o %t.o
3 # RUN: ld.lld %t.o -T %s -o %t
4 # RUN: llvm-nm -p %t | FileCheck %s
8 unary =!0 + !0; # Test space can be omitted between = and !
12 multiplicative = 20 / 2 % 7;
13 additive = 1 - 2 + -3 * -2;
14 shift = 2 << 5 >> 1 << 2;
15 shift2 = 2 << 69 >> 65;
17 lesseq = 1<<0 <= 1>>0 ? 1 : 2;
18 greater = 0 > 1 ? 1 : 2;
19 greatereq = 1 >= 1 ? 1 : 2;
21 neq = 1 != 1 <= 1 ? 1 : 2;
25 logicaland = (0 && 0) + (0&&1)*2 + (1&& 0)*4 + (1 &&1) *8;
26 logicaland2 = 1 & 0 && 1 | 1;
27 logicalor = (0 || 0) + (0||1)*2 + (1|| 0)*4 + (1 ||1) *8;
28 logicalor2 = 0 && 0 || 1 && 1;
29 ternary1 = 0 ? 1 : 2 & 6;
30 ternary2 = 1 ? 2?3:4 : 5?6 :7;
33 mulassign *=2; # Test space can be omitted after *=
42 lshiftassign <<= 65; # arbitrarily reduced to 1
45 rshiftassign >>= 130; # arbitrarily reduced to 2
55 braces = 1 + (2 + 3) * 4;
56 precedence1 = 1|0xff&1/1<<1+1*2;
57 precedence2 = (1 | (0xff & (1 << (1 + (1 * 2)))));
58 maxpagesize = CONSTANT (MAXPAGESIZE);
59 commonpagesize = CONSTANT (COMMONPAGESIZE);
61 datasegmentalign = DATA_SEGMENT_ALIGN (0xffff, 0);
62 datasegmentalign2 = DATA_SEGMENT_ALIGN (0, 0);
64 minus_rel = _end - 0x10;
65 minus_abs = _end - _start;
68 log2ceil0 = LOG2CEIL(0);
69 log2ceil1 = LOG2CEIL(1);
70 log2ceil2 = LOG2CEIL(2);
71 log2ceil3 = LOG2CEIL(3);
72 log2ceil4 = LOG2CEIL(4);
73 log2ceil100000000 = LOG2CEIL(0x100000000);
74 log2ceil100000001 = LOG2CEIL(0x100000001);
75 log2ceilmax = LOG2CEIL(0xffffffffffffffff);
78 # CHECK: 0000000000000002 A unary
79 # CHECK-NEXT: fffffffffffffffe A negate
80 # CHECK-NEXT: ffffffffffff0004 A not
81 # CHECK-NEXT: 0000000000000007 A not_negate
82 # CHECK-NEXT: 0000000000000003 A multiplicative
83 # CHECK-NEXT: 0000000000000005 A additive
84 # CHECK-NEXT: 0000000000000080 A shift
85 # CHECK-NEXT: 0000000000000020 A shift
86 # CHECK-NEXT: 0000000000000002 A less
87 # CHECK-NEXT: 0000000000000001 A lesseq
88 # CHECK-NEXT: 0000000000000002 A greater
89 # CHECK-NEXT: 0000000000000001 A greatereq
90 # CHECK-NEXT: 0000000000000001 A eq
91 # CHECK-NEXT: 0000000000000002 A neq
92 # CHECK-NEXT: 0000000000000001 A and
93 # CHECK-NEXT: 00000000000000ab A or
94 # CHECK-NEXT: 0000000000000007 A xor
95 # CHECK-NEXT: 0000000000000008 A logicaland
96 # CHECK-NEXT: 0000000000000000 A logicaland2
97 # CHECK-NEXT: 000000000000000e A logicalor
98 # CHECK-NEXT: 0000000000000001 A logicalor2
99 # CHECK-NEXT: 0000000000000002 A ternary1
100 # CHECK-NEXT: 0000000000000003 A ternary2
101 # CHECK-NEXT: 0000000000000004 A mulassign
102 # CHECK-NEXT: 0000000000000004 A divassign
103 # CHECK-NEXT: 0000000000000003 A plusassign
104 # CHECK-NEXT: 0000000000000002 A minusassign
105 # CHECK-NEXT: 0000000000000004 A lshiftassign
106 # CHECK-NEXT: 0000000000000003 A rshiftassign
107 # CHECK-NEXT: 0000000000000004 A andassign
108 # CHECK-NEXT: 0000000000000005 A xorassign
109 # CHECK-NEXT: 0000000000000005 A orassign
110 # CHECK-NEXT: 0000000000000015 A braces
111 # CHECK-NEXT: 0000000000000009 A precedence1
112 # CHECK-NEXT: 0000000000000009 A precedence2
113 # CHECK-NEXT: 0000000000001000 A maxpagesize
114 # CHECK-NEXT: 0000000000001000 A commonpagesize
115 # CHECK-NEXT: 0000000000010000 A datasegmentalign
116 # CHECK-NEXT: 000000000000fff0 A datasegmentalign2
117 # CHECK-NEXT: 000000000000ffe0 T minus_rel
118 # CHECK-NEXT: 000000000000fff0 A minus_abs
119 # CHECK-NEXT: 0000000000000016 A max
120 # CHECK-NEXT: 000000000000000b A min
121 # CHECK-NEXT: 0000000000000000 A log2ceil0
122 # CHECK-NEXT: 0000000000000000 A log2ceil1
123 # CHECK-NEXT: 0000000000000001 A log2ceil2
124 # CHECK-NEXT: 0000000000000002 A log2ceil3
125 # CHECK-NEXT: 0000000000000002 A log2ceil4
126 # CHECK-NEXT: 0000000000000020 A log2ceil100000000
127 # CHECK-NEXT: 0000000000000021 A log2ceil100000001
128 # CHECK-NEXT: 0000000000000040 A log2ceilmax
130 ## Mailformed number error.
131 # RUN: echo "SECTIONS { . = 0x12Q41; }" > %t.script
132 # RUN: not ld.lld %t.o -T %t.script -o /dev/null 2>&1 | \
133 # RUN: FileCheck --check-prefix=NUMERR %s
134 # NUMERR: malformed number: 0x12Q41
136 ## Missing closing bracket.
137 # RUN: echo "SECTIONS { . = (1; }" > %t.script
138 # RUN: not ld.lld %t.o -T %t.script -o /dev/null 2>&1 | \
139 # RUN: FileCheck --check-prefix=BRACKETERR %s
140 # BRACKETERR: ) expected, but got ;
142 ## Missing opening bracket.
143 # RUN: echo "SECTIONS { . = 1); }" > %t.script
144 # RUN: not ld.lld %t.o -T %t.script -o /dev/null 2>&1 | \
145 # RUN: FileCheck --check-prefix=BRACKETERR2 %s
146 # BRACKETERR2: ; expected, but got )
149 # RUN: echo "SECTIONS { . = ; }" > %t.script
150 # RUN: not ld.lld %t.o -T %t.script -o /dev/null 2>&1 | \
151 # RUN: FileCheck --check-prefix=ERREXPR %s
152 # ERREXPR: malformed number: ;
154 ## Div by zero error.
155 # RUN: echo "SECTIONS { . = 1 / 0; }" > %t.script
156 # RUN: not ld.lld %t.o -T %t.script -o /dev/null 2>&1 | \
157 # RUN: FileCheck --check-prefix=DIVZERO %s
158 # DIVZERO: {{.*}}.script:1: division by zero
160 ## Mod by zero error.
161 # RUN: echo "SECTIONS { . = 1 % 0; }" > %t.script
162 # RUN: not ld.lld %t.o -T %t.script -o /dev/null 2>&1 | \
163 # RUN: FileCheck --check-prefix=MODZERO %s
164 # MODZERO: {{.*}}.script:1: modulo by zero
166 ## Broken ternary operator expression.
167 # RUN: echo "SECTIONS { . = 1 ? 2; }" > %t.script
168 # RUN: not ld.lld %t.o -T %t.script -o /dev/null 2>&1 | \
169 # RUN: FileCheck --check-prefix=TERNERR %s
170 # TERNERR: : expected, but got ;
172 ## Div by zero error.
173 # RUN: echo 'a = 1; a /= 0;' > %t.script
174 # RUN: not ld.lld %t.o -T %t.script -o /dev/null 2>&1 | FileCheck --check-prefix=DIVZERO %s
176 ## GNU ld does not support %=.
177 # RUN: echo 'a = 1; a %= 0;' > %t.script
178 # RUN: not ld.lld %t.o -T %t.script -o /dev/null 2>&1 | FileCheck --check-prefix=UNKNOWN1 %s
179 ## For now, we don't support ^= without a preceding space.
180 # RUN: echo 'a = 1; a^=0;' > %t.script
181 # RUN: not ld.lld %t.o -T %t.script -o /dev/null 2>&1 | FileCheck --check-prefix=UNKNOWN2 %s
183 # UNKNOWN1: error: {{.*}}:1: unknown directive: a{{$}}
184 # UNKNOWN2: error: {{.*}}:1: unknown directive: a^=0{{$}}