170 lines · plain
1# REQUIRES: x862 3# RUN: rm -rf %t; split-file %s %t4 5## ld64 ignores the __objc_imageinfo section entirely if there is no actual6## ObjC class + category data in the file. LLD doesn't yet do this check, but7## to make this test work for both linkers, I am inserting an appropriate class8## definition into each test file.9# RUN: cat %t/no-category-cls.s %t/foo-cls.s > %t/no-category-cls-1.s10# RUN: cat %t/with-category-cls.s %t/foo-cls.s > %t/with-category-cls-1.s11# RUN: cat %t/ignored-flags.s %t/foo-cls.s > %t/ignored-flags-1.s12# RUN: cat %t/invalid-version.s %t/foo-cls.s > %t/invalid-version-1.s13# RUN: cat %t/invalid-size.s %t/foo-cls.s > %t/invalid-size-1.s14# RUN: cat %t/swift-version-1.s %t/foo-cls.s > %t/swift-version-1-1.s15# RUN: cat %t/swift-version-2.s %t/foo-cls.s > %t/swift-version-2-1.s16 17# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/no-category-cls-1.s -o %t/no-category-cls.o18# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/with-category-cls-1.s -o %t/with-category-cls.o19# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/ignored-flags-1.s -o %t/ignored-flags.o20# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/invalid-version-1.s -o %t/invalid-version.o21# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/swift-version-1-1.s -o %t/swift-version-1.o22# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/swift-version-2-1.s -o %t/swift-version-2.o23# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/invalid-size-1.s -o %t/invalid-size.o24 25# RUN: %lld -dylib -lSystem %t/with-category-cls.o -o %t/test-with-cat26# RUN: llvm-objdump --macho --section="__DATA_CONST,__objc_imageinfo" --syms \27# RUN: %t/test-with-cat | FileCheck %s --check-prefix=HAS-CAT-CLS \28# RUN: --implicit-check-not=_discard_me29 30# RUN: %lld -dylib -lSystem %t/no-category-cls.o -o %t/test-no-cat31# RUN: llvm-objdump --macho --section="__DATA_CONST,__objc_imageinfo" --syms \32# RUN: %t/test-no-cat | FileCheck %s --check-prefix=NO-CAT-CLS \33# RUN: --implicit-check-not=_discard_me34 35# RUN: %lld -dylib -lSystem %t/no-category-cls.o %t/with-category-cls.o -o %t/test136# RUN: llvm-objdump --macho --section="__DATA_CONST,__objc_imageinfo" %t/test1 \37# RUN: | FileCheck %s --check-prefix=NO-CAT-CLS38 39# RUN: %lld -dylib -lSystem %t/with-category-cls.o %t/ignored-flags.o -o %t/test240# RUN: llvm-objdump --macho --section="__DATA_CONST,__objc_imageinfo" %t/test2 \41# RUN: | FileCheck %s --check-prefix=HAS-CAT-CLS42 43# RUN: %lld -dylib -lSystem %t/no-category-cls.o %t/ignored-flags.o -o %t/test344# RUN: llvm-objdump --macho --section="__DATA_CONST,__objc_imageinfo" %t/test3 \45# RUN: | FileCheck %s --check-prefix=NO-CAT-CLS46 47# RUN: %no-fatal-warnings-lld -dylib -lSystem %t/with-category-cls.o \48# RUN: %t/invalid-version.o -o %t/test4 2>&1 | FileCheck %s \49# RUN: --check-prefix=IMAGE-VERSION50# RUN: llvm-objdump --macho --section="__DATA_CONST,__objc_imageinfo" %t/test4 \51# RUN: | FileCheck %s --check-prefix=NO-CAT-CLS52 53# RUN: %no-fatal-warnings-lld -dylib -lSystem %t/no-category-cls.o \54# RUN: %t/invalid-version.o -o %t/test5 2>&1 | FileCheck %s \55# RUN: --check-prefix=IMAGE-VERSION56# RUN: llvm-objdump --macho --section="__DATA_CONST,__objc_imageinfo" %t/test5 \57# RUN: | FileCheck %s --check-prefix=NO-CAT-CLS58 59# RUN: %no-fatal-warnings-lld -dylib -lSystem %t/with-category-cls.o \60# RUN: %t/invalid-size.o -o %t/test6 2>&1 | FileCheck %s \61# RUN: --check-prefix=INVALID-SIZE62# RUN: llvm-objdump --macho --section="__DATA_CONST,__objc_imageinfo" %t/test6 \63# RUN: | FileCheck %s --check-prefix=NO-CAT-CLS64 65# RUN: not %lld -dylib -lSystem %t/swift-version-1.o %t/swift-version-2.o -o \66# RUN: /dev/null 2>&1 | FileCheck %s --check-prefix=SWIFT-MISMATCH-1267# RUN: not %lld -dylib -lSystem %t/swift-version-2.o %t/swift-version-1.o -o \68# RUN: /dev/null 2>&1 | FileCheck %s --check-prefix=SWIFT-MISMATCH-2169 70## with-category-cls.o does not have a Swift version (it's set to zero) and71## should be compatible with any Swift version.72# RUN: %lld -dylib -lSystem %t/with-category-cls.o %t/swift-version-1.o -o %t/swift-v173# RUN: llvm-objdump --macho --section="__DATA_CONST,__objc_imageinfo" \74# RUN: %t/swift-v1 | FileCheck %s --check-prefix=SWIFT-V175# RUN: %lld -dylib -lSystem %t/with-category-cls.o %t/swift-version-2.o -o %t/swift-v276# RUN: llvm-objdump --macho --section="__DATA_CONST,__objc_imageinfo" \77# RUN: %t/swift-v2 | FileCheck %s --check-prefix=SWIFT-V278 79# HAS-CAT-CLS: Contents of (__DATA_CONST,__objc_imageinfo) section80# HAS-CAT-CLS: 00 00 00 40 00 00 0081# HAS-CAT-CLS-EMPTY:82 83# NO-CAT-CLS: Contents of (__DATA_CONST,__objc_imageinfo) section84# NO-CAT-CLS: 00 00 00 00 00 00 0085# NO-CAT-CLS-EMPTY:86 87# SWIFT-V1: Contents of (__DATA_CONST,__objc_imageinfo) section88# SWIFT-V1: 00 00 00 40 01 00 0089# SWIFT-V1-EMPTY:90 91# SWIFT-V2: Contents of (__DATA_CONST,__objc_imageinfo) section92# SWIFT-V2: 00 00 00 40 02 00 0093# SWIFT-V2-EMPTY:94 95# IMAGE-VERSION: warning: {{.*}}invalid-version.o: invalid __objc_imageinfo version96 97# INVALID-SIZE: warning: {{.*}}invalid-size.o: invalid __objc_imageinfo size98 99# SWIFT-MISMATCH-12: error: Swift version mismatch: {{.*}}swift-version-1.o has version 1.0 but {{.*}}swift-version-2.o has version 1.1100# SWIFT-MISMATCH-21: error: Swift version mismatch: {{.*}}swift-version-2.o has version 1.1 but {{.*}}swift-version-1.o has version 1.0101 102#--- no-category-cls.s103.section __DATA,__objc_imageinfo,regular,no_dead_strip104## ld64 discards any symbols in this section; we follow suit.105_discard_me:106.long 0107.long 0108 109#--- with-category-cls.s110.section __DATA,__objc_imageinfo,regular,no_dead_strip111_discard_me:112.long 0113.long 0x40 ## "has category class properties" flag114 115#--- ignored-flags.s116.section __DATA,__objc_imageinfo,regular,no_dead_strip117.long 0118## Only the 0x40 flag is carried through to the output binary.119.long (0x40 | 0x20 | 0x4 | 0x2)120 121#--- invalid-version.s122.section __DATA,__objc_imageinfo,regular,no_dead_strip123.long 1 ## only 0 is valid; the flag field below will not be parsed.124.long 0x40125 126#--- invalid-size.s127.section __DATA,__objc_imageinfo128.long 0129 130#--- swift-version-1.s131.section __DATA,__objc_imageinfo,regular,no_dead_strip132.long 0133.byte 0x40134.byte 0x1 ## Swift version135.short 0136 137#--- swift-version-2.s138.section __DATA,__objc_imageinfo,regular,no_dead_strip139.long 0140.byte 0x40141.byte 0x2 ## Swift version142.short 0143 144#--- foo-cls.s145.section __TEXT,__objc_classname,cstring_literals146L_CAT_NAME:147.asciz "barcat"148 149.section __DATA,__objc_data150.p2align 3151_OBJC_CLASS_$_FooClass:152.space 40153 154.section __DATA,__objc_const155.p2align 3156__OBJC_$_CATEGORY_FooClass_$_barcat:157.quad L_CAT_NAME158.quad _OBJC_CLASS_$_FooClass159.quad 0160.quad 0161.quad 0162.quad 0163.quad 0164.long 64165.space 4166 167.section __DATA,__objc_catlist,regular,no_dead_strip168.p2align 3169.quad __OBJC_$_CATEGORY_FooClass_$_barcat170