]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/linkerscript/diagnostic.s
Vendor import of lld trunk r290819:
[FreeBSD/FreeBSD.git] / test / ELF / linkerscript / diagnostic.s
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3
4 ## Take some valid script with multiline comments
5 ## and check it actually works:
6 # RUN: echo "SECTIONS {" > %t.script
7 # RUN: echo ".text : { *(.text) }" >> %t.script
8 # RUN: echo ".keep : { *(.keep) } /*" >> %t.script
9 # RUN: echo "comment line 1" >> %t.script
10 # RUN: echo "comment line 2 */" >> %t.script
11 # RUN: echo ".temp : { *(.temp) } }" >> %t.script
12 # RUN: ld.lld -shared %t -o %t1 --script %t.script
13
14 ## Change ":" to "+" at line 2, check that error
15 ## message starts from correct line number:
16 # RUN: echo "SECTIONS {" > %t.script
17 # RUN: echo ".text + { *(.text) }" >> %t.script
18 # RUN: echo ".keep : { *(.keep) } /*" >> %t.script
19 # RUN: echo "comment line 1" >> %t.script
20 # RUN: echo "comment line 2 */" >> %t.script
21 # RUN: echo ".temp : { *(.temp) } }" >> %t.script
22 # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | FileCheck -check-prefix=ERR1 %s
23 # ERR1: {{.*}}.script:2:
24
25 ## Change ":" to "+" at line 3 now, check correct error line number:
26 # RUN: echo "SECTIONS {" > %t.script
27 # RUN: echo ".text : { *(.text) }" >> %t.script
28 # RUN: echo ".keep + { *(.keep) } /*" >> %t.script
29 # RUN: echo "comment line 1" >> %t.script
30 # RUN: echo "comment line 2 */" >> %t.script
31 # RUN: echo ".temp : { *(.temp) } }" >> %t.script
32 # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | FileCheck -check-prefix=ERR2 %s
33 # ERR2: {{.*}}.script:3:
34
35 ## Change ":" to "+" at line 6, after multiline comment,
36 ## check correct error line number:
37 # RUN: echo "SECTIONS {" > %t.script
38 # RUN: echo ".text : { *(.text) }" >> %t.script
39 # RUN: echo ".keep : { *(.keep) } /*" >> %t.script
40 # RUN: echo "comment line 1" >> %t.script
41 # RUN: echo "comment line 2 */" >> %t.script
42 # RUN: echo ".temp + { *(.temp) } }" >> %t.script
43 # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | FileCheck -check-prefix=ERR5 %s
44 # ERR5: {{.*}}.script:6:
45
46 ## Check that text of lines and pointer to 'bad' token are working ok.
47 # RUN: echo "UNKNOWN_TAG {" > %t.script
48 # RUN: echo ".text : { *(.text) }" >> %t.script
49 # RUN: echo ".keep : { *(.keep) }" >> %t.script
50 # RUN: echo ".temp : { *(.temp) } }" >> %t.script
51 # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \
52 # RUN:   FileCheck -check-prefix=ERR6 -strict-whitespace %s
53 # ERR6:      error: {{.*}}.script:1:
54 # ERR6-NEXT: error: {{.*}}.script:1: UNKNOWN_TAG {
55 # ERR6-NEXT: error: {{.*}}.script:1: ^
56
57 ## One more check that text of lines and pointer to 'bad' token are working ok.
58 # RUN: echo "SECTIONS {" > %t.script
59 # RUN: echo ".text : { *(.text) }" >> %t.script
60 # RUN: echo ".keep : { *(.keep) }" >> %t.script
61 # RUN: echo "boom .temp : { *(.temp) } }" >> %t.script
62 # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \
63 # RUN:   FileCheck -check-prefix=ERR7 -strict-whitespace %s
64 # ERR7:      error: {{.*}}.script:4: malformed number: .temp
65 # ERR7-NEXT: error: {{.*}}.script:4: boom .temp : { *(.temp) } }
66 # ERR7-NEXT: error: {{.*}}.script:4:      ^
67
68 ## Check tokenize() error
69 # RUN: echo "SECTIONS {}" > %t.script
70 # RUN: echo "\"" >> %t.script
71 # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \
72 # RUN:   FileCheck -check-prefix=ERR8 -strict-whitespace %s
73 # ERR8: {{.*}}.script:2: unclosed quote
74
75 ## Check tokenize() error in included script file
76 # RUN: echo "SECTIONS {}" > %t.script.inc
77 # RUN: echo "\"" >> %t.script.inc
78 # RUN: echo "INCLUDE \"%t.script.inc\"" > %t.script
79 # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \
80 # RUN:   FileCheck -check-prefix=ERR9 -strict-whitespace %s
81 # ERR9: {{.*}}.script.inc:2: unclosed quote
82
83 ## Check error reporting correctness for included files.
84 # RUN: echo "SECTIONS {" > %t.script.inc
85 # RUN: echo ".text : { *(.text) }" >> %t.script.inc
86 # RUN: echo ".keep : { *(.keep) }" >> %t.script.inc
87 # RUN: echo "boom .temp : { *(.temp) } }" >> %t.script.inc
88 # RUN: echo "INCLUDE \"%t.script.inc\"" > %t.script
89 # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \
90 # RUN:   FileCheck -check-prefix=ERR10 -strict-whitespace %s
91 # ERR10:      error: {{.*}}.script.inc:4: malformed number: .temp
92 # ERR10-NEXT: error: {{.*}}.script.inc:4: boom .temp : { *(.temp) } }
93 # ERR10-NEXT: error: {{.*}}.script.inc:4:      ^
94
95 ## Check error reporting in script with INCLUDE directive.
96 # RUN: echo "SECTIONS {" > %t.script.inc
97 # RUN: echo ".text : { *(.text) }" >> %t.script.inc
98 # RUN: echo ".keep : { *(.keep) }" >> %t.script.inc
99 # RUN: echo ".temp : { *(.temp) } }" >> %t.script.inc
100 # RUN: echo "/* One line before INCLUDE */" > %t.script
101 # RUN: echo "INCLUDE \"%t.script.inc\"" >> %t.script
102 # RUN: echo "/* One line ater INCLUDE */" >> %t.script
103 # RUN: echo "Error" >> %t.script
104 # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \
105 # RUN:   FileCheck -check-prefix=ERR11 -strict-whitespace %s
106 # ERR11: error: {{.*}}.script:4: unexpected EOF