2 # RUN: rm -rf %t; mkdir %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
4 # RUN: %lld -lSystem --icf=all -o %t/test %t/test.o
5 # RUN: llvm-objdump --macho --syms -d %t/test | FileCheck %s
8 # CHECK-NEXT: callq _foo2_ref
9 # CHECK-NEXT: callq _foo2_ref
10 # CHECK-NEXT: callq _foo2_neg_offset_ref
11 # CHECK-NEXT: callq _foo2_neg_offset_ref
12 # CHECK-NEXT: callq _foo2_pos_offset_ref
13 # CHECK-NEXT: callq _foo2_pos_offset_ref
14 # CHECK-NEXT: callq _bar2_ref
15 # CHECK-NEXT: callq _bar2_ref
16 # CHECK-NEXT: callq _baz2_ref
17 # CHECK-NEXT: callq _baz2_ref
18 # CHECK-NEXT: callq _qux2_ref
19 # CHECK-NEXT: callq _qux2_ref
20 # CHECK-NEXT: callq _sub_str_a_b
21 # CHECK-NEXT: callq _sub_str_b_a
22 # CHECK-NEXT: callq _sub_lit_a_b
23 # CHECK-NEXT: callq _sub_lit_b_a
25 # CHECK: [[#%.16x,FOO:]] l O __TEXT,__cstring _foo1
26 # CHECK-NEXT: [[#%.16x,FOO:]] l O __TEXT,__cstring _foo2
27 # CHECK-NEXT: [[#%.16x,BAR:]] l O __TEXT,__cstring _bar1
28 # CHECK-NEXT: [[#%.16x,BAR:]] l O __TEXT,__cstring _bar2
29 # CHECK-NEXT: [[#%.16x,BAZ:]] l O __TEXT,__literals _baz1
30 # CHECK-NEXT: [[#%.16x,BAZ:]] l O __TEXT,__literals _baz2
31 # CHECK-NEXT: [[#%.16x,QUX:]] l O __TEXT,__literals _qux1
32 # CHECK-NEXT: [[#%.16x,QUX:]] l O __TEXT,__literals _qux2
33 # CHECK-NEXT: [[#%.16x,FOO_REF:]] l F __TEXT,__text _foo1_ref
34 # CHECK-NEXT: [[#%.16x,FOO_REF:]] l F __TEXT,__text _foo2_ref
35 # CHECK-NEXT: [[#%.16x,FOO_NEG:]] l F __TEXT,__text _foo1_neg_offset_ref
36 # CHECK-NEXT: [[#%.16x,FOO_NEG]] l F __TEXT,__text _foo2_neg_offset_ref
37 # CHECK-NEXT: [[#%.16x,FOO_POS:]] l F __TEXT,__text _foo1_pos_offset_ref
38 # CHECK-NEXT: [[#%.16x,FOO_POS]] l F __TEXT,__text _foo2_pos_offset_ref
39 # CHECK-NEXT: [[#%.16x,BAR_REF:]] l F __TEXT,__text _bar1_ref
40 # CHECK-NEXT: [[#%.16x,BAR_REF:]] l F __TEXT,__text _bar2_ref
41 # CHECK-NEXT: [[#%.16x,BAZ_REF:]] l F __TEXT,__text _baz1_ref
42 # CHECK-NEXT: [[#%.16x,BAZ_REF:]] l F __TEXT,__text _baz2_ref
43 # CHECK-NEXT: [[#%.16x,QUX_REF:]] l F __TEXT,__text _qux1_ref
44 # CHECK-NEXT: [[#%.16x,QUX_REF:]] l F __TEXT,__text _qux2_ref
46 ## _foo1 vs _bar1: same section, different offsets
47 ## _foo1 vs _baz1: same offset, different sections
71 leaq _foo1
(%rip
), %rax
73 leaq _foo2
(%rip
), %rax
75 ## Check that we can correctly handle `_foo1-32` even though it points outside
76 ## the __cstring section.
77 leaq _foo1-
32(%rip
), %rax
79 leaq _foo2-
32(%rip
), %rax
81 leaq _foo1+
4(%rip
), %rax
83 ## Although `_foo2+4` points at _bar1 in the input object file, we shouldn't
84 ## dedup references to _foo2+4 with references to _bar1.
85 leaq _foo2+
4(%rip
), %rax
87 leaq _bar1
(%rip
), %rax
89 leaq _bar2
(%rip
), %rax
91 movq _baz1
(%rip
), %rax
93 movq _baz2
(%rip
), %rax
95 movq _qux1
(%rip
), %rax
97 movq _qux2
(%rip
), %rax
99 ## _sub_str_a_b and _sub_str_b_a should not be folded: They contain relocations
100 ## against the same string symbols, but in a different order and hence
101 ## return different numbers.
103 leaq _foo2
(%rip
), %rdx
104 leaq _bar2
(%rip
), %rax
107 leaq _bar2
(%rip
), %rdx
108 leaq _foo2
(%rip
), %rax
111 ## Same with literals instead of strings.
113 movq _baz2
(%rip
), %rax
114 subq _qux2
(%rip
), %rax
116 movq _qux2
(%rip
), %rax
117 subq _baz2
(%rip
), %rax
124 callq _foo1_neg_offset_ref
125 callq _foo2_neg_offset_ref
126 callq _foo1_pos_offset_ref
127 callq _foo2_pos_offset_ref
139 .subsections_via_symbols