1# REQUIRES: aarch64 2# RUN: rm -rf %t; split-file %s %t 3 4# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/explicit-selrefs-1.s -o %t/explicit-selrefs-1.o 5# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/explicit-selrefs-2.s -o %t/explicit-selrefs-2.o 6# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/implicit-selrefs.s -o %t/implicit-selrefs.o 7 8# RUN: %lld -dylib -arch arm64 -lSystem -o %t/explicit-only-no-icf \ 9# RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o -no_fixup_chains 10# RUN: llvm-otool -vs __DATA __objc_selrefs %t/explicit-only-no-icf | \ 11# RUN: FileCheck %s --check-prefix=EXPLICIT-NO-ICF 12 13## NOTE: ld64 always dedups the selrefs unconditionally, but we only do it when 14## ICF is enabled. 15# RUN: %lld -dylib -arch arm64 -lSystem -o %t/explicit-only-with-icf \ 16# RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o -no_fixup_chains 17# RUN: llvm-otool -vs __DATA __objc_selrefs %t/explicit-only-with-icf \ 18# RUN: | FileCheck %s --check-prefix=EXPLICIT-WITH-ICF 19 20# SELREFS: Contents of (__DATA,__objc_selrefs) section 21# SELREFS-NEXT: __TEXT:__objc_methname:foo 22# SELREFS-NEXT: __TEXT:__objc_methname:bar 23# SELREFS-NEXT: __TEXT:__objc_methname:foo 24# SELREFS-NEXT: __TEXT:__objc_methname:length 25# SELREFS-EMPTY: 26 27# RUN: %lld -dylib -arch arm64 -lSystem --icf=all -o %t/explicit-and-implicit \ 28# RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o %t/implicit-selrefs.o \ 29# RUN: -no_fixup_chains 30# RUN: llvm-otool -vs __DATA __objc_selrefs %t/explicit-and-implicit \ 31# RUN: | FileCheck %s --check-prefix=EXPLICIT-AND-IMPLICIT 32 33# EXPLICIT-NO-ICF: Contents of (__DATA,__objc_selrefs) section 34# EXPLICIT-NO-ICF-NEXT: __TEXT:__objc_methname:foo 35# EXPLICIT-NO-ICF-NEXT: __TEXT:__objc_methname:bar 36# EXPLICIT-NO-ICF-NEXT: __TEXT:__objc_methname:bar 37# EXPLICIT-NO-ICF-NEXT: __TEXT:__objc_methname:foo 38 39# EXPLICIT-WITH-ICF: Contents of (__DATA,__objc_selrefs) section 40# EXPLICIT-WITH-ICF-NEXT: __TEXT:__objc_methname:foo 41# EXPLICIT-WITH-ICF-NEXT: __TEXT:__objc_methname:bar 42 43# EXPLICIT-AND-IMPLICIT: Contents of (__DATA,__objc_selrefs) section 44# EXPLICIT-AND-IMPLICIT-NEXT: __TEXT:__objc_methname:foo 45# EXPLICIT-AND-IMPLICIT-NEXT: __TEXT:__objc_methname:bar 46# EXPLICIT-AND-IMPLICIT-NEXT: __TEXT:__objc_methname:length 47 48#--- explicit-selrefs-1.s 49.section __TEXT,__objc_methname,cstring_literals 50lselref1: 51 .asciz "foo" 52lselref2: 53 .asciz "bar" 54 55.section __DATA,__objc_selrefs,literal_pointers,no_dead_strip 56.p2align 3 57 .quad lselref1 58 .quad lselref2 59 .quad lselref2 60 61#--- explicit-selrefs-2.s 62.section __TEXT,__objc_methname,cstring_literals 63lselref1: 64 .asciz "foo" 65 66.section __DATA,__objc_selrefs,literal_pointers,no_dead_strip 67.p2align 3 68 .quad lselref1 69 70#--- implicit-selrefs.s 71.text 72.globl _objc_msgSend 73.p2align 2 74_objc_msgSend: 75 ret 76 77.p2align 2 78_sender: 79 bl _objc_msgSend$length 80 bl _objc_msgSend$foo 81 ret 82