File: export-dynamic-symbol.s

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (58 lines) | stat: -rw-r--r-- 2,638 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# REQUIRES: x86

# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o

## For an executable, --export-dynamic-symbol exports a symbol if it is non-local and defined.
# RUN: ld.lld -pie --export-dynamic-symbol foo %t.o -o %t
# RUN: llvm-nm -D -p %t | FileCheck %s

## --export-dynamic exports all non-local defined symbols.
## --export-dynamic-symbol is shadowed.
# RUN: ld.lld -pie --export-dynamic --export-dynamic-symbol foo %t.o -o %t.start
# RUN: llvm-nm -D -p %t.start | FileCheck --check-prefixes=CHECK,START %s

# CHECK-NOT:  .
# START:      T _start
# CHECK:      T foo
# CHECK-NOT:  .

## --export-dynamic-symbol does not imply -u: %t1.a(%t1.o) is not fetched.
## This is compatible with GNU ld since binutils 2.35 onwards.
# RUN: echo '.globl foo, bar; foo: bar:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
# RUN: rm -f %t1.a && llvm-ar rc %t1.a %t1.o
# RUN: ld.lld --export-dynamic-symbol bar %t1.a %t.o -o %t.nofetch
# RUN: llvm-nm %t.nofetch | FileCheck /dev/null --implicit-check-not=bar

## --export-dynamic-symbol can make a symbol preemptible even if it would be otherwise
## non-preemptible (due to -Bsymbolic, -Bsymbolic-functions or --dynamic-list).
# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol nomatch %t.o -o %t.nopreempt
# RUN: llvm-objdump -d %t.nopreempt | FileCheck --check-prefix=NOPLT %s
# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol foo %t.o -o %t.preempt
# RUN: llvm-objdump -d %t.preempt | FileCheck --check-prefix=PLT %s

## 'nomatch' does not match any symbol. Don't warn.
# RUN: ld.lld --fatal-warnings -shared -Bsymbolic-functions --export-dynamic-symbol nomatch %t.o -o %t.nopreempt2
# RUN: llvm-objdump -d %t.nopreempt2 | FileCheck --check-prefix=NOPLT %s
# RUN: ld.lld -shared -Bsymbolic-functions --export-dynamic-symbol foo %t.o -o %t.preempt2
# RUN: llvm-objdump -d %t.preempt2 | FileCheck --check-prefix=PLT %s

# RUN: echo '{};' > %t.list
# RUN: ld.lld -shared --dynamic-list %t.list --export-dynamic-symbol foo %t.o -o %t.preempt3
# RUN: llvm-objdump -d %t.preempt3 | FileCheck --check-prefix=PLT %s

## The option value is a glob.
# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f*' %t.o -o - | \
# RUN:   llvm-objdump -d - | FileCheck --check-prefix=PLT %s
# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol '[f]o[o]' %t.o -o - | \
# RUN:   llvm-objdump -d - | FileCheck --check-prefix=PLT %s
# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f?o' %t.o -o - | \
# RUN:   llvm-objdump -d - | FileCheck --check-prefix=PLT %s

# PLT:       <foo@plt>
# NOPLT-NOT: <foo@plt>

.global _start, foo
.type foo, @function
_start:
  call foo
foo: