summaryrefslogtreecommitdiff
path: root/lld/test
diff options
context:
space:
mode:
authorJez Ng <jezng@fb.com>2023-03-27 16:39:37 -0400
committerJez Ng <jezng@fb.com>2023-03-27 16:39:37 -0400
commit4f086218ddc3862b695abc986b2387db55e89da9 (patch)
treec820fbddf5b6cb1881f0712b95c4223f04ef2927 /lld/test
parent64b3bbc5220615b13d4a003877c773b8745a4d00 (diff)
downloadllvm-4f086218ddc3862b695abc986b2387db55e89da9.tar.gz
[lld-macho] Support re-exports of individual symbols
Specifically, we support this: ld64.lld -dylib foo.o libbar.dylib -exported_symbol _bar -o libfoo.dylib Where `_bar` is defined in libbar.dylib. Reviewed By: #lld-macho, smeenai Differential Revision: https://reviews.llvm.org/D144153
Diffstat (limited to 'lld/test')
-rw-r--r--lld/test/MachO/export-options.s24
1 files changed, 23 insertions, 1 deletions
diff --git a/lld/test/MachO/export-options.s b/lld/test/MachO/export-options.s
index 5ec52d15cfd9..3a63afc6d5a3 100644
--- a/lld/test/MachO/export-options.s
+++ b/lld/test/MachO/export-options.s
@@ -1,6 +1,7 @@
# REQUIRES: x86
# RUN: rm -rf %t; split-file %s %t
+# RUN: echo "" | llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/empty.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %t/default.s -o %t/default.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %t/lazydef.s -o %t/lazydef.o
# RUN: llvm-ar --format=darwin rcs %t/lazydef.a %t/lazydef.o
@@ -190,9 +191,27 @@
# NOEXPORTS-NOT: literal_also
# NOEXPORTS-NOT: literal_only
+# RUN: %lld -dylib %t/default.o -o %t/libdefault.dylib
+# RUN: %lld -dylib %t/empty.o %t/libdefault.dylib -exported_symbol _keep_globl \
+# RUN: -exported_symbol _undef -exported_symbol _tlv \
+# RUN: -undefined dynamic_lookup -o %t/reexport-dylib
+# RUN: llvm-objdump --macho --exports-trie %t/reexport-dylib
+
+# REEXPORT: Exports trie:
+# REEXPORT-NEXT: [re-export] _tlv [per-thread] (from libdefault)
+# REEXPORT-NEXT: [re-export] _keep_globl (from libdefault)
+# REEXPORT-NEXT: [re-export] _undef (from unknown)
+
+## -unexported_symbol will not make us re-export symbols in dylibs.
+# RUN: %lld -dylib %t/default.o -o %t/libdefault.dylib
+# RUN: %lld -dylib %t/empty.o %t/libdefault.dylib -unexported_symbol _tlv \
+# RUN: -o %t/unexport-dylib
+# RUN: llvm-objdump --macho --exports-trie %t/unexport-dylib | FileCheck %s \
+# RUN: --check-prefix=EMPTY-TRIE
+
#--- default.s
-.globl _keep_globl, _hide_globl
+.globl _keep_globl, _hide_globl, _tlv
_keep_globl:
retq
_hide_globl:
@@ -203,6 +222,9 @@ _private_extern:
_private:
retq
+.section __DATA,__thread_vars,thread_local_variables
+_tlv:
+
#--- lazydef.s
.globl _keep_lazy