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

source code of compiler-rt/test/orc/TestCases/Darwin/arm64/objc-imageinfo.S