117 lines · plain
1# REQUIRES: x862 3# FIXME: this should be supported on Windows as well. There is a strange issue4# happening with command line processing though. The command line argument5# --export-dynamic-symbol 'f*'6# does not have the single quotes stripped on some Windows targets (but not7# all). This causes the glob matching to fail, which means the test fails on8# some Windows bots and passes on others. However, there's no clear indication9# as to what's changed to cause this behavior. Marking the test as unsupported10# so that we have time to investigate the issue without losing postcommit CI.11# UNSUPPORTED: system-windows12 13# RUN: rm -rf %t && split-file %s %t && cd %t14# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o %t.o15 16## For an executable, --export-dynamic-symbol exports a symbol if it is non-local and defined.17# RUN: ld.lld -pie --export-dynamic-symbol foo --export-dynamic-symbol qux %t.o -o out18# RUN: llvm-nm -D -p out | FileCheck %s19# RUN: echo '{ foo; };' > %t1.list20# RUN: echo '{ foo; qux; };' > %t2.list21# RUN: ld.lld -pie --export-dynamic-symbol-list=%t2.list %t.o -o out22# RUN: llvm-nm -D -p out | FileCheck %s23 24## --export-dynamic exports all non-local defined symbols.25## --export-dynamic-symbol is shadowed.26# RUN: ld.lld -pie --export-dynamic --export-dynamic-symbol foo %t.o -o %t.start27# RUN: llvm-nm -D -p %t.start | FileCheck --check-prefixes=CHECK,START %s28 29# CHECK-NOT: .30# START: T _start31# CHECK: T foo32# CHECK: T qux33# CHECK-NOT: .34 35## --export-dynamic-symbol does not imply -u: %t1.a(%t1.o) is not fetched.36## This is compatible with GNU ld since binutils 2.35 onwards.37# RUN: echo '.globl foo, bar; foo: bar:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o38# RUN: rm -f %t1.a && llvm-ar rc %t1.a %t1.o39# RUN: ld.lld --export-dynamic-symbol bar %t1.a %t.o -o %t.nofetch40# RUN: llvm-nm %t.nofetch | FileCheck /dev/null --implicit-check-not=bar41 42## For -shared, if no option expresses a symbolic intention, --export-dynamic-symbol is a no-op.43# RUN: ld.lld -shared --export-dynamic-symbol foo %t.o -o %t.noop44# RUN: llvm-objdump -d %t.noop | FileCheck --check-prefix=PLT2 %s45# RUN: ld.lld -shared --export-dynamic-symbol-list %t2.list %t.o -o %t.noop46# RUN: llvm-objdump -d %t.noop | FileCheck --check-prefix=PLT2 %s47 48## --export-dynamic-symbol can make a symbol preemptible even if it would be otherwise49## non-preemptible (due to -Bsymbolic, -Bsymbolic-functions or --dynamic-list).50# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol nomatch %t.o -o %t.nopreempt51# RUN: llvm-objdump -d %t.nopreempt | FileCheck --check-prefix=NOPLT %s52# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol foo %t.o -o %t.preempt53# RUN: llvm-objdump -d %t.preempt | FileCheck --check-prefix=PLT1 %s54# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol-list %t1.list %t.o -o %t.preempt55# RUN: llvm-objdump -d %t.preempt | FileCheck --check-prefix=PLT1 %s56 57## Hidden symbols cannot be exported by --export-dynamic-symbol family options.58# RUN: llvm-mc -filetype=obj -triple=x86_64 hidden.s -o hidden.o59# RUN: ld.lld -pie %t.o hidden.o --dynamic-list hidden.list -o out.hidden60# RUN: llvm-readelf -s out.hidden | FileCheck %s --check-prefix=HIDDEN61 62# HIDDEN: '.dynsym' contains 2 entries:63# HIDDEN: NOTYPE GLOBAL DEFAULT [[#]] _end64# HIDDEN: '.symtab' contains 6 entries:65# HIDDEN: FUNC LOCAL HIDDEN [[#]] foo66# HIDDEN-NEXT: NOTYPE LOCAL HIDDEN [[#]] _DYNAMIC67# HIDDEN-NEXT: NOTYPE GLOBAL DEFAULT [[#]] _start68# HIDDEN-NEXT: FUNC GLOBAL DEFAULT [[#]] qux69# HIDDEN-NEXT: NOTYPE GLOBAL DEFAULT [[#]] _end70 71## 'nomatch' does not match any symbol. Don't warn.72# RUN: ld.lld --fatal-warnings -shared -Bsymbolic-functions --export-dynamic-symbol nomatch %t.o -o %t.nopreempt273# RUN: llvm-objdump -d %t.nopreempt2 | FileCheck --check-prefix=NOPLT %s74# RUN: ld.lld -shared -Bsymbolic-functions --export-dynamic-symbol foo %t.o -o %t.preempt275# RUN: llvm-objdump -d %t.preempt2 | FileCheck --check-prefix=PLT1 %s76 77# RUN: echo '{};' > %t.list78# RUN: ld.lld -shared --dynamic-list %t.list --export-dynamic-symbol foo %t.o -o %t.preempt379# RUN: llvm-objdump -d %t.preempt3 | FileCheck --check-prefix=PLT1 %s80 81## The option value is a glob.82# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f*' %t.o -o - | \83# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT1 %s84# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol '[f]o[o]' %t.o -o - | \85# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT1 %s86# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f?o' %t.o -o - | \87# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT1 %s88 89# PLT1: <foo@plt>90# PLT1: <qux>91 92# PLT2: <foo@plt>93# PLT2: <qux@plt>94 95# NOPLT-NOT: <foo@plt>96# NOPLT-NOT: <qux@plt>97 98#--- a.s99.global _start, foo, qux100.type foo, @function101.type qux, @function102_start:103 call foo104 call qux105foo:106qux:107 108#--- hidden.s109.hidden foo110 111.data112.quad _DYNAMIC113.quad _end114 115#--- hidden.list116{foo;_end;_DYNAMIC;};117