|
1 | 1 | # REQUIRES: x86
|
2 | 2 |
|
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 |
7 |
| - |
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 |
16 |
| - |
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 |
21 |
| - |
22 |
| -# DSO with undefines: |
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 |
27 |
| - |
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 |
| 3 | +# RUN: rm -rf %t && split-file %s %t && cd %t |
| 4 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 main.s -o main.o |
| 5 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 def.s -o def.o |
| 6 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 def-hidden.s -o def-hidden.o |
| 7 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 ref.s -o ref.o |
| 8 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o && ld.lld -shared a.o -o a.so |
| 9 | +# RUN: cp a.so b.so |
| 10 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 empty.s -o empty.o && ld.lld -shared empty.o -o empty.so |
| 11 | + |
| 12 | +# RUN: ld.lld --allow-shlib-undefined main.o a.so -o /dev/null |
| 13 | +# RUN: not ld.lld --no-allow-shlib-undefined main.o a.so -o /dev/null 2>&1 | FileCheck %s |
| 14 | +## Executable linking defaults to --no-allow-shlib-undefined. |
| 15 | +# RUN: not ld.lld main.o a.so -o /dev/null 2>&1 | FileCheck %s |
| 16 | +# RUN: ld.lld main.o a.so --noinhibit-exec -o /dev/null 2>&1 | FileCheck %s --check-prefix=WARN |
| 17 | +# RUN: ld.lld main.o a.so --warn-unresolved-symbols -o /dev/null 2>&1 | FileCheck %s --check-prefix=WARN |
| 18 | +## -shared linking defaults to --allow-shlib-undefined. |
| 19 | +# RUN: ld.lld -shared main.o a.so -o /dev/null |
| 20 | + |
| 21 | +## DSO with undefines should link with or without any of these options. |
| 22 | +# RUN: ld.lld -shared --allow-shlib-undefined a.o -o /dev/null |
| 23 | +# RUN: ld.lld -shared --no-allow-shlib-undefined a.o -o /dev/null |
| 24 | + |
| 25 | +## Perform checking even if an unresolved symbol is first seen in a regular object file. |
| 26 | +# RUN: not ld.lld --gc-sections main.o ref.o a.so -o /dev/null 2>&1 | FileCheck %s |
33 | 27 |
|
34 | 28 | ## Check that the error is reported for each shared library where the symbol
|
35 | 29 | ## is referenced.
|
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 |
| 30 | +# RUN: not ld.lld main.o a.so empty.so b.so -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK2 |
39 | 31 |
|
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 |
| 32 | +## Test some cases when a relocatable object file provides a non-exported definition. |
| 33 | +# RUN: ld.lld main.o a.so def-hidden.o --fatal-warnings -o /dev/null |
| 34 | +# RUN: ld.lld main.o a.so def-hidden.o -shared --no-allow-shlib-undefined --fatal-warnings -o /dev/null |
| 35 | +# RUN: ld.lld main.o a.so def-hidden.o --allow-shlib-undefined --fatal-warnings -o /dev/null |
| 36 | +## Test a relocatable object file definition that is converted to STB_LOCAL. |
| 37 | +# RUN: ld.lld main.o a.so def-hidden.o --version-script=local.ver --fatal-warnings -o /dev/null |
44 | 38 |
|
45 | 39 | ## 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 |
| 40 | +# RUN: not ld.lld --gc-sections main.o a.so def-hidden.o -o /dev/null 2>&1 | FileCheck %s |
| 41 | +## The definition def.so is ignored. |
| 42 | +# RUN: ld.lld -shared def.o -o def.so |
| 43 | +# RUN: not ld.lld --gc-sections main.o a.so def.so def-hidden.o -o /dev/null 2>&1 | FileCheck %s |
| 44 | + |
| 45 | +# CHECK-NOT: error: |
| 46 | +# CHECK: error: undefined reference due to --no-allow-shlib-undefined: x1{{$}} |
| 47 | +# CHECK-NEXT: >>> referenced by a.so{{$}} |
| 48 | +# CHECK-NOT: {{.}} |
50 | 49 |
|
| 50 | +# CHECK2-NOT: error: |
| 51 | +# CHECK2: error: undefined reference due to --no-allow-shlib-undefined: x1 |
| 52 | +# CHECK2-NEXT: >>> referenced by a.so |
| 53 | +# CHECK2: error: undefined reference due to --no-allow-shlib-undefined: x1 |
| 54 | +# CHECK2-NEXT: >>> referenced by b.so |
| 55 | +# CHECK2-NOT: {{.}} |
| 56 | + |
| 57 | +# WARN: warning: undefined reference due to --no-allow-shlib-undefined: x1 |
| 58 | +# WARN-NEXT: >>> referenced by a.so |
| 59 | + |
| 60 | +#--- main.s |
51 | 61 | .globl _start
|
52 | 62 | _start:
|
53 |
| - callq _shared@PLT |
54 |
| - |
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 |
| 63 | + callq shared@PLT |
| 64 | +#--- ref.s |
| 65 | + callq x1@PLT |
| 66 | +#--- def.s |
| 67 | +.globl x1 |
| 68 | +x1: |
| 69 | +#--- def-hidden.s |
| 70 | +.globl x1 |
| 71 | +.hidden x1 |
| 72 | +x1: |
| 73 | + |
| 74 | +#--- a.s |
| 75 | +.globl shared |
| 76 | +.weak x2 |
| 77 | +shared: |
| 78 | + callq x1@PLT |
| 79 | + movq x2@GOTPCREL(%rip), %rax |
| 80 | + |
| 81 | +#--- empty.s |
| 82 | +#--- local.ver |
| 83 | +v1 { local: x1; }; |
0 commit comments