llvm-project

Форк
0
145 строк · 5.8 Кб
1
# REQUIRES: x86, arm
2
# RUN: rm -rf %t; split-file %s %t
3

4
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-objc-symbol.s -o %t/has-objc-symbol.o
5
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-objc-category.s -o %t/has-objc-category.o
6
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-objc-symbol-and-category.s -o %t/has-objc-symbol-and-category.o
7
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-swift.s -o %t/has-swift.o
8
# RUN: llvm-as %t/has-swift-ir-loaded.ll -o %t/has-swift-ir-loaded.o
9
# RUN: llvm-as %t/has-swift-ir-not-loaded.ll -o %t/has-swift-ir-not-loaded.o
10
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-swift-proto.s -o %t/has-swift-proto.o
11
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/no-objc.s -o %t/no-objc.o
12
## Make sure we don't mis-parse a 32-bit file as 64-bit
13
# RUN: llvm-mc -filetype=obj -triple=armv7-apple-watchos %t/no-objc.s -o %t/wrong-arch.o
14
# RUN: llvm-ar rcs %t/libHasSomeObjC.a %t/no-objc.o %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/has-swift-proto.o %t/has-swift-ir-loaded.o %t/has-swift-ir-not-loaded.o %t/wrong-arch.o
15
# RUN: llvm-ar rcs %t/libHasSomeObjC2.a %t/no-objc.o %t/has-objc-symbol-and-category.o %t/has-swift.o %t/has-swift-proto.o %t/has-swift-ir-loaded.o %t/has-swift-ir-not-loaded.o %t/wrong-arch.o
16

17
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
18

19
# RUN: %lld -lSystem %t/test.o -o %t/test -L%t -lHasSomeObjC -ObjC 
20
# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=OBJC
21

22
# RUN: %lld -lSystem %t/test.o -o %t/test -L%t -lHasSomeObjC2 -ObjC
23
# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=OBJC
24

25
# RUN: %no-fatal-warnings-lld -lSystem %t/test.o -o %t/test --start-lib %t/no-objc.o %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/has-swift-proto.o %t/has-swift-ir-loaded.o %t/has-swift-ir-not-loaded.o %t/wrong-arch.o --end-lib -ObjC 2>&1 \
26
# RUN:     | FileCheck -check-prefix=WARNING %s
27
# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=OBJC
28

29
# WARNING: {{.+}}wrong-arch.o has architecture armv7 which is incompatible with target architecture x86_64
30
# WARNING-NOT: {{.}}
31

32
# OBJC:       Sections:
33
# OBJC-NEXT:  Idx Name            Size   VMA  Type
34
# OBJC-NEXT:    0 __text          {{.*}}      TEXT
35
# OBJC-NEXT:    1 __swift         {{.*}}      DATA
36
# OBJC-NEXT:    2 __swift5_fieldmd{{.*}}      DATA
37
# OBJC-NEXT:    3 __objc_catlist  {{.*}}      DATA
38
# OBJC-NEXT:    4 has_objc_symbol {{.*}}      DATA
39
# OBJC-EMPTY:
40
# OBJC-NEXT:  SYMBOL TABLE:
41
# OBJC-DAG:   g     O __TEXT,__swift _foo
42
# OBJC-DAG:   g     F __TEXT,__text _main
43
# OBJC-DAG:   g     F __TEXT,__text _OBJC_CLASS_$_MyObject
44
# OBJC-DAG:   g     O __TEXT,__swift5_fieldmd $s7somelib4Blah_pMF
45

46
# RUN: %lld -lSystem %t/test.o -o %t/test -L%t -lHasSomeObjC
47
# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=NO-OBJC
48

49
# NO-OBJC:       Sections:
50
# NO-OBJC-NEXT:  Idx Name           Size   VMA  Type
51
# NO-OBJC-NEXT:    0 __text         {{.*}}      TEXT
52
# NO-OBJC-EMPTY:
53
# NO-OBJC-NEXT:  SYMBOL TABLE:
54
# NO-OBJC-NEXT:  g     F __TEXT,__text _main
55
# NO-OBJC-NEXT:  g     F __TEXT,__text __mh_execute_header
56
# NO-OBJC-NEXT:          *UND* dyld_stub_binder
57
# NO-OBJC-EMPTY:
58

