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