138 lines · plain
1# REQUIRES: x862 3# RUN: split-file %s %t --no-leading-lines4 5# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %t/test.s -o %t/test.o6 7# RUN: %lld -o %t/test -lSystem -lc++ -framework CoreFoundation %t/libNested.tbd %t/libTlvWeak.tbd %t/test.o8# RUN: llvm-objdump --bind --weak-bind --no-show-raw-insn -d -r %t/test | FileCheck %s9 10## Targeting an arch not listed in the tbd should fallback to an ABI compatible arch11# RUN: %lld -arch x86_64h -o %t/test-compat -lSystem -lc++ -framework CoreFoundation %t/libNested.tbd %t/libTlvWeak.tbd %t/test.o12# RUN: llvm-objdump --bind --weak-bind --no-show-raw-insn -d -r %t/test-compat | FileCheck %s13 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=INCOMPATIBLE17 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-level23## tapi document, re-exported by a top-level tapi document, which itself is24## 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.o26# RUN: llvm-objdump --bind --weak-bind --no-show-raw-insn -d -r %t/with-reexport | FileCheck %s27 28# CHECK: Bind table:29# CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_CLASS_$_NSObject30# CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_METACLASS_$_NSObject31# CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_IVAR_$_NSConstantArray._count32# CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_EHTYPE_$_NSException33# CHECK-DAG: __DATA __data {{.*}} pointer 0 libc++abi ___gxx_personality_v034# CHECK-DAG: __DATA __data {{.*}} pointer 0 libNested3 _deeply_nested35# CHECK-DAG: __DATA __data {{.*}} pointer 0 libTlvWeak _weak36# CHECK-DAG: __DATA __thread_ptrs {{.*}} pointer 0 libTlvWeak _tlv37 38# CHECK: Weak bind table:39# CHECK-DAG: __DATA __data {{.*}} pointer 0 _weak40 41# RUN: llvm-otool -l %t/test | FileCheck --check-prefix=LOAD %s42 43# RUN: llvm-otool -l %t/with-reexport | \44# RUN: FileCheck --check-prefixes=LOAD,LOAD-REEXPORT %s45 46# LOAD: cmd LC_LOAD_DYLIB47# LOAD-NEXT: cmdsize48# LOAD-NEXT: name /usr/lib/libSystem.dylib49# LOAD-NEXT: time stamp50# LOAD-NEXT: current version 1.1.151# LOAD-NEXT: compatibility version52 53# LOAD-REEXPORT: cmd LC_LOAD_DYLIB54# LOAD-REEXPORT-NEXT: cmdsize55# LOAD-REEXPORT-NEXT: name /usr/lib/libReexportNested.dylib56# LOAD-REEXPORT-NEXT: time stamp57# LOAD-REEXPORT-NEXT: current version 1.0.058# LOAD-REEXPORT-NEXT: compatibility version59 60#--- test.s61.section __TEXT,__text62.global _main63 64_main:65 mov _tlv@TLVP(%rip), %rax66 ret67 68.data69 .quad _OBJC_CLASS_$_NSObject70 .quad _OBJC_METACLASS_$_NSObject71 .quad _OBJC_IVAR_$_NSConstantArray._count72 .quad _OBJC_EHTYPE_$_NSException73## This symbol is defined in an inner TAPI document within libNested.tbd.74 .quad _deeply_nested75 76## This symbol is defined in libc++abi.tbd, but we are linking test.o against77## libc++.tbd (which re-exports libc++abi). Linking against this symbol verifies78## that .tbd file re-exports can refer not just to TAPI documents within the79## same .tbd file, but to other on-disk files as well.80 .quad ___gxx_personality_v081 82 .quad _weak83 84## This tests that we can locate a symbol re-exported by a child of a TAPI85## document.86#--- libNested.tbd87--- !tapi-tbd-v388archs: [ x86_64 ]89uuids: [ 'x86_64: 00000000-0000-0000-0000-000000000000' ]90platform: macosx91install-name: '/usr/lib/libNested.dylib'92exports:93 - archs: [ x86_64 ]94 re-exports: [ '/usr/lib/libNested2.dylib' ]95--- !tapi-tbd-v396archs: [ x86_64 ]97uuids: [ 'x86_64: 00000000-0000-0000-0000-000000000001' ]98platform: macosx99install-name: '/usr/lib/libNested2.dylib'100exports:101 - archs: [ x86_64 ]102 re-exports: [ '/usr/lib/libNested3.dylib' ]103--- !tapi-tbd-v3104archs: [ x86_64 ]105uuids: [ 'x86_64: 00000000-0000-0000-0000-000000000002' ]106platform: macosx107install-name: '/usr/lib/libNested3.dylib'108exports:109 - archs: [ x86_64 ]110 symbols: [ _deeply_nested ]111...112 113#--- libReexportNested.tbd114--- !tapi-tbd-v3115archs: [ i386, x86_64 ]116uuids: [ 'i386: 00000000-0000-0000-0000-000000000000', 'x86_64: 00000000-0000-0000-0000-000000000001' ]117platform: macosx118install-name: '/usr/lib/libReexportNested.dylib'119exports:120 - archs: [ i386, x86_64 ]121 re-exports: [ 'libNested.dylib' ]122...123 124#--- libTlvWeak.tbd125--- !tapi-tbd126tbd-version: 4127targets: [ x86_64-macos ]128uuids:129 - target: x86_64-macos130 value: 00000000-0000-0000-0000-000000000000131install-name: '/usr/lib/libTlvWeak.dylib'132current-version: 0001.001.1133exports: # Validate weak & thread-local symbols 134 - targets: [ x86_64-macos ]135 weak-symbols: [ _weak ]136 thread-local-symbols: [ _tlv ]137...138