3 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
5 # RUN: %p/Inputs/allow-shlib-undefined.s -o %t1.o
6 # RUN: ld.lld -shared %t1.o -o %t.so
8 # RUN: ld.lld --allow-shlib-undefined %t.o %t.so -o /dev/null
9 # RUN: not ld.lld --no-allow-shlib-undefined %t.o %t.so -o /dev/null 2>&1 | FileCheck %s
10 # Executable defaults to --no-allow-shlib-undefined
11 # RUN: not ld.lld %t.o %t.so -o /dev/null 2>&1 | FileCheck %s
12 # RUN: ld.lld %t.o %t.so --noinhibit-exec -o /dev/null 2>&1 | FileCheck %s --check-prefix=WARN
13 # RUN: ld.lld %t.o %t.so --warn-unresolved-symbols -o /dev/null 2>&1 | FileCheck %s --check-prefix=WARN
14 # -shared defaults to --allow-shlib-undefined
15 # RUN: ld.lld -shared %t.o %t.so -o /dev/null
17 # RUN: echo | llvm-mc -filetype=obj -triple=x86_64-unknown-linux -o %tempty.o
18 # RUN: ld.lld -shared %tempty.o -o %tempty.so
19 # RUN: ld.lld -shared %t1.o %tempty.so -o %t2.so
20 # RUN: ld.lld --no-allow-shlib-undefined %t.o %t2.so -o /dev/null
23 # should link with or without any of these options.
24 # RUN: ld.lld -shared %t1.o -o /dev/null
25 # RUN: ld.lld -shared --allow-shlib-undefined %t1.o -o /dev/null
26 # RUN: ld.lld -shared --no-allow-shlib-undefined %t1.o -o /dev/null
28 ## Check that the error is reported if an unresolved symbol is first seen in a
29 ## regular object file.
30 # RUN: echo 'callq _unresolved@PLT' | \
31 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tref.o
32 # RUN: not ld.lld --gc-sections %t.o %tref.o %t.so -o /dev/null 2>&1 | FileCheck %s
34 ## Check that the error is reported for each shared library where the symbol
36 # RUN: cp %t.so %t2.so
37 # RUN: not ld.lld %t.o %t.so %t2.so -o /dev/null 2>&1 | \
38 # RUN: FileCheck %s --check-prefixes=CHECK,CHECK2
40 ## Test some cases where relocatable object files provide a hidden definition.
41 # RUN: echo '.globl _unresolved; _unresolved:' | llvm-mc -filetype=obj -triple=x86_64 -o %tdef.o
42 # RUN: echo '.globl _unresolved; .hidden _unresolved; _unresolved:' | llvm-mc -filetype=obj -triple=x86_64 -o %tdef-hidden.o
43 # RUN: ld.lld %t.o %t.so %tdef-hidden.o -o /dev/null 2>&1 | count 0
45 ## The section containing the definition is discarded, and we report an error.
46 # RUN: not ld.lld --gc-sections %t.o %t.so %tdef-hidden.o -o /dev/null 2>&1 | FileCheck %s
47 ## The definition %tdef.so is ignored.
48 # RUN: ld.lld -shared -soname=tdef.so %tdef.o -o %tdef.so
49 # RUN: not ld.lld --gc-sections %t.o %t.so %tdef.so %tdef-hidden.o -o /dev/null 2>&1 | FileCheck %s
55 # CHECK: error: undefined reference due to --no-allow-shlib-undefined: _unresolved
56 # CHECK-NEXT: >>> referenced by {{.*}}.so
57 # CHECK2: error: undefined reference due to --no-allow-shlib-undefined: _unresolved
58 # CHECK2-NEXT: >>> referenced by {{.*}}2.so
59 # WARN: warning: undefined reference due to --no-allow-shlib-undefined: _unresolved
60 # WARN-NEXT: >>> referenced by {{.*}}.so