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
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
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
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
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
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
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
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
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
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
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
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
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
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
72 # Check that symbols only in unused archive members result in a warning.
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
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
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
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
103 # SAMESYM: warning: {{.*}}.txt: duplicate ordered symbol: _start
105 # SYNTHETIC: warning: <internal>: unable to order synthetic symbol: _GLOBAL_OFFSET_TABLE_
107 # DISCARD: warning: {{.*}}1.o: unable to order discarded symbol: discard
109 # GC: warning: {{.*}}1.o: unable to order discarded symbol: gc
111 # SHARED: warning: {{.*}}.so: unable to order shared symbol: shared
113 # UNDEFINED: warning: {{.*}}3.o: unable to order undefined symbol: undefined
115 # ABSOLUTE: warning: {{.*}}1.o: unable to order absolute symbol: absolute
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
126 .section .text.gc,"ax",@progbits
131 .section .text.discard,"ax",@progbits
136 .section .text.comdat,"axG",@progbits,comdat,comdat
141 .section .text.glob_or_wk,"ax",@progbits
146 .section .text._start,"ax",@progbits
152 .section .text.icf1,"ax",@progbits
157 .section .text.icf2,"ax",@progbits
162 # This is a "good" instance of the symbol
163 .section .text.multi,"ax",@progbits
165 .quad _GLOBAL_OFFSET_TABLE_