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 -debug-only=orc %t/main.o %t/objc_old.o 2>&1 | FileCheck %s -check-prefix=OLD
13// OLD: MachOPlatform: Registered __objc_imageinfo for main
14// OLD-SAME: flags = 0x0000
15// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/objc_new.o 2>&1 | FileCheck %s -check-prefix=NEW
16// NEW: MachOPlatform: Registered __objc_imageinfo for main
17// NEW-SAME: flags = 0x0040
18// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/swift_4.o 2>&1 | FileCheck %s -check-prefix=SWIFT_4
19// SWIFT_4: MachOPlatform: Registered __objc_imageinfo for main
20// SWIFT_4-SAME: flags = 0x0640
21// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/swift_5.o 2>&1 | FileCheck %s -check-prefix=SWIFT_5
22// SWIFT_5: MachOPlatform: Registered __objc_imageinfo for main
23// SWIFT_5-SAME: flags = 0x5000740
24// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/swift_59.o 2>&1 | FileCheck %s -check-prefix=SWIFT_59
25// SWIFT_59: MachOPlatform: Registered __objc_imageinfo for main
26// SWIFT_59-SAME: flags = 0x5090740
27
28// Check error conditions.
29
30// RUN: not %llvm_jitlink %t/main.o %t/objc_old.o %t/objc_new.o 2>&1 | FileCheck %s -check-prefix=CATEGORY
31// CATEGORY: ObjC category class property support in {{.*}} does not match first registered flags
32
33// RUN: not %llvm_jitlink %t/main.o %t/swift_4.o %t/swift_5.o 2>&1 | FileCheck %s -check-prefix=SWIFT_ABI
34// SWIFT_ABI: Swift ABI version in {{.*}} does not match first registered flags
35
36// Check merging.
37
38// Take the lowest swift version.
39// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/swift_59.o %t/swift_5.o 2>&1 | FileCheck %s -check-prefix=SWIFT_MIX1
40// SWIFT_MIX1: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x5000740
41
42// Add swift to objc.
43// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/swift_59.o %t/objc_new.o 2>&1 | FileCheck %s -check-prefix=SWIFT_MIX2
44// SWIFT_MIX2: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x5090740
45
46// Add multiple swift to objc.
47// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/swift_59.o %t/swift_5.o %t/objc_new.o 2>&1 | FileCheck %s -check-prefix=SWIFT_MIX3
48// SWIFT_MIX3: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x5000740
49
50//--- main.S
51.section __TEXT,__text,regular,pure_instructions
52.globl _main
53_main:
54 mov w0, #0
55 ret
56
57//--- objc_old.S
58.section __TEXT,__text,regular,pure_instructions
59.globl _objc1
60_objc1:
61 ret
62
63 .section __DATA,__objc_imageinfo,regular,no_dead_strip
64L_OBJC_IMAGE_INFO:
65 .long 0
66 .long 0
67
68//--- objc_new.S
69.section __TEXT,__text,regular,pure_instructions
70.globl _objc2
71_objc2:
72 ret
73
74 .section __DATA,__objc_imageinfo,regular,no_dead_strip
75L_OBJC_IMAGE_INFO:
76 .long 0
77 .long 64
78
79//--- swift_4.S
80.section __TEXT,__text,regular,pure_instructions
81.globl _swift4
82_swift4:
83 ret
84
85 .section __DATA,__objc_imageinfo,regular,no_dead_strip
86L_OBJC_IMAGE_INFO:
87 .long 0
88 .long 1600
89
90//--- swift_5.S
91.section __TEXT,__text,regular,pure_instructions
92.globl _swift5
93_swift5:
94 ret
95
96 .section __DATA,__objc_imageinfo,regular,no_dead_strip
97L_OBJC_IMAGE_INFO:
98 .long 0
99 .long 83887936
100
101//--- swift_59.S
102.section __TEXT,__text,regular,pure_instructions
103.globl _swift59
104_swift59:
105 ret
106
107 .section __DATA,__objc_imageinfo,regular,no_dead_strip
108L_OBJC_IMAGE_INFO:
109 .long 0
110 .long 84477760
111
112

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