[ELF] Make section member orders consistent
[llvm-project.git] / lld / test / ELF / icf-preemptible.s
blob4bd1eca438b19f30a235f2a48af6bfa6e2a5c5c9
1 # REQUIRES: x86
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
4 # RUN: ld.lld -pie %t.o --icf=all --print-icf-sections -o /dev/null | \
5 # RUN: FileCheck --check-prefixes=EXE %s
7 # RUN: ld.lld -shared %t.o --icf=all --print-icf-sections -o /dev/null | \
8 # RUN: FileCheck --check-prefix=DSO %s
10 ## Definitions are non-preemptible in an executable.
11 # EXE-NOT: {{.}}
12 # EXE: selected section {{.*}}:(.text.g1)
13 # EXE-NEXT: removing identical section {{.*}}:(.text.g2)
14 # EXE-NEXT: removing identical section {{.*}}:(.text.g3)
15 # EXE-NEXT: selected section {{.*}}:(.text.f1)
16 # EXE-NEXT: removing identical section {{.*}}:(.text.f2)
17 # EXE-NEXT: selected section {{.*}}:(.text.h1)
18 # EXE-NEXT: removing identical section {{.*}}:(.text.h2)
19 # EXE-NEXT: removing identical section {{.*}}:(.text.h3)
20 # EXE-NOT: {{.}}
22 ## Definitions are preemptible in a DSO. Only leaf functions can be folded.
23 # DSO-NOT: {{.}}
24 # DSO: selected section {{.*}}:(.text.g1)
25 # DSO-NEXT: removing identical section {{.*}}:(.text.g3)
26 # DSO-NEXT: selected section {{.*}}:(.text.f1)
27 # DSO-NEXT: removing identical section {{.*}}:(.text.f2)
28 # DSO-NOT: {{.}}
30 .globl _start, f1, f2, g1, g2, g3
31 _start:
33 .section .text.f1
34 f1: ret
35 .section .text.f2
36 f2: ret
38 ## In -shared mode, .text.g1 and .text.g2 cannot be folded because f1 and f2 are
39 ## preemptible and may refer to different functions at runtime.
40 .section .text.g1
41 g1: jmp f1@plt
42 .section .text.g2
43 g2: jmp f2@plt
44 .section .text.g3
45 g3: jmp f1@plt
47 ## In -shared mode, the sections below cannot be folded because g1, g2 and g3
48 ## are preemptible and may refer to different functions at runtime.
49 .section .text.h1
50 jmp g1@plt
51 .section .text.h2
52 jmp g2@plt
53 .section .text.h3
54 jmp g3@plt