1# REQUIRES: x86 2 3# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o 4 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 7# RUN: llvm-nm -D -p %t | FileCheck %s 8 9## --export-dynamic exports all non-local defined symbols. 10## --export-dynamic-symbol is shadowed. 11# RUN: ld.lld -pie --export-dynamic --export-dynamic-symbol foo %t.o -o %t.start 12# RUN: llvm-nm -D -p %t.start | FileCheck --check-prefixes=CHECK,START %s 13 14# CHECK-NOT: . 15# START: T _start 16# CHECK: T foo 17# CHECK-NOT: . 18 19## --export-dynamic-symbol does not imply -u: %t1.a(%t1.o) is not fetched. 20## This is compatible with GNU ld since binutils 2.35 onwards. 21# RUN: echo '.globl foo, bar; foo: bar:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o 22# RUN: rm -f %t1.a && llvm-ar rc %t1.a %t1.o 23# RUN: ld.lld --export-dynamic-symbol bar %t1.a %t.o -o %t.nofetch 24# RUN: llvm-nm %t.nofetch | FileCheck /dev/null --implicit-check-not=bar 25 26## --export-dynamic-symbol can make a symbol preemptible even if it would be otherwise 27## non-preemptible (due to -Bsymbolic, -Bsymbolic-functions or --dynamic-list). 28# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol nomatch %t.o -o %t.nopreempt 29# RUN: llvm-objdump -d %t.nopreempt | FileCheck --check-prefix=NOPLT %s 30# 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 32 33## 'nomatch' does not match any symbol. Don't warn. 34# RUN: ld.lld --fatal-warnings -shared -Bsymbolic-functions --export-dynamic-symbol nomatch %t.o -o %t.nopreempt2 35# RUN: llvm-objdump -d %t.nopreempt2 | FileCheck --check-prefix=NOPLT %s 36# 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 38 39# RUN: echo '{};' > %t.list 40# 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 42 43## The option value is a glob. 44# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f*' %t.o -o - | \ 45# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s 46# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol '[f]o[o]' %t.o -o - | \ 47# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s 48# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f?o' %t.o -o - | \ 49# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s 50 51# PLT: <foo@plt> 52# NOPLT-NOT: <foo@plt> 53 54.global _start, foo 55.type foo, @function 56_start: 57 call foo 58foo: 59