|
3 | 3 | # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
|
4 | 4 |
|
5 | 5 | ## For an executable, --export-dynamic-symbol exports a symbol if it is non-local and defined.
|
6 |
| -# RUN: ld.lld -pie --export-dynamic-symbol foo %t.o -o %t |
| 6 | +# RUN: ld.lld -pie --export-dynamic-symbol foo --export-dynamic-symbol qux %t.o -o %t |
| 7 | +# RUN: llvm-nm -D -p %t | FileCheck %s |
| 8 | +# RUN: echo '{ foo; };' > %t1.list |
| 9 | +# RUN: echo '{ foo; qux; };' > %t2.list |
| 10 | +# RUN: ld.lld -pie --export-dynamic-symbol-list=%t2.list %t.o -o %t |
7 | 11 | # RUN: llvm-nm -D -p %t | FileCheck %s
|
8 | 12 |
|
9 | 13 | ## --export-dynamic exports all non-local defined symbols.
|
|
14 | 18 | # CHECK-NOT: .
|
15 | 19 | # START: T _start
|
16 | 20 | # CHECK: T foo
|
| 21 | +# CHECK: T qux |
17 | 22 | # CHECK-NOT: .
|
18 | 23 |
|
19 | 24 | ## --export-dynamic-symbol does not imply -u: %t1.a(%t1.o) is not fetched.
|
|
23 | 28 | # RUN: ld.lld --export-dynamic-symbol bar %t1.a %t.o -o %t.nofetch
|
24 | 29 | # RUN: llvm-nm %t.nofetch | FileCheck /dev/null --implicit-check-not=bar
|
25 | 30 |
|
| 31 | +## For -shared, if no option expresses a symbolic intention, --export-dynamic-symbol is a no-op. |
| 32 | +# RUN: ld.lld -shared --export-dynamic-symbol foo %t.o -o %t.noop |
| 33 | +# RUN: llvm-objdump -d %t.noop | FileCheck --check-prefix=PLT2 %s |
| 34 | +# RUN: ld.lld -shared --export-dynamic-symbol-list %t2.list %t.o -o %t.noop |
| 35 | +# RUN: llvm-objdump -d %t.noop | FileCheck --check-prefix=PLT2 %s |
| 36 | + |
26 | 37 | ## --export-dynamic-symbol can make a symbol preemptible even if it would be otherwise
|
27 | 38 | ## non-preemptible (due to -Bsymbolic, -Bsymbolic-functions or --dynamic-list).
|
28 | 39 | # RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol nomatch %t.o -o %t.nopreempt
|
29 | 40 | # RUN: llvm-objdump -d %t.nopreempt | FileCheck --check-prefix=NOPLT %s
|
30 | 41 | # RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol foo %t.o -o %t.preempt
|
31 |
| -# RUN: llvm-objdump -d %t.preempt | FileCheck --check-prefix=PLT %s |
| 42 | +# RUN: llvm-objdump -d %t.preempt | FileCheck --check-prefix=PLT1 %s |
| 43 | +# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol-list %t1.list %t.o -o %t.preempt |
| 44 | +# RUN: llvm-objdump -d %t.preempt | FileCheck --check-prefix=PLT1 %s |
32 | 45 |
|
33 | 46 | ## 'nomatch' does not match any symbol. Don't warn.
|
34 | 47 | # RUN: ld.lld --fatal-warnings -shared -Bsymbolic-functions --export-dynamic-symbol nomatch %t.o -o %t.nopreempt2
|
35 | 48 | # RUN: llvm-objdump -d %t.nopreempt2 | FileCheck --check-prefix=NOPLT %s
|
36 | 49 | # RUN: ld.lld -shared -Bsymbolic-functions --export-dynamic-symbol foo %t.o -o %t.preempt2
|
37 |
| -# RUN: llvm-objdump -d %t.preempt2 | FileCheck --check-prefix=PLT %s |
| 50 | +# RUN: llvm-objdump -d %t.preempt2 | FileCheck --check-prefix=PLT1 %s |
38 | 51 |
|
39 | 52 | # RUN: echo '{};' > %t.list
|
40 | 53 | # RUN: ld.lld -shared --dynamic-list %t.list --export-dynamic-symbol foo %t.o -o %t.preempt3
|
41 |
| -# RUN: llvm-objdump -d %t.preempt3 | FileCheck --check-prefix=PLT %s |
| 54 | +# RUN: llvm-objdump -d %t.preempt3 | FileCheck --check-prefix=PLT1 %s |
42 | 55 |
|
43 | 56 | ## The option value is a glob.
|
44 | 57 | # RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f*' %t.o -o - | \
|
45 |
| -# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s |
| 58 | +# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT1 %s |
46 | 59 | # RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol '[f]o[o]' %t.o -o - | \
|
47 |
| -# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s |
| 60 | +# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT1 %s |
48 | 61 | # RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f?o' %t.o -o - | \
|
49 |
| -# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s |
| 62 | +# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT1 %s |
| 63 | + |
| 64 | +# PLT1: <foo@plt> |
| 65 | +# PLT1: <qux> |
| 66 | + |
| 67 | +# PLT2: <foo@plt> |
| 68 | +# PLT2: <qux@plt> |
50 | 69 |
|
51 |
| -# PLT: <foo@plt> |
52 | 70 | # NOPLT-NOT: <foo@plt>
|
| 71 | +# NOPLT-NOT: <qux@plt> |
53 | 72 |
|
54 |
| -.global _start, foo |
| 73 | +.global _start, foo, qux |
55 | 74 | .type foo, @function
|
| 75 | +.type qux, @function |
56 | 76 | _start:
|
57 | 77 | call foo
|
| 78 | + call qux |
58 | 79 | foo:
|
| 80 | +qux: |
0 commit comments