llvm-project
73 строки · 2.4 Кб
1; REQUIRES: x86
2; RUN: rm -rf %t; split-file %s %t
3; RUN: llvm-as %t/foo.ll -o %t/foo.o
4; RUN: llvm-as %t/has-objc-symbol.ll -o %t/has-objc-symbol.o
5; RUN: llvm-as %t/has-objc-category.ll -o %t/has-objc-category.o
6; RUN: llvm-ar rcs %t/foo.a %t/foo.o
7; RUN: llvm-ar rcs %t/objc.a %t/has-objc-symbol.o %t/has-objc-category.o
8
9; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o
10; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/references-foo.s -o %t/references-foo.o
11
12; RUN: %lld -lSystem %t/references-foo.o %t/foo.a -o /dev/null -why_load | FileCheck %s --check-prefix=FOO
13; FOO: _foo forced load of {{.+}}foo.a(foo.o)
14
15; RUN: %lld -lSystem -force_load %t/foo.a %t/main.o -o /dev/null -why_load | FileCheck %s --check-prefix=FORCE-LOAD
16; FORCE-LOAD: -force_load forced load of {{.+}}foo.a(foo.o)
17
18; RUN: %lld -lSystem -ObjC -framework CoreFoundation %t/objc.a %t/main.o \
19; RUN: -o /dev/null -why_load | FileCheck %s --check-prefix=OBJC
20; OBJC: _OBJC_CLASS_$_Foo forced load of {{.+}}objc.a(has-objc-symbol.o)
21; OBJC: -ObjC forced load of {{.+}}objc.a(has-objc-category.o)
22
23; RUN: %lld -lSystem %t/foo.a %t/main.o -o %t/no-force-load -why_load | count 0
24
25; RUN: %lld -lSystem -framework CoreFoundation %t/objc.a %t/main.o -o %t/no-objc -why_load | count 0
26
27;--- foo.ll
28
29target triple = "x86_64-apple-macosx10.15.0"
30target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
31
32define void @foo() {
33ret void
34}
35
36;--- has-objc-symbol.ll
37
38target triple = "x86_64-apple-macosx10.15.0"
39target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
40
41%struct._class_t = type { i8 }
42@"OBJC_CLASS_$_Foo" = global %struct._class_t { i8 123 }
43
44;--- has-objc-category.ll
45
46target triple = "x86_64-apple-macosx10.15.0"
47target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
48
49%struct._category_t = type { i8 }
50
51@"_OBJC_$_CATEGORY_Foo_$_Bar" = internal global %struct._category_t { i8 123 },
52section "__DATA, __objc_const", align 8
53
54@"OBJC_LABEL_CATEGORY_$" = private global [1 x ptr] [
55ptr @"_OBJC_$_CATEGORY_Foo_$_Bar"
56], section "__DATA,__objc_catlist,regular,no_dead_strip", align 8
57
58@llvm.compiler.used = appending global [1 x ptr] [
59ptr @"OBJC_LABEL_CATEGORY_$"
60], section "llvm.metadata"
61
62;--- main.s
63
64.globl _main
65_main:
66ret
67
68;--- references-foo.s
69
70.globl _main
71_main:
72callq _foo
73ret
74