1010# so that we have time to investigate the issue without losing postcommit CI.
1111# UNSUPPORTED: system-windows
1212
13- # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
13+ # RUN: rm -rf %t && split-file %s %t && cd %t
14+ # RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o %t.o
1415
1516## For an executable, --export-dynamic-symbol exports a symbol if it is non-local and defined.
16- # RUN: ld.lld -pie --export-dynamic-symbol foo --export-dynamic-symbol qux %t.o -o %t
17- # RUN: llvm-nm -D -p %t | FileCheck %s
17+ # RUN: ld.lld -pie --export-dynamic-symbol foo --export-dynamic-symbol qux %t.o -o out
18+ # RUN: llvm-nm -D -p out | FileCheck %s
1819# RUN: echo '{ foo; };' > %t1.list
1920# RUN: echo '{ foo; qux; };' > %t2.list
20- # RUN: ld.lld -pie --export-dynamic-symbol-list=%t2.list %t.o -o %t
21- # RUN: llvm-nm -D -p %t | FileCheck %s
21+ # RUN: ld.lld -pie --export-dynamic-symbol-list=%t2.list %t.o -o out
22+ # RUN: llvm-nm -D -p out | FileCheck %s
2223
2324## --export-dynamic exports all non-local defined symbols.
2425## --export-dynamic-symbol is shadowed.
5354# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol-list %t1.list %t.o -o %t.preempt
5455# RUN: llvm-objdump -d %t.preempt | FileCheck --check-prefix=PLT1 %s
5556
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.o
59+ # RUN: ld.lld -pie %t.o hidden.o --dynamic-list hidden.list -o out.hidden
60+ # RUN: llvm-readelf -s out.hidden | FileCheck %s --check-prefix=HIDDEN
61+
62+ # HIDDEN: '.dynsym' contains 2 entries:
63+ # HIDDEN: NOTYPE GLOBAL DEFAULT [[#]] _end
64+ # HIDDEN: '.symtab' contains 6 entries:
65+ # HIDDEN: FUNC LOCAL HIDDEN [[#]] foo
66+ # HIDDEN-NEXT: NOTYPE LOCAL HIDDEN [[#]] _DYNAMIC
67+ # HIDDEN-NEXT: NOTYPE GLOBAL DEFAULT [[#]] _start
68+ # HIDDEN-NEXT: FUNC GLOBAL DEFAULT [[#]] qux
69+ # HIDDEN-NEXT: NOTYPE GLOBAL DEFAULT [[#]] _end
70+
5671## 'nomatch' does not match any symbol. Don't warn.
5772# RUN: ld.lld --fatal-warnings -shared -Bsymbolic-functions --export-dynamic-symbol nomatch %t.o -o %t.nopreempt2
5873# RUN: llvm-objdump -d %t.nopreempt2 | FileCheck --check-prefix=NOPLT %s
8095# NOPLT-NOT: <foo@plt>
8196# NOPLT-NOT: <qux@plt>
8297
98+ #--- a.s
8399.global _start, foo, qux
84100.type foo, @function
85101.type qux, @function
@@ -88,3 +104,13 @@ _start:
88104 call qux
89105foo:
90106qux:
107+
108+ #--- hidden.s
109+ .hidden foo
110+
111+ .data
112+ .quad _DYNAMIC
113+ .quad _end
114+
115+ #--- hidden.list
116+ {foo;_end;_DYNAMIC;};
0 commit comments