2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo1.s -o %t/foo1.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo2.s -o %t/foo2.o
5 # RUN: %lld -dylib --icf=all -framework CoreFoundation %t/foo1.o %t/foo2.o -o %t/foo
6 # RUN: llvm-objdump --no-print-imm-hex --macho --rebase --bind --syms -d %t/foo | FileCheck %s --check-prefixes=CHECK,LITERALS
7 # RUN: %lld -dylib -framework CoreFoundation %t/foo1.o %t/foo2.o -o %t/foo
8 # RUN: llvm-objdump --no-print-imm-hex --macho --rebase --bind --syms -d %t/foo | FileCheck %s --check-prefix=LITERALS
10 # CHECK: (__TEXT,__text) section
13 # CHECK-NEXT: movq _named_cfstring(%rip), %rax
14 # CHECK-NEXT: _foo1_utf16:
15 # CHECK-NEXT: movq [[#]](%rip), %rax
16 # CHECK-NEXT: _named_foo1:
17 # CHECK-NEXT: _named_foo2:
18 # CHECK-NEXT: movq _named_cfstring(%rip), %rax
19 # CHECK-NEXT: _foo2_utf16:
20 # CHECK-NEXT: movq [[#]](%rip), %rax
22 # CHECK: SYMBOL TABLE:
23 # CHECK-DAG: [[#%.16x,FOO:]] g F __TEXT,__text _foo1
24 # CHECK-DAG: [[#FOO]] g F __TEXT,__text _foo2
26 ## Make sure we don't emit redundant bind / rebase opcodes for folded sections.
27 # LITERALS: Rebase table:
28 # LITERALS-NEXT: segment section address type
29 # LITERALS-NEXT: __DATA_CONST __cfstring {{.*}} pointer
30 # LITERALS-NEXT: __DATA_CONST __cfstring {{.*}} pointer
31 # LITERALS-NEXT: __DATA_CONST __cfstring {{.*}} pointer
33 # LITERALS-NEXT: Bind table:
34 # LITERALS-NEXT: segment section address type addend dylib symbol
35 # LITERALS-NEXT: __DATA_CONST __cfstring {{.*}} pointer 0 CoreFoundation ___CFConstantStringClassReference
36 # LITERALS-NEXT: __DATA_CONST __cfstring {{.*}} pointer 0 CoreFoundation ___CFConstantStringClassReference
37 # LITERALS-NEXT: __DATA_CONST __cfstring {{.*}} pointer 0 CoreFoundation ___CFConstantStringClassReference
44 ## This string is at a different offset than the corresponding "foo" string in
45 ## foo2.s. Make sure that we treat references to either string as equivalent.
49 .section __DATA,__cfstring
52 .quad ___CFConstantStringClassReference
59 .quad ___CFConstantStringClassReference
65 .section __TEXT,__ustring
73 ## FIXME: We should be able to deduplicate UTF-16 CFStrings too.
74 ## Note that this string contains a null byte in the middle -- any dedup code
75 ## we add should take care to handle this correctly.
76 ## Technically, UTF-8 should support encoding null bytes too, but since we
77 ## atomize the __cstring section at every null byte, this isn't supported. ld64
78 ## doesn't support it either, and clang seems to always emit a UTF-16 CFString
79 ## if it needs to contain a null, so I think we're good here.
80 .section __DATA,__cfstring
82 L__unnamed_cfstring_.2
:
83 .quad ___CFConstantStringClassReference
90 .globl _foo1, _foo1_utf16, _named_foo1
92 movq L__unnamed_cfstring_
(%rip
), %rax
95 movq L__unnamed_cfstring_.2
(%rip
), %rax
98 movq _named_cfstring
(%rip
), %rax
100 .subsections_via_symbols
107 .section __DATA,__cfstring
109 L__unnamed_cfstring_
:
110 .quad ___CFConstantStringClassReference
117 .quad ___CFConstantStringClassReference
123 .section __TEXT,__ustring
132 .section __DATA,__cfstring
134 L__unnamed_cfstring_.2
:
135 .quad ___CFConstantStringClassReference
142 .globl _foo2, _foo2_utf16, _named_foo2
144 movq L__unnamed_cfstring_
(%rip
), %rax
147 movq L__unnamed_cfstring_.2
(%rip
), %rax
150 movq _named_cfstring
(%rip
), %rax
152 .subsections_via_symbols