summaryrefslogtreecommitdiff
path: root/lld/test/MachO/allowable-client.s
blob: e87e3fabb262ca18fbea1d1db917461d94ee668c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# REQUIRES: x86
# RUN: rm -rf %t; split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
# RUN: touch %t/empty.s; llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/empty.s -o %t/empty.o

# Check that `-allowable_client` generates LC_SUB_CLIENT.
# We create our .dylib in a `lib` subdirectory to make sure we test linking against the `.dylib` instead of the `.tbd` below.
# RUN: mkdir -p %t/lib; %lld -dylib -o %t/lib/liballowable_client.dylib %t/empty.o -allowable_client allowed -allowable_client also_allowed
# RUN: llvm-objdump --macho --all-headers %t/lib/liballowable_client.dylib | FileCheck %s
# CHECK:      LC_SUB_CLIENT
# CHECK-NEXT: cmdsize 24
# CHECK-NEXT: client allowed
# CHECK:      LC_SUB_CLIENT
# CHECK-NEXT: cmdsize 32
# CHECK-NEXT: client also_allowed

# Check linking against the .dylib we created above
# RUN: not %lld -o %t/test %t/test.o -L%t/lib -lallowable_client 2>&1 | FileCheck %s --check-prefix=NOTALLOWED-IMPLICIT
# RUN: not %lld -o %t/libtest_debug.exe %t/test.o -L%t/lib -lallowable_client 2>&1 | FileCheck %s --check-prefix=NOTALLOWED-IMPLICIT
# RUN: not %lld -o %t/test %t/test.o -L%t/lib -lallowable_client -client_name notallowed 2>&1 | FileCheck %s --check-prefix=NOTALLOWED-EXPLICIT
# RUN: %lld -o %t/test %t/test.o -L%t/lib -lallowable_client -client_name allowed
# RUN: %lld -o %t/test %t/test.o -L%t/lib -lallowable_client -client_name all
# RUN: %lld -o %t/all %t/test.o -L%t/lib -lallowable_client
# RUN: %lld -o %t/allowed %t/test.o -L%t/lib -lallowable_client
# RUN: %lld -o %t/liballowed_debug.exe %t/test.o -L%t/lib -lallowable_client

# Check linking against a .tbd
# RUN: not %lld -o %t/test %t/test.o -L%t -lallowable_client 2>&1 | FileCheck %s --check-prefix=NOTALLOWED-IMPLICIT
# RUN: not %lld -o %t/libtest_debug.exe %t/test.o -L%t -lallowable_client 2>&1 | FileCheck %s --check-prefix=NOTALLOWED-IMPLICIT
# RUN: not %lld -o %t/test %t/test.o -L%t -lallowable_client -client_name notallowed 2>&1 | FileCheck %s --check-prefix=NOTALLOWED-EXPLICIT
# RUN: %lld -o %t/test %t/test.o -L%t -lallowable_client -client_name allowed
# RUN: %lld -o %t/test %t/test.o -L%t -lallowable_client -client_name all
# RUN: %lld -o %t/all %t/test.o -L%t -lallowable_client
# RUN: %lld -o %t/allowed %t/test.o -L%t -lallowable_client
# RUN: %lld -o %t/liballowed_debug.exe %t/test.o -L%t -lallowable_client

# NOTALLOWED-IMPLICIT: error: cannot link directly with 'liballowable_client.dylib' because test is not an allowed client
# NOTALLOWED-EXPLICIT: error: cannot link directly with 'liballowable_client.dylib' because notallowed is not an allowed client

#--- test.s
.text
.globl _main
_main:
  ret

#--- liballowable_client.tbd
{
  "main_library": {
    "allowable_clients": [
      {
        "clients": [
          "allowed"
        ]
      }
    ],
    "compatibility_versions": [
      {
        "version": "0"
      }
    ],
    "current_versions": [
      {
        "version": "0"
      }
    ],
    "flags": [
      {
        "attributes": [
          "not_app_extension_safe"
        ]
      }
    ],
    "install_names": [
      {
        "name": "lib/liballowable_client.dylib"
      }
    ],
    "target_info": [
      {
        "min_deployment": "10.11",
        "target": "x86_64-macos"
      }
    ]
  },
  "tapi_tbd_version": 5
}