llvm-project
137 строк · 5.5 Кб
1# REQUIRES: x86
2
3# RUN: split-file %s %t --no-leading-lines
4
5# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %t/test.s -o %t/test.o
6
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
9
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
13
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
17
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)
21
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
27
28# CHECK: Bind table:
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
37
38# CHECK: Weak bind table:
39# CHECK-DAG: __DATA __data {{.*}} pointer 0 _weak
40
41# RUN: llvm-otool -l %t/test | FileCheck --check-prefix=LOAD %s
42
43# RUN: llvm-otool -l %t/with-reexport | \
44# RUN: FileCheck --check-prefixes=LOAD,LOAD-REEXPORT %s
45
46# LOAD: cmd LC_LOAD_DYLIB
47# LOAD-NEXT: cmdsize
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
52
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
59
60#--- test.s
61.section __TEXT,__text
62.global _main
63
64_main:
65mov _tlv@TLVP(%rip), %rax
66ret
67
68.data
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.
74.quad _deeply_nested
75
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
81
82.quad _weak
83
84## This tests that we can locate a symbol re-exported by a child of a TAPI
85## document.
86#--- libNested.tbd
87--- !tapi-tbd-v3
88archs: [ x86_64 ]
89uuids: [ 'x86_64: 00000000-0000-0000-0000-000000000000' ]
90platform: macosx
91install-name: '/usr/lib/libNested.dylib'
92exports:
93- archs: [ x86_64 ]
94re-exports: [ '/usr/lib/libNested2.dylib' ]
95--- !tapi-tbd-v3
96archs: [ x86_64 ]
97uuids: [ 'x86_64: 00000000-0000-0000-0000-000000000001' ]
98platform: macosx
99install-name: '/usr/lib/libNested2.dylib'
100exports:
101- archs: [ x86_64 ]
102re-exports: [ '/usr/lib/libNested3.dylib' ]
103--- !tapi-tbd-v3
104archs: [ x86_64 ]
105uuids: [ 'x86_64: 00000000-0000-0000-0000-000000000002' ]
106platform: macosx
107install-name: '/usr/lib/libNested3.dylib'
108exports:
109- archs: [ x86_64 ]
110symbols: [ _deeply_nested ]
111...
112
113#--- libReexportNested.tbd
114--- !tapi-tbd-v3
115archs: [ i386, x86_64 ]
116uuids: [ 'i386: 00000000-0000-0000-0000-000000000000', 'x86_64: 00000000-0000-0000-0000-000000000001' ]
117platform: macosx
118install-name: '/usr/lib/libReexportNested.dylib'
119exports:
120- archs: [ i386, x86_64 ]
121re-exports: [ 'libNested.dylib' ]
122...
123
124#--- libTlvWeak.tbd
125--- !tapi-tbd
126tbd-version: 4
127targets: [ x86_64-macos ]
128uuids:
129- target: x86_64-macos
130value: 00000000-0000-0000-0000-000000000000
131install-name: '/usr/lib/libTlvWeak.dylib'
132current-version: 0001.001.1
133exports: # Validate weak & thread-local symbols
134- targets: [ x86_64-macos ]
135weak-symbols: [ _weak ]
136thread-local-symbols: [ _tlv ]
137...
138