1# REQUIRES: x86
2# RUN: 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-swift.s -o %t/has-swift.o
7# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/no-objc.s -o %t/no-objc.o
8
9# RUN: rm -f %t/libHasSomeObjC.a
10# RUN: llvm-ar rcs %t/libHasSomeObjC.a %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/no-objc.o
11
12# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
13# RUN: %lld -lSystem %t/test.o -o %t/test \
14# RUN:   -L%t -lHasSomeObjC -ObjC
15# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=OBJC
16
17# OBJC:       Sections:
18# OBJC-NEXT:  Idx Name           Size   VMA  Type
19# OBJC-NEXT:    0 __text         {{.*}}      TEXT
20# OBJC-NEXT:    1 __swift        {{.*}}      DATA
21# OBJC-NEXT:    2 __objc_catlist {{.*}}      DATA
22# OBJC-EMPTY:
23# OBJC-NEXT:  SYMBOL TABLE:
24# OBJC-NEXT:  g     F __TEXT,__text _main
25# OBJC-NEXT:  g     F __TEXT,__text _OBJC_CLASS_$_MyObject
26
27# RUN: %lld -lSystem %t/test.o -o %t/test \
28# RUN:   -L%t -lHasSomeObjC
29# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=NO-OBJC
30
31# NO-OBJC:       Sections:
32# NO-OBJC-NEXT:  Idx Name           Size   VMA  Type
33# NO-OBJC-NEXT:    0 __text         {{.*}}      TEXT
34# NO-OBJC-EMPTY:
35# NO-OBJC-NEXT:  SYMBOL TABLE:
36# NO-OBJC-NEXT:  g     F __TEXT,__text _main
37# NO-OBJC-EMPTY:
38
39#--- has-objc-symbol.s
40.globl _OBJC_CLASS_$_MyObject
41_OBJC_CLASS_$_MyObject:
42
43#--- has-objc-category.s
44.section	__DATA,__objc_catlist
45.quad 0x1234
46
47#--- has-swift.s
48.section	__TEXT,__swift
49.quad 0x1234
50
51#--- no-objc.s
52## This archive member should not be pulled in since it does not contain any
53## ObjC-related data.
54.globl _foo
55.section __DATA,foo
56
57foo:
58  .quad 0x1234
59
60#--- test.s
61.globl _main
62_main:
63  ret
64