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 %p/Inputs/unresolved-symbols.s -o %t2.o
4 # RUN: ld.lld -shared %t2.o -o %t.so
6 ## Check that %t2.o contains undefined symbol undef.
7 # RUN: not ld.lld %t1.o %t2.o -o /dev/null 2>&1 | \
8 # RUN: FileCheck -check-prefix=UNDCHECK %s
9 # UNDCHECK: error: undefined symbol: undef
10 # UNDCHECK: >>> referenced by {{.*}}2.o:(.text+0x1)
12 ## Error out if unknown option value was set.
13 # RUN: not ld.lld %t1.o %t2.o -o /dev/null --unresolved-symbols=xxx 2>&1 | \
14 # RUN: FileCheck -check-prefix=ERR1 %s
15 # ERR1: unknown --unresolved-symbols value: xxx
17 # RUN: not ld.lld %t1.o %t2.o -o /dev/null --unresolved-symbols xxx 2>&1 | \
18 # RUN: FileCheck -check-prefix=ERR1 %s
20 ## Ignore all should not produce error for symbols from object except
21 ## case when --no-undefined specified.
22 # RUN: ld.lld %t2.o -o %t1_1 --unresolved-symbols=ignore-all
23 # RUN: llvm-readobj %t1_1 > /dev/null 2>&1
24 # RUN: not ld.lld %t2.o -o /dev/null --unresolved-symbols=ignore-all --no-undefined 2>&1 | \
25 # RUN: FileCheck -check-prefix=ERRUND %s
26 # ERRUND: error: undefined symbol: undef
27 # ERRUND: >>> referenced by {{.*}}:(.text+0x1)
29 ## Also ignore all should not produce error for symbols from DSOs.
30 # RUN: ld.lld %t1.o %t.so -o %t1_3 --allow-shlib-undefined --unresolved-symbols=ignore-all
31 # RUN: llvm-readobj %t1_3 > /dev/null 2>&1
33 ## Ignoring undefines in objects should not produce error for symbol from object.
34 # RUN: ld.lld %t1.o %t2.o -o %t2 --unresolved-symbols=ignore-in-object-files
35 # RUN: llvm-readobj %t2 > /dev/null 2>&1
36 ## --unresolved-symbols overrides a previous --allow-shlib-undefined.
37 # RUN: not ld.lld %t1.o %t.so -o /dev/null --allow-shlib-undefined --unresolved-symbols=ignore-in-object-files 2>&1 | FileCheck %s --check-prefix=SHLIB
39 # SHLIB: error: undefined reference: undef
41 ## Ignoring undefines in shared should produce error for symbol from object.
42 # RUN: not ld.lld %t2.o -o /dev/null --unresolved-symbols=ignore-in-shared-libs 2>&1 | \
43 # RUN: FileCheck -check-prefix=ERRUND %s
44 ## And should not produce errors for symbols from DSO.
45 # RUN: ld.lld %t1.o %t.so -o %t3_1 --allow-shlib-undefined --unresolved-symbols=ignore-in-shared-libs
46 # RUN: llvm-readobj %t3_1 > /dev/null 2>&1
48 ## Ignoring undefines in shared libs should not produce error for symbol from object
49 ## if we are linking DSO.
50 # RUN: ld.lld -shared %t1.o -o %t4 --unresolved-symbols=ignore-in-shared-libs
51 # RUN: llvm-readobj %t4 > /dev/null 2>&1
53 ## Do not report undefines if linking relocatable.
54 # RUN: ld.lld -r %t1.o %t2.o -o %t5 --unresolved-symbols=report-all
55 # RUN: llvm-readobj %t5 > /dev/null 2>&1
57 ## report-all is the default when linking an executable. Check that we report
58 ## unresolved undefines from both DSO and regular object files.
59 # RUN: not ld.lld -shared %t1.o %t.so -o /dev/null --unresolved-symbols=report-all 2>&1 | FileCheck %s --check-prefix=SHLIB
60 # RUN: ld.lld -shared %t1.o %t.so -o %t6_1
61 # RUN: llvm-readobj %t6_1 > /dev/null 2>&1
62 # RUN: not ld.lld %t2.o -o /dev/null --unresolved-symbols=report-all 2>&1 | \
63 # RUN: FileCheck -check-prefix=ERRUND %s
64 # RUN: not ld.lld %t2.o -o /dev/null 2>&1 | FileCheck -check-prefix=ERRUND %s