150
|
1 # REQUIRES: x86
|
|
2
|
|
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
|
|
4 # RUN: llvm-objcopy %t1.o %t1copy.o
|
|
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-safe.s -o %t2.o
|
|
6 # RUN: ld.lld %t1.o %t2.o -o %t2 --icf=safe --print-icf-sections | FileCheck %s
|
|
7 # RUN: ld.lld %t1.o %t2.o -o %t3 --icf=safe --print-icf-sections -shared | FileCheck --check-prefix=EXPORT %s
|
|
8 # RUN: ld.lld %t1.o %t2.o -o %t3 --icf=safe --print-icf-sections --export-dynamic | FileCheck --check-prefix=EXPORT %s
|
|
9 # RUN: ld.lld %t1.o %t2.o -o %t2 --icf=all --print-icf-sections | FileCheck --check-prefix=ALL %s
|
|
10 # RUN: ld.lld %t1.o %t2.o -o %t2 --icf=all --print-icf-sections --export-dynamic | FileCheck --check-prefix=ALL-EXPORT %s
|
|
11 # RUN: ld.lld %t1copy.o -o %t4 --icf=safe 2>&1 | FileCheck --check-prefix=OBJCOPY %s
|
|
12
|
|
13 # CHECK-NOT: selected section {{.*}}:(.text.f1)
|
|
14 # CHECK: selected section {{.*}}:(.text.f3)
|
|
15 # CHECK: removing identical section {{.*}}:(.text.f4)
|
|
16
|
|
17 # CHECK-NOT: selected section {{.*}}:(.rodata.h1)
|
|
18 # CHECK: selected section {{.*}}:(.rodata.h3)
|
|
19 # CHECK: removing identical section {{.*}}:(.rodata.h4)
|
|
20
|
|
21 # CHECK-NOT: selected section {{.*}}:(.rodata.l1)
|
|
22 # CHECK: selected section {{.*}}:(.rodata.l3)
|
|
23 # CHECK: removing identical section {{.*}}:(.rodata.l4)
|
|
24
|
|
25 # CHECK-NOT: selected section {{.*}}:(.rodata.g1)
|
|
26 # CHECK: selected section {{.*}}:(.rodata.g3)
|
|
27 # CHECK: removing identical section {{.*}}:(.rodata.g4)
|
|
28
|
|
29 # CHECK-NOT: selected section {{.*}}:(.text.non_addrsig{{.}})
|
|
30
|
|
31 # With --icf=all address-significance implies keep-unique only for rodata, not
|
|
32 # text.
|
|
33 # ALL: selected section {{.*}}:(.text.f3)
|
|
34 # ALL: removing identical section {{.*}}:(.text.f4)
|
|
35
|
|
36 # ALL-NOT: selected section {{.*}}:(.rodata.h1)
|
|
37 # ALL: selected section {{.*}}:(.rodata.h3)
|
|
38 # ALL: removing identical section {{.*}}:(.rodata.h4)
|
|
39
|
|
40 # ALL-NOT: selected section {{.*}}:(.rodata.l1)
|
|
41 # ALL: selected section {{.*}}:(.rodata.l3)
|
|
42 # ALL: removing identical section {{.*}}:(.rodata.l4)
|
|
43
|
|
44 # ALL-NOT: selected section {{.*}}:(.rodata.g1)
|
|
45 # ALL: selected section {{.*}}:(.rodata.g3)
|
|
46 # ALL: removing identical section {{.*}}:(.rodata.g4)
|
|
47
|
|
48 # ALL: selected section {{.*}}:(.text.f1)
|
|
49 # ALL: removing identical section {{.*}}:(.text.f2)
|
|
50 # ALL: removing identical section {{.*}}:(.text.non_addrsig1)
|
|
51 # ALL: removing identical section {{.*}}:(.text.non_addrsig2)
|
|
52
|
|
53 # llvm-mc normally emits an empty .text section into every object file. Since
|
|
54 # nothing actually refers to it via a relocation, it doesn't have any associated
|
|
55 # symbols (thus nor can anything refer to it via a relocation, making it safe to
|
|
56 # merge with the empty section in the other input file). Here we check that the
|
|
57 # only two sections merged are the two empty sections and the sections with only
|
|
58 # STB_LOCAL or STV_HIDDEN symbols. The dynsym entries should have prevented
|
|
59 # anything else from being merged.
|
|
60 # EXPORT-NOT: selected section
|
|
61 # EXPORT: selected section {{.*}}:(.rodata.h3)
|
|
62 # EXPORT: removing identical section {{.*}}:(.rodata.h4)
|
|
63 # EXPORT-NOT: selected section
|
|
64 # EXPORT: selected section {{.*}}:(.text)
|
|
65 # EXPORT: removing identical section {{.*}}:(.text)
|
|
66 # EXPORT-NOT: selected section
|
|
67 # EXPORT: selected section {{.*}}:(.rodata.l3)
|
|
68 # EXPORT: removing identical section {{.*}}:(.rodata.l4)
|
|
69 # EXPORT-NOT: selected section
|
|
70
|
|
71 # If --icf=all is specified when exporting we can also merge the exported text
|
|
72 # sections, but not the exported rodata.
|
|
73 # ALL-EXPORT-NOT: selected section
|
|
74 # ALL-EXPORT: selected section {{.*}}:(.text.f3)
|
|
75 # ALL-EXPORT: removing identical section {{.*}}:(.text.f4)
|
|
76 # ALL-EXPORT-NOT: selected section
|
|
77 # ALL-EXPORT: selected section {{.*}}:(.rodata.h3)
|
|
78 # ALL-EXPORT: removing identical section {{.*}}:(.rodata.h4)
|
|
79 # ALL-EXPORT-NOT: selected section
|
|
80 # ALL-EXPORT: selected section {{.*}}:(.text)
|
|
81 # ALL-EXPORT: removing identical section {{.*}}:(.text)
|
|
82 # ALL-EXPORT-NOT: selected section
|
|
83 # ALL-EXPORT: selected section {{.*}}:(.rodata.l3)
|
|
84 # ALL-EXPORT: removing identical section {{.*}}:(.rodata.l4)
|
|
85 # ALL-EXPORT-NOT: selected section
|
|
86 # ALL-EXPORT: selected section {{.*}}:(.text.f1)
|
|
87 # ALL-EXPORT: removing identical section {{.*}}:(.text.f2)
|
|
88 # ALL-EXPORT: removing identical section {{.*}}:(.text.non_addrsig1)
|
|
89 # ALL-EXPORT: removing identical section {{.*}}:(.text.non_addrsig2)
|
|
90 # ALL-EXPORT-NOT: selected section
|
|
91
|
|
92 # OBJCOPY: --icf=safe is incompatible with object files created using objcopy or ld -r
|
|
93
|
|
94 .section .text.f1,"ax",@progbits
|
|
95 .globl f1
|
|
96 f1:
|
|
97 ret
|
|
98
|
|
99 .section .text.f2,"ax",@progbits
|
|
100 .globl f2
|
|
101 f2:
|
|
102 ret
|
|
103
|
|
104 .section .text.f3,"ax",@progbits
|
|
105 .globl f3
|
|
106 f3:
|
|
107 ud2
|
|
108
|
|
109 .section .text.f4,"ax",@progbits
|
|
110 .globl f4
|
|
111 f4:
|
|
112 ud2
|
|
113
|
|
114 .section .rodata.g1,"a",@progbits
|
|
115 .globl g1
|
|
116 g1:
|
|
117 .byte 1
|
|
118
|
|
119 .section .rodata.g2,"a",@progbits
|
|
120 .globl g2
|
|
121 g2:
|
|
122 .byte 1
|
|
123
|
|
124 .section .rodata.g3,"a",@progbits
|
|
125 .globl g3
|
|
126 g3:
|
|
127 .byte 2
|
|
128
|
|
129 .section .rodata.g4,"a",@progbits
|
|
130 .globl g4
|
|
131 g4:
|
|
132 .byte 2
|
|
133
|
|
134 .section .rodata.l1,"a",@progbits
|
|
135 l1:
|
|
136 .byte 3
|
|
137
|
|
138 .section .rodata.l2,"a",@progbits
|
|
139 l2:
|
|
140 .byte 3
|
|
141
|
|
142 .section .rodata.l3,"a",@progbits
|
|
143 l3:
|
|
144 .byte 4
|
|
145
|
|
146 .section .rodata.l4,"a",@progbits
|
|
147 l4:
|
|
148 .byte 4
|
|
149
|
|
150 .section .rodata.h1,"a",@progbits
|
|
151 .globl h1
|
|
152 .hidden h1
|
|
153 h1:
|
|
154 .byte 5
|
|
155
|
|
156 .section .rodata.h2,"a",@progbits
|
|
157 .globl h2
|
|
158 .hidden h2
|
|
159 h2:
|
|
160 .byte 5
|
|
161
|
|
162 .section .rodata.h3,"a",@progbits
|
|
163 .globl h3
|
|
164 .hidden h3
|
|
165 h3:
|
|
166 .byte 6
|
|
167
|
|
168 .section .rodata.h4,"a",@progbits
|
|
169 .globl h4
|
|
170 .hidden h4
|
|
171 h4:
|
|
172 .byte 6
|
|
173
|
|
174 .addrsig
|
|
175 .addrsig_sym f1
|
|
176 .addrsig_sym f2
|
|
177 .addrsig_sym g1
|
|
178 .addrsig_sym g2
|
|
179 .addrsig_sym l1
|
|
180 .addrsig_sym l2
|
|
181 .addrsig_sym h1
|
|
182 .addrsig_sym h2
|