3 # RUN: split-file %s %t --no-leading-lines
5 # RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %t/test.s -o %t/test.o
7 # RUN: %lld -o %t/test -lSystem -lc++ -framework CoreFoundation %t/libNested.tbd %t/libTlvWeak.tbd %t/test.o
8 # RUN: llvm-objdump --bind --weak-bind --no-show-raw-insn -d -r %t/test | FileCheck %s
10 ## Targeting an arch not listed in the tbd should fallback to an ABI compatible arch
11 # RUN: %lld -arch x86_64h -o %t/test-compat -lSystem -lc++ -framework CoreFoundation %t/libNested.tbd %t/libTlvWeak.tbd %t/test.o
12 # RUN: llvm-objdump --bind --weak-bind --no-show-raw-insn -d -r %t/test-compat | FileCheck %s
14 ## Setting LD_DYLIB_CPU_SUBTYPES_MUST_MATCH forces exact target arch match.
15 # RUN: env LD_DYLIB_CPU_SUBTYPES_MUST_MATCH=1 not %lld -arch x86_64h -o /dev/null -lSystem -lc++ -framework \
16 # RUN: CoreFoundation %t/libNested.tbd %t/libTlvWeak.tbd %t/test.o 2>&1 | FileCheck %s -check-prefix=INCOMPATIBLE
18 # INCOMPATIBLE: error: {{.*}}libSystem.tbd(/usr/lib/libSystem.dylib) is incompatible with x86_64h (macOS11.0)
19 # INCOMPATIBLE-NEXT: error: {{.*}}libc++.tbd(/usr/lib/libc++.dylib) is incompatible with x86_64h (macOS11.0)
20 # INCOMPATIBLE-NEXT: error: {{.*}}CoreFoundation.tbd(/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation) is incompatible with x86_64h (macOS11.0)
22 ## libReexportSystem.tbd tests that we can reference symbols from a 2nd-level
23 ## tapi document, re-exported by a top-level tapi document, which itself is
24 ## re-exported by another top-level tapi document.
25 # RUN: %lld -o %t/with-reexport -lSystem -L%t %t/libReexportNested.tbd %t/libTlvWeak.tbd -lc++ -framework CoreFoundation %t/test.o
26 # RUN: llvm-objdump --bind --weak-bind --no-show-raw-insn -d -r %t/with-reexport | FileCheck %s
29 # CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_CLASS_$_NSObject
30 # CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_METACLASS_$_NSObject
31 # CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_IVAR_$_NSConstantArray._count
32 # CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_EHTYPE_$_NSException
33 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libc++abi ___gxx_personality_v0
34 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libNested3 _deeply_nested
35 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libTlvWeak _weak
36 # CHECK-DAG: __DATA __thread_ptrs {{.*}} pointer 0 libTlvWeak _tlv
38 # CHECK: Weak bind table:
39 # CHECK-DAG: __DATA __data {{.*}} pointer 0 _weak
41 # RUN: llvm-otool -l %t/test | FileCheck --check-prefix=LOAD %s
43 # RUN: llvm-otool -l %t/with-reexport | \
44 # RUN: FileCheck --check-prefixes=LOAD,LOAD-REEXPORT %s
46 # LOAD: cmd LC_LOAD_DYLIB
48 # LOAD-NEXT: name /usr/lib/libSystem.dylib
49 # LOAD-NEXT: time stamp
50 # LOAD-NEXT: current version 1.1.1
51 # LOAD-NEXT: compatibility version
53 # LOAD-REEXPORT: cmd LC_LOAD_DYLIB
54 # LOAD-REEXPORT-NEXT: cmdsize
55 # LOAD-REEXPORT-NEXT: name /usr/lib/libReexportNested.dylib
56 # LOAD-REEXPORT-NEXT: time stamp
57 # LOAD-REEXPORT-NEXT: current version 1.0.0
58 # LOAD-REEXPORT-NEXT: compatibility version
61 .section __TEXT,__text
65 mov _tlv@TLVP
(%rip
), %rax
69 .quad _OBJC_CLASS_$_NSObject
70 .quad _OBJC_METACLASS_$_NSObject
71 .quad _OBJC_IVAR_$_NSConstantArray._count
72 .quad _OBJC_EHTYPE_$_NSException
73 ## This symbol is defined in an inner TAPI document within libNested.tbd.
76 ## This symbol is defined in libc++abi.tbd, but we are linking test.o against
77 ## libc++.tbd (which re-exports libc++abi). Linking against this symbol verifies
78 ## that .tbd file re-exports can refer not just to TAPI documents within the
79 ## same .tbd file, but to other on-disk files as well.
80 .quad ___gxx_personality_v0
84 ## This tests that we can locate a symbol re-exported by a child of a TAPI
89 uuids
: [ 'x86_64: 00000000-0000-0000-0000-000000000000' ]
91 install-name
: '/usr/lib/libNested.dylib'
94 re-exports
: [ '/usr/lib/libNested2.dylib' ]
97 uuids
: [ 'x86_64: 00000000-0000-0000-0000-000000000001' ]
99 install-name
: '/usr/lib/libNested2.dylib'
102 re-exports
: [ '/usr/lib/libNested3.dylib' ]
105 uuids
: [ 'x86_64: 00000000-0000-0000-0000-000000000002' ]
107 install-name
: '/usr/lib/libNested3.dylib'
110 symbols
: [ _deeply_nested
]
113 #--- libReexportNested.tbd
115 archs
: [ i386
, x86_64
]
116 uuids
: [ 'i386: 00000000-0000-0000-0000-000000000000', 'x86_64: 00000000-0000-0000-0000-000000000001' ]
118 install-name
: '/usr/lib/libReexportNested.dylib'
120 - archs
: [ i386
, x86_64
]
121 re-exports
: [ 'libNested.dylib' ]
127 targets
: [ x86_64-macos
]
129 - target
: x86_64-macos
130 value
: 00000000-0000-0000-0000-000000000000
131 install-name
: '/usr/lib/libTlvWeak.dylib'
132 current-version
: 0001.001.1
133 exports
: # Validate weak & thread-local symbols
134 - targets
: [ x86_64-macos
]
135 weak-symbols
: [ _weak
]
136 thread-local-symbols
: [ _tlv
]