llvm-project
112 строк · 7.2 Кб
1# REQUIRES: x86, aarch64
2
3# RUN: rm -rf %t; split-file %s %t
4
5# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o %t/main-arm64-macos.o %t/main.s
6# RUN: llvm-mc -filetype=obj -triple=arm64-apple-iossimulator -o %t/main-arm64-sim.o %t/main.s
7# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main-x86_64-macos.o %t/main.s
8# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o %t/foo-arm64-macos.o %t/foo.s
9# RUN: llvm-mc -filetype=obj -triple=arm64-apple-iossimulator -o %t/foo-arm64-sim.o %t/foo.s
10# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/foo-x86_64-macos.o %t/foo.s
11
12# Exhaustive test for:
13# (x86_64-macos, arm64-macos, arm64-ios-simulator) x (default, -adhoc_codesign, -no_adhoc-codesign) x (execute, dylib, bundle)
14
15# RUN: %lld -lSystem -arch x86_64 -execute -o %t/out %t/main-x86_64-macos.o
16# RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=NO-ADHOC %s
17# RUN: %lld -arch x86_64 -dylib -o %t/out %t/foo-x86_64-macos.o
18# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
19# RUN: %lld -arch x86_64 -bundle -o %t/out %t/foo-x86_64-macos.o
20# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
21
22# RUN: %lld -lSystem -arch x86_64 -execute -adhoc_codesign -o %t/out %t/main-x86_64-macos.o
23# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
24# RUN: %lld -arch x86_64 -dylib -adhoc_codesign -o %t/out %t/foo-x86_64-macos.o
25# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
26# RUN: %lld -arch x86_64 -bundle -adhoc_codesign -o %t/out %t/foo-x86_64-macos.o
27# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
28
29# RUN: %lld -lSystem -arch x86_64 -execute -no_adhoc_codesign -o %t/out %t/main-x86_64-macos.o
30# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
31# RUN: %lld -arch x86_64 -dylib -no_adhoc_codesign -o %t/out %t/foo-x86_64-macos.o
32# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
33# RUN: %lld -arch x86_64 -bundle -no_adhoc_codesign -o %t/out %t/foo-x86_64-macos.o
34# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
35
36
37# RUN: %lld -lSystem -arch arm64 -execute -o %t/out %t/main-arm64-macos.o
38# RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=ADHOC %s
39# RUN: %lld -arch arm64 -dylib -o %t/out %t/foo-arm64-macos.o
40# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
41# RUN: %lld -arch arm64 -bundle -o %t/out %t/foo-arm64-macos.o
42# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
43
44# RUN: %lld -lSystem -arch arm64 -execute -adhoc_codesign -o %t/out %t/main-arm64-macos.o
45# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
46# RUN: %lld -arch arm64 -dylib -adhoc_codesign -o %t/out %t/foo-arm64-macos.o
47# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
48# RUN: %lld -arch arm64 -bundle -adhoc_codesign -o %t/out %t/foo-arm64-macos.o
49# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
50
51# RUN: %lld -lSystem -arch arm64 -execute -no_adhoc_codesign -o %t/out %t/main-arm64-macos.o
52# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
53# RUN: %lld -arch arm64 -dylib -no_adhoc_codesign -o %t/out %t/foo-arm64-macos.o
54# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
55# RUN: %lld -arch arm64 -bundle -no_adhoc_codesign -o %t/out %t/foo-arm64-macos.o
56# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
57
58
59# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk -lSystem
60# RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=ADHOC %s
61# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib -o %t/out %t/foo-arm64-sim.o
62# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
63# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle -o %t/out %t/foo-arm64-sim.o
64# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
65
66# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -adhoc_codesign -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk -lSystem
67# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
68# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib -adhoc_codesign -o %t/out %t/foo-arm64-sim.o
69# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
70# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle -adhoc_codesign -o %t/out %t/foo-arm64-sim.o
71# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
72
73# RUN: %no-arg-lld -lSystem -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -no_adhoc_codesign -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk
74# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
75# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib -no_adhoc_codesign -o %t/out %t/foo-arm64-sim.o
76# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
77# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle -no_adhoc_codesign -o %t/out %t/foo-arm64-sim.o
78# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
79
80# RUN: %lld -arch x86_64 -dylib -o %t/out_installname.dylib -install_name @rpath/MyInstallName %t/foo-x86_64-macos.o -adhoc_codesign
81# RUN: %lld -arch x86_64 -dylib -o %t/out_no_installname.dylib %t/foo-x86_64-macos.o -adhoc_codesign
82
83## Smoke check to verify the dataoff and datasize value before using them with code-signature-check.py
84# RUN: llvm-objdump --macho --all-headers %t/out_installname.dylib | FileCheck %s --check-prefix CS-ID-PRE -D#DATA_OFFSET=4176 -D#DATA_SIZE=192
85# RUN: llvm-objdump --macho --all-headers %t/out_no_installname.dylib | FileCheck %s --check-prefix CS-ID-PRE -D#DATA_OFFSET=4176 -D#DATA_SIZE=208
86
87## Verify that the 'Identifier' (aka 'Code Directory ID') field are set to the install-name, if available.
88# RUN: %python %p/Inputs/code-signature-check.py %t/out_installname.dylib 4176 192 0 4176 | FileCheck %s --check-prefix CS-ID-INSTALL
89# RUN: %python %p/Inputs/code-signature-check.py %t/out_no_installname.dylib 4176 208 0 4176 | FileCheck %s --check-prefix CS-ID-NO-INSTALL
90
91# ADHOC: cmd LC_CODE_SIGNATURE
92# ADHOC-NEXT: cmdsize 16
93
94# NO-ADHOC-NOT: cmd LC_CODE_SIGNATURE
95
96# CS-ID-PRE: cmd LC_CODE_SIGNATURE
97# CS-ID-PRE-NEXT: cmdsize 16
98# CS-ID-PRE-NEXT: dataoff [[#DATA_OFFSET]]
99# CS-ID-PRE-NEXT: datasize [[#DATA_SIZE]]
100
101# CS-ID-INSTALL: Code Directory ID: MyInstallName
102# CS-ID-NO-INSTALL: Code Directory ID: out_no_installname.dylib
103
104#--- foo.s
105.globl _foo
106_foo:
107ret
108
109#--- main.s
110.globl _main
111_main:
112ret
113