1# REQUIRES: x86 2# RUN: rm -rf %t; split-file %s %t 3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/archive-foo.s -o %t/archive-foo.o 4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/archive-baz.s -o %t/archive-baz.o 5# RUN: llvm-ar rcs %t/libfoo.a %t/archive-foo.o 6# RUN: llvm-ar rcs %t/libbaz.a %t/archive-baz.o 7# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/obj.s -o %t/obj.o 8# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/obj-bar.s -o %t/obj-bar.o 9 10# RUN: %lld -dylib -lSystem %t/obj.o -load_hidden %t/libfoo.a -o %t/test.dylib 11# RUN: llvm-nm %t/test.dylib | FileCheck %s 12# RUN: %lld -dylib -lSystem -L%t %t/obj.o -hidden-lfoo -o %t/test2.dylib 13# RUN: llvm-nm %t/test2.dylib | FileCheck %s 14# CHECK-DAG: t _foo 15# CHECK-DAG: d _bar 16 17## If an archive has already been loaded without -load_hidden earlier in the command line, 18## -load_hidden does not have an effect. 19# RUN: %lld -dylib -lSystem %t/obj.o %t/libfoo.a -load_hidden %t/libfoo.a -o %t/test-regular-then-hidden.dylib 20# RUN: llvm-nm %t/test-regular-then-hidden.dylib | FileCheck %s --check-prefix=REGULAR-THEN-HIDDEN 21# REGULAR-THEN-HIDDEN-DAG: T _foo 22# REGULAR-THEN-HIDDEN-DAG: D _bar 23 24## If -load_hidden comes first, the symbols will have hidden visibility. 25# RUN: %lld -dylib -lSystem %t/obj.o -load_hidden %t/libfoo.a %t/libfoo.a -o %t/test-hidden-then-regular.dylib 26# RUN: llvm-nm %t/test-hidden-then-regular.dylib | FileCheck %s --check-prefix=HIDDEN-THEN-REGULAR 27# HIDDEN-THEN-REGULAR-DAG: t _foo 28# HIDDEN-THEN-REGULAR-DAG: d _bar 29 30## If both -load_hidden and -force_load are specified, the earlier one will have an effect. 31# RUN: %lld -dylib -lSystem %t/obj.o %t/libfoo.a -force_load %t/libbaz.a -load_hidden %t/libbaz.a -o %t/test-force-then-hidden.dylib 32# RUN: llvm-nm %t/test-force-then-hidden.dylib | FileCheck %s --check-prefix=FORCE-THEN-HIDDEN 33# FORCE-THEN-HIDDEN: T _baz 34# RUN: %lld -dylib -lSystem %t/obj.o %t/libfoo.a -load_hidden %t/libbaz.a -force_load %t/libbaz.a -o %t/test-hidden-then-force.dylib 35# RUN: llvm-nm %t/test-hidden-then-force.dylib | FileCheck %s --check-prefix=HIDDEN-THEN-FORCE 36# HIDDEN-THEN-FORCE-NOT: _baz 37 38## -load_hidden does not cause the library to be loaded eagerly. 39# RUN: %lld -dylib -lSystem %t/obj.o -load_hidden %t/libfoo.a -load_hidden %t/libbaz.a -o %t/test-lazy.dylib 40# RUN: llvm-nm %t/test-lazy.dylib | FileCheck %s --check-prefix=LAZY 41# LAZY-NOT: _baz 42 43## Specifying the same library twice is fine. 44# RUN: %lld -dylib -lSystem %t/obj.o -load_hidden %t/libfoo.a -load_hidden %t/libfoo.a -o %t/test-twice.dylib 45# RUN: llvm-nm %t/test-twice.dylib | FileCheck %s --check-prefix=TWICE 46# TWICE-DAG: t _foo 47# TWICE-DAG: d _bar 48 49## -load_hidden causes the symbols to have "private external" visibility, so duplicate definitions 50## are not allowed. 51# RUN: not %lld -dylib -lSystem %t/obj.o %t/obj-bar.o -load_hidden %t/libfoo.a 2>&1 | FileCheck %s --check-prefix=DUP 52# DUP: error: duplicate symbol: _bar 53 54#--- archive-foo.s 55.globl _foo 56_foo: 57 58.data 59.globl _bar 60_bar: 61 62#--- archive-baz.s 63.globl _baz 64_baz: 65 66#--- obj-bar.s 67.data 68.globl _bar 69_bar: 70 71#--- obj.s 72.globl _test 73_test: 74 call _foo 75