1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
3
4# RUN: echo "SECTIONS { ASSERT(1, fail) }" > %t1.script
5# RUN: ld.lld -shared -o %t1 --script %t1.script %t1.o
6# RUN: llvm-readobj %t1 > /dev/null
7
8# RUN: echo "SECTIONS { ASSERT(0, fail) }" > %t3.script
9# RUN: not ld.lld -o /dev/null -T %t3.script %t1.o 2>&1 | FileCheck --check-prefix=FAIL %s
10# RUN: ld.lld -o /dev/null -T %t3.script %t1.o --noinhibit-exec 2>&1 | FileCheck --check-prefix=FAIL %s
11# FAIL: fail
12
13# RUN: echo "SECTIONS { . = ASSERT(0x1000, fail); }" > %t4.script
14# RUN: ld.lld -shared -o %t4 --script %t4.script %t1.o
15# RUN: llvm-readobj %t4 > /dev/null
16
17# RUN: echo "SECTIONS { .foo : { *(.foo) } }" > %t5.script
18# RUN: echo "ASSERT(SIZEOF(.foo) == 8, fail);" >> %t5.script
19# RUN: ld.lld -shared -o %t5 --script %t5.script %t1.o
20# RUN: llvm-readobj %t5 > /dev/null
21
22## Even without SECTIONS block we still use section names
23## in expressions
24# RUN: echo "ASSERT(SIZEOF(.foo) == 8, fail);" > %t5.script
25# RUN: ld.lld -shared -o %t5 --script %t5.script %t1.o
26# RUN: llvm-readobj %t5 > /dev/null
27
28## Test assertions inside of output section descriptions.
29# RUN: echo "SECTIONS { .foo : { *(.foo) ASSERT(SIZEOF(.foo) == 8, \"true\"); } }" > %t6.script
30# RUN: ld.lld -shared -o %t6 --script %t6.script %t1.o
31# RUN: llvm-readobj %t6 > /dev/null
32
33## Unlike the GNU ld, we accept the ASSERT without the semicolon.
34## It is consistent with how ASSERT can be written outside of the
35## output section declaration.
36# RUN: echo "SECTIONS { .foo : { ASSERT(1, \"true\") } }" > %t7.script
37# RUN: ld.lld -shared -o /dev/null --script %t7.script %t1.o
38
39.section .foo, "a"
40 .quad 0
41