Debian Codegraph @

compiler-rt/test/orc/TestCases/Darwin/x86-64/objc-imageinfo.S

raw
1 // Test merging of __objc_imageinfo flags and ensure we can run mixed objc and
2 // swift code in a single jit dylib.
3
4 // REQUIRES: system-darwin && asserts
5
6 // RUN: rm -rf %t
7 // RUN: split-file %s %t
8 // RUN: pushd %t
9 // RUN: %clang -c *.S
10 // RUN: popd
11
12 // Check individual versions are loadable.
13
14 // RUN: %llvm_jitlink -num-threads=0 -debug-only=orc %t/main.o \
15 // RUN: %t/objc_old.o 2>&1 \
16 // RUN: | FileCheck %s -check-prefix=OLD
17 // OLD: MachOPlatform: Registered __objc_imageinfo for main
18 // OLD-SAME: flags = 0x0000
19 // RUN: %llvm_jitlink -num-threads=0 -debug-only=orc %t/main.o \
20 // RUN: %t/objc_new.o 2>&1 \
21 // RUN: | FileCheck %s -check-prefix=NEW
22 // NEW: MachOPlatform: Registered __objc_imageinfo for main
23 // NEW-SAME: flags = 0x0040
24 // RUN: %llvm_jitlink -num-threads=0 -debug-only=orc %t/main.o \
25 // RUN: %t/swift_4.o 2>&1 \
26 // RUN: | FileCheck %s -check-prefix=SWIFT_4
27 // SWIFT_4: MachOPlatform: Registered __objc_imageinfo for main
28 // SWIFT_4-SAME: flags = 0x0640
29 // RUN: %llvm_jitlink -num-threads=0 -debug-only=orc %t/main.o \
30 // RUN: %t/swift_5.o 2>&1 \
31 // RUN: | FileCheck %s -check-prefix=SWIFT_5
32 // SWIFT_5: MachOPlatform: Registered __objc_imageinfo for main
33 // SWIFT_5-SAME: flags = 0x5000740
34 // RUN: %llvm_jitlink -num-threads=0 -debug-only=orc %t/main.o \
35 // RUN: %t/swift_59.o 2>&1 \
36 // RUN: | FileCheck %s -check-prefix=SWIFT_59
37 // SWIFT_59: MachOPlatform: Registered __objc_imageinfo for main
38 // SWIFT_59-SAME: flags = 0x5090740
39
40 // Check error conditions.
41
42 // RUN: not %llvm_jitlink %t/main.o %t/swift_4.o %t/swift_5.o 2>&1 | FileCheck %s -check-prefix=SWIFT_ABI
43 // SWIFT_ABI: Swift ABI version in {{.*}} does not match first registered flags
44
45 // Check merging.
46
47 // Take the lowest swift version.
48 // RUN: %llvm_jitlink -num-threads=0 -debug-only=orc %t/main.o %t/swift_59.o \
49 // RUN: %t/swift_5.o 2>&1 \
50 // RUN: | FileCheck %s -check-prefix=SWIFT_MIX1
51 // SWIFT_MIX1: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x5000740
52
53 // Add swift to objc.
54 // RUN: %llvm_jitlink -num-threads=0 -debug-only=orc %t/main.o %t/swift_59.o \
55 // RUN: %t/objc_new.o 2>&1 \
56 // RUN: | FileCheck %s -check-prefix=SWIFT_MIX2
57 // SWIFT_MIX2: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x5090740
58
59 // Add multiple swift to objc.
60 // RUN: %llvm_jitlink -num-threads=0 -debug-only=orc %t/main.o %t/swift_59.o \
61 // RUN: %t/swift_5.o %t/objc_new.o 2>&1 \
62 // RUN: | FileCheck %s -check-prefix=SWIFT_MIX3
63 // SWIFT_MIX3: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x5000740
64
65 // Disable categories.
66 // RUN: %llvm_jitlink -num-threads=0 -debug-only=orc %t/main.o %t/objc_old.o \
67 // RUN: %t/objc_new.o 2>&1 \
68 // RUN: | FileCheck %s -check-prefix=SWIFT_MIX4
69 // SWIFT_MIX4: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x0000
70
71 // Disable signed class_ro.
72 // RUN: %llvm_jitlink -num-threads=0 -debug-only=orc %t/main.o %t/objc_new.o \
73 // RUN: %t/objc_new_signed_ro.o 2>&1 \
74 // RUN: | FileCheck %s -check-prefix=SWIFT_MIX5
75 // SWIFT_MIX5: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x0040
76
77 //--- main.S
78 .section __TEXT,__text,regular,pure_instructions
79 .globl _main
80 _main:
81 xorl %eax, %eax
82 ret
83
84 //--- objc_old.S
85 .section __TEXT,__text,regular,pure_instructions
86 .globl _objc1
87 _objc1:
88 ret
89
90 .section __DATA,__objc_imageinfo,regular,no_dead_strip
91 L_OBJC_IMAGE_INFO:
92 .long 0
93 .long 0
94
95 //--- objc_new.S
96 .section __TEXT,__text,regular,pure_instructions
97 .globl _objc2
98 _objc2:
99 ret
100
101 .section __DATA,__objc_imageinfo,regular,no_dead_strip
102 L_OBJC_IMAGE_INFO:
103 .long 0
104 .long 64
105
106 //--- objc_new_signed_ro.S
107 .section __TEXT,__text,regular,pure_instructions
108 .globl _objc3
109 _objc3:
110 ret
111
112 .section __DATA,__objc_imageinfo,regular,no_dead_strip
113 L_OBJC_IMAGE_INFO:
114 .long 0
115 .long 80
116
117 //--- swift_4.S
118 .section __TEXT,__text,regular,pure_instructions
119 .globl _swift4
120 _swift4:
121 ret
122
123 .section __DATA,__objc_imageinfo,regular,no_dead_strip
124 L_OBJC_IMAGE_INFO:
125 .long 0
126 .long 1600
127
128 //--- swift_5.S
129 .section __TEXT,__text,regular,pure_instructions
130 .globl _swift5
131 _swift5:
132 ret
133
134 .section __DATA,__objc_imageinfo,regular,no_dead_strip
135 L_OBJC_IMAGE_INFO:
136 .long 0
137 .long 83887936
138
139 //--- swift_59.S
140 .section __TEXT,__text,regular,pure_instructions
141 .globl _swift59
142 _swift59:
143 ret
144
145 .section __DATA,__objc_imageinfo,regular,no_dead_strip
146 L_OBJC_IMAGE_INFO:
147 .long 0
148 .long 84477760
149