59
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/refs-dup.s -o %t/refs-dup.o
60
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/refs-objc.s -o %t/refs-objc.o
61

62
## Check that -ObjC causes has-objc-symbol.o to be loaded first, prior to symbol
63
## resolution. This matches ld64's behavior.
64
# RUN: %lld -dylib %t/refs-dup.o %t/refs-objc.o -o %t/refs-dup -L%t -lHasSomeObjC -ObjC
65
# RUN: llvm-objdump --macho --syms %t/refs-dup | FileCheck %s --check-prefix=DUP-FROM-OBJC
66
# DUP-FROM-OBJC: g     O __DATA,has_objc_symbol _has_dup
67

68
## Without -ObjC, no-objc.o gets loaded first during symbol resolution, causing
69
## a duplicate symbol error.
70
# RUN: not %lld -dylib %t/refs-dup.o %t/refs-objc.o -o %t/refs-dup -L%t \
71
# RUN:   -lHasSomeObjC 2>&1 | FileCheck %s --check-prefix=DUP-ERROR
72
# DUP-ERROR: error: duplicate symbol: _has_dup
73

74
## TODO: Load has-objc-symbol.o prior to symbol resolution to match the archive behavior.
75
# RUN: not %lld -dylib %t/refs-dup.o %t/refs-objc.o -o %t/refs-dup --start-lib %t/no-objc.o \
76
# RUN:   %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/wrong-arch.o --end-lib \
77
# RUN:   -ObjC 2>&1 | FileCheck %s --check-prefix=DUP-ERROR
78

79
#--- has-objc-symbol.s
80
.globl _OBJC_CLASS_$_MyObject, _has_dup
81
_OBJC_CLASS_$_MyObject:
82

83
.section __DATA,has_objc_symbol
84
_has_dup:
85

86
#--- has-objc-category.s
87
.section __DATA,__objc_catlist
88
.quad 0x1234
89

90
#--- has-objc-symbol-and-category.s
91
## Make sure we load this archive member exactly once (i.e. no duplicate symbol
92
## error).
93
.globl _OBJC_CLASS_$_MyObject, _has_dup
94
_OBJC_CLASS_$_MyObject:
95

96
.section __DATA,has_objc_symbol
97
_has_dup:
98

99
.section __DATA,__objc_catlist
100
.quad 0x1234
101

102
#--- has-swift.s
103
.section __TEXT,__swift
104
.quad 0x1234
105

106
#--- has-swift-ir-loaded.ll
107
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
108
target triple = "x86_64-apple-darwin"
109

110
@foo = global i64 1234, section "__TEXT,__swift"
111
@llvm.used = appending global [1 x ptr] [ptr @foo]
112

113
#--- has-swift-ir-not-loaded.ll
114
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
115
target triple = "x86_64-apple-darwin"
116

117
@bar = global i64 1234
118
@llvm.used = appending global [1 x ptr] [ptr @bar]
119

120
#--- has-swift-proto.s
121
.section __TEXT,__swift5_fieldmd
122
.globl $s7somelib4Blah_pMF
123
$s7somelib4Blah_pMF:
124

125
#--- no-objc.s
126
## This archive member should not be pulled in by -ObjC since it does not
127
## contain any ObjC-related data.
128
.globl _has_dup
129
.section __DATA,foo
130
.section __DATA,bar
131
.section __DATA,no_objc
132
_has_dup:
133

134
#--- test.s
135
.globl _main
136
_main:
137
  ret
138

139
#--- refs-dup.s
140
.data
141
.quad _has_dup
142

143
#--- refs-objc.s
144
.data
145
.quad _OBJC_CLASS_$_MyObject
146

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.