annotate lld/test/ELF/symbol-ordering-file-warnings.s @ 192:d7606dcf6fce

Added tag llvm10 for changeset 0572611fdcc8
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 14 Dec 2020 18:01:34 +0900
parents 1d019706d866
children 2e18cbf3894f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 # REQUIRES: x86
anatofuz
parents:
diff changeset
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
anatofuz
parents:
diff changeset
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/symbol-ordering-file-warnings1.s -o %t2.o
anatofuz
parents:
diff changeset
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/symbol-ordering-file-warnings2.s -o %t3.o
anatofuz
parents:
diff changeset
5 # RUN: ld.lld -shared %t2.o -o %t.so
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 # Check that a warning is emitted for entries in the file that are not present in any used input.
anatofuz
parents:
diff changeset
8 # RUN: echo "missing" > %t-order-missing.txt
anatofuz
parents:
diff changeset
9 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-missing.txt \
anatofuz
parents:
diff changeset
10 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,MISSING
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 # Check that the warning can be disabled.
anatofuz
parents:
diff changeset
13 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-missing.txt \
anatofuz
parents:
diff changeset
14 # RUN: --unresolved-symbols=ignore-all --no-warn-symbol-ordering 2>&1 | \
anatofuz
parents:
diff changeset
15 # RUN: FileCheck %s --check-prefixes=WARN --allow-empty
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 # Check that the warning can be re-enabled
anatofuz
parents:
diff changeset
18 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-missing.txt \
anatofuz
parents:
diff changeset
19 # RUN: --unresolved-symbols=ignore-all --no-warn-symbol-ordering --warn-symbol-ordering 2>&1 | \
anatofuz
parents:
diff changeset
20 # RUN: FileCheck %s --check-prefixes=WARN,MISSING
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 # Check that a warning is emitted for imported shared symbols.
anatofuz
parents:
diff changeset
23 # RUN: echo "shared" > %t-order-shared.txt
anatofuz
parents:
diff changeset
24 # RUN: ld.lld %t1.o %t.so -o %t --symbol-ordering-file %t-order-shared.txt \
anatofuz
parents:
diff changeset
25 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,SHARED
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 # Check that a warning is emitted for absolute symbols.
anatofuz
parents:
diff changeset
28 # RUN: echo "absolute" > %t-order-absolute.txt
anatofuz
parents:
diff changeset
29 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-absolute.txt \
anatofuz
parents:
diff changeset
30 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,ABSOLUTE
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 # Check that a warning is emitted for symbols discarded due to --gc-sections.
anatofuz
parents:
diff changeset
33 # RUN: echo "gc" > %t-order-gc.txt
anatofuz
parents:
diff changeset
34 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-gc.txt --gc-sections \
anatofuz
parents:
diff changeset
35 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,GC
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 # Check that a warning is not emitted for the symbol removed due to --icf.
anatofuz
parents:
diff changeset
38 # RUN: echo "icf1" > %t-order-icf.txt
anatofuz
parents:
diff changeset
39 # RUN: echo "icf2" >> %t-order-icf.txt
anatofuz
parents:
diff changeset
40 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-icf.txt --icf=all \
anatofuz
parents:
diff changeset
41 # RUN: --unresolved-symbols=ignore-all --fatal-warnings
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 # RUN: echo "_GLOBAL_OFFSET_TABLE_" > %t-order-synthetic.txt
anatofuz
parents:
diff changeset
44 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-synthetic.txt --icf=all \
anatofuz
parents:
diff changeset
45 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,SYNTHETIC
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 # Check that a warning is emitted for symbols discarded due to a linker script /DISCARD/ section.
anatofuz
parents:
diff changeset
48 # RUN: echo "discard" > %t-order-discard.txt
anatofuz
parents:
diff changeset
49 # RUN: echo "SECTIONS { /DISCARD/ : { *(.text.discard) } }" > %t.script
anatofuz
parents:
diff changeset
50 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-discard.txt -T %t.script \
anatofuz
parents:
diff changeset
51 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,DISCARD
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 # Check that LLD does not warn for discarded COMDAT symbols, if they are present in the kept instance.
anatofuz
parents:
diff changeset
54 # RUN: echo "comdat" > %t-order-comdat.txt
anatofuz
parents:
diff changeset
55 # RUN: ld.lld %t1.o %t2.o -o %t --symbol-ordering-file %t-order-comdat.txt \
anatofuz
parents:
diff changeset
56 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN --allow-empty
anatofuz
parents:
diff changeset
57
anatofuz
parents:
diff changeset
58 # Check that if a COMDAT was unused and discarded via --gc-sections, warn for each instance.
anatofuz
parents:
diff changeset
59 # RUN: ld.lld %t1.o %t2.o -o %t --symbol-ordering-file %t-order-comdat.txt --gc-sections \
anatofuz
parents:
diff changeset
60 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,COMDAT
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 # Check that if a weak symbol is not kept, because of an equivalent global symbol, no warning is emitted.
anatofuz
parents:
diff changeset
63 # RUN: echo "glob_or_wk" > %t-order-weak.txt
anatofuz
parents:
diff changeset
64 # RUN: ld.lld %t1.o %t2.o -o %t --symbol-ordering-file %t-order-weak.txt \
anatofuz
parents:
diff changeset
65 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN --allow-empty
anatofuz
parents:
diff changeset
66
anatofuz
parents:
diff changeset
67 # Check that symbols only in unused archive members result in a warning.
anatofuz
parents:
diff changeset
68 # RUN: rm -f %t.a
anatofuz
parents:
diff changeset
69 # RUN: llvm-ar rc %t.a %t3.o
anatofuz
parents:
diff changeset
70 # RUN: ld.lld %t1.o %t.a -o %t --symbol-ordering-file %t-order-missing.txt \
anatofuz
parents:
diff changeset
71 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,MISSING --allow-empty
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 # Check that a warning for each same-named symbol with an issue.
anatofuz
parents:
diff changeset
74 # RUN: echo "multi" > %t-order-same-name.txt
anatofuz
parents:
diff changeset
75 # RUN: ld.lld %t1.o %t2.o %t3.o -o %t --symbol-ordering-file %t-order-same-name.txt \
anatofuz
parents:
diff changeset
76 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,MULTI
anatofuz
parents:
diff changeset
77
anatofuz
parents:
diff changeset
78 # Check that a warning is emitted if the same symbol is mentioned multiple times in the ordering file.
anatofuz
parents:
diff changeset
79 # RUN: echo "_start" > %t-order-multiple-same.txt
anatofuz
parents:
diff changeset
80 # RUN: echo "_start" >> %t-order-multiple-same.txt
anatofuz
parents:
diff changeset
81 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-multiple-same.txt \
anatofuz
parents:
diff changeset
82 # RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,SAMESYM
anatofuz
parents:
diff changeset
83
anatofuz
parents:
diff changeset
84 # Check that all warnings can be emitted from the same input.
anatofuz
parents:
diff changeset
85 # RUN: echo "missing_sym" > %t-order-multi.txt
anatofuz
parents:
diff changeset
86 # RUN: echo "undefined" >> %t-order-multi.txt
anatofuz
parents:
diff changeset
87 # RUN: echo "_start" >> %t-order-multi.txt
anatofuz
parents:
diff changeset
88 # RUN: echo "shared" >> %t-order-multi.txt
anatofuz
parents:
diff changeset
89 # RUN: echo "absolute" >> %t-order-multi.txt
anatofuz
parents:
diff changeset
90 # RUN: echo "gc" >> %t-order-multi.txt
anatofuz
parents:
diff changeset
91 # RUN: echo "discard" >> %t-order-multi.txt
anatofuz
parents:
diff changeset
92 # RUN: echo "_GLOBAL_OFFSET_TABLE_" >> %t-order-multi.txt
anatofuz
parents:
diff changeset
93 # RUN: echo "_start" >> %t-order-multi.txt
anatofuz
parents:
diff changeset
94 # RUN: ld.lld %t1.o %t3.o %t.so -o %t --symbol-ordering-file %t-order-multi.txt --gc-sections -T %t.script \
anatofuz
parents:
diff changeset
95 # RUN: 2>&1 | FileCheck %s --check-prefixes=WARN,SAMESYM,ABSOLUTE,SHARED,UNDEFINED,GC,DISCARD,MISSING2,SYNTHETIC
anatofuz
parents:
diff changeset
96
anatofuz
parents:
diff changeset
97 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
98 # SAMESYM: warning: {{.*}}.txt: duplicate ordered symbol: _start
anatofuz
parents:
diff changeset
99 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
100 # SYNTHETIC: warning: <internal>: unable to order synthetic symbol: _GLOBAL_OFFSET_TABLE_
anatofuz
parents:
diff changeset
101 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
102 # DISCARD: warning: {{.*}}1.o: unable to order discarded symbol: discard
anatofuz
parents:
diff changeset
103 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
104 # GC: warning: {{.*}}1.o: unable to order discarded symbol: gc
anatofuz
parents:
diff changeset
105 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
106 # SHARED: warning: {{.*}}.so: unable to order shared symbol: shared
anatofuz
parents:
diff changeset
107 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
108 # UNDEFINED: warning: {{.*}}3.o: unable to order undefined symbol: undefined
anatofuz
parents:
diff changeset
109 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
110 # ABSOLUTE: warning: {{.*}}1.o: unable to order absolute symbol: absolute
anatofuz
parents:
diff changeset
111 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
112 # MISSING: warning: symbol ordering file: no such symbol: missing
anatofuz
parents:
diff changeset
113 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
114 # MISSING2: warning: symbol ordering file: no such symbol: missing_sym
anatofuz
parents:
diff changeset
115 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
116 # COMDAT: warning: {{.*}}1.o: unable to order discarded symbol: comdat
anatofuz
parents:
diff changeset
117 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
118 # MULTI: warning: {{.*}}2.o: unable to order absolute symbol: multi
anatofuz
parents:
diff changeset
119 # WARN-NOT: warning:
anatofuz
parents:
diff changeset
120
anatofuz
parents:
diff changeset
121 absolute = 0x1234
anatofuz
parents:
diff changeset
122
anatofuz
parents:
diff changeset
123 .section .text.gc,"ax",@progbits
anatofuz
parents:
diff changeset
124 .global gc
anatofuz
parents:
diff changeset
125 gc:
anatofuz
parents:
diff changeset
126 nop
anatofuz
parents:
diff changeset
127
anatofuz
parents:
diff changeset
128 .section .text.discard,"ax",@progbits
anatofuz
parents:
diff changeset
129 .global discard
anatofuz
parents:
diff changeset
130 discard:
anatofuz
parents:
diff changeset
131 nop
anatofuz
parents:
diff changeset
132
anatofuz
parents:
diff changeset
133 .section .text.comdat,"axG",@progbits,comdat,comdat
anatofuz
parents:
diff changeset
134 .weak comdat
anatofuz
parents:
diff changeset
135 comdat:
anatofuz
parents:
diff changeset
136 nop
anatofuz
parents:
diff changeset
137
anatofuz
parents:
diff changeset
138 .section .text.glob_or_wk,"ax",@progbits
anatofuz
parents:
diff changeset
139 .weak glob_or_wk
anatofuz
parents:
diff changeset
140 glob_or_wk:
anatofuz
parents:
diff changeset
141 nop
anatofuz
parents:
diff changeset
142
anatofuz
parents:
diff changeset
143 .section .text._start,"ax",@progbits
anatofuz
parents:
diff changeset
144 .global _start
anatofuz
parents:
diff changeset
145 _start:
anatofuz
parents:
diff changeset
146 movq %rax, absolute
anatofuz
parents:
diff changeset
147 callq shared
anatofuz
parents:
diff changeset
148
anatofuz
parents:
diff changeset
149 .section .text.icf1,"ax",@progbits
anatofuz
parents:
diff changeset
150 .global icf1
anatofuz
parents:
diff changeset
151 icf1:
anatofuz
parents:
diff changeset
152 ret
anatofuz
parents:
diff changeset
153
anatofuz
parents:
diff changeset
154 .section .text.icf2,"ax",@progbits
anatofuz
parents:
diff changeset
155 .global icf2
anatofuz
parents:
diff changeset
156 icf2:
anatofuz
parents:
diff changeset
157 ret
anatofuz
parents:
diff changeset
158
anatofuz
parents:
diff changeset
159 # This is a "good" instance of the symbol
anatofuz
parents:
diff changeset
160 .section .text.multi,"ax",@progbits
anatofuz
parents:
diff changeset
161 multi:
anatofuz
parents:
diff changeset
162 .quad _GLOBAL_OFFSET_TABLE_