[ELF] Make SyntheticSection parameter order match InputSection
[llvm-project.git] / lld / test / ELF / gc-sections-group.s
blobda4cad98f36530bd21e23dee95d3fa599dda8969
1 # REQUIRES: x86
2 ## Check that group members are retained or discarded as a unit, and
3 ## non-SHF_ALLOC sections in a group are subject to garbage collection,
4 ## if at least one member has the SHF_ALLOC flag.
6 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
7 # RUN: ld.lld --gc-sections %t.o -o %t.dead
8 # RUN: llvm-readobj -S %t.dead | FileCheck %s --check-prefix=CHECK-DEAD
10 ## .mynote.ccc is retained because it is not in a group.
11 # CHECK-DEAD-NOT: Name: .myanote.aaa
12 # CHECK-DEAD-NOT: Name: .mytext.aaa
13 # CHECK-DEAD-NOT: Name: .mybss.aaa
14 # CHECK-DEAD-NOT: Name: .mynote.aaa
15 # CHECK-DEAD-NOT: Name: .myanote.bbb
16 # CHECK-DEAD-NOT: Name: .mytext.bbb
17 # CHECK-DEAD-NOT: Name: .mybss.bbb
18 # CHECK-DEAD-NOT: Name: .mynote.bbb
19 # CHECK-DEAD: Name: .mynote.ccc
21 # RUN: ld.lld --gc-sections %t.o -o %t -e anote_aaa
22 # RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-GROUP
23 # RUN: ld.lld --gc-sections %t.o -o %t -e aaa
24 # RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-GROUP
25 # RUN: ld.lld --gc-sections %t.o -o %t -e bss_aaa
26 # RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-GROUP
28 ## note_zero as the entry point does not make much sense because it is defined
29 ## in a non-SHF_ALLOC section. This is just to demonstrate the behavior.
30 # RUN: ld.lld --gc-sections %t.o -o %t -e note_aaa
31 # RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-GROUP
33 # CHECK-LIVE-GROUP: Name: .myanote.aaa
34 # CHECK-LIVE-GROUP: Name: .mytext.aaa
35 # CHECK-LIVE-GROUP: Name: .mybss.aaa
36 # CHECK-LIVE-GROUP: Name: .mynote.aaa
37 # CHECK-LIVE-GROUP-NOT: Name: .myanote.bbb
38 # CHECK-LIVE-GROUP-NOT: Name: .mytext.bbb
39 # CHECK-LIVE-GROUP-NOT: Name: .mybss.bbb
40 # CHECK-LIVE-GROUP-NOT: Name: .mynote.bbb
41 # CHECK-LIVE-GROUP: Name: .mynote.ccc
43 # RUN: ld.lld --gc-sections %t.o -o %t -e anote_bbb
44 # RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-COMDAT
45 # RUN: ld.lld --gc-sections %t.o -o %t -e bbb
46 # RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-COMDAT
47 # RUN: ld.lld --gc-sections %t.o -o %t -e bss_bbb
48 # RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-COMDAT
50 ## note_bbb as the entry point does not make much sense because it is defined
51 ## in a non-SHF_ALLOC section. This is just to demonstrate the behavior.
52 # RUN: ld.lld --gc-sections %t.o -o %t -e note_bbb
53 # RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-COMDAT
55 # CHECK-LIVE-COMDAT-NOT: Name: .myanote.aaa
56 # CHECK-LIVE-COMDAT-NOT: Name: .mytext.aaa
57 # CHECK-LIVE-COMDAT-NOT: Name: .mybss.aaa
58 # CHECK-LIVE-COMDAT-NOT: Name: .mynote.aaa
59 # CHECK-LIVE-COMDAT: Name: .myanote.bbb
60 # CHECK-LIVE-COMDAT: Name: .mytext.bbb
61 # CHECK-LIVE-COMDAT: Name: .mybss.bbb
62 # CHECK-LIVE-COMDAT: Name: .mynote.bbb
63 # CHECK-LIVE-COMDAT: Name: .mynote.ccc
65 ## These sections are in a zero flag group `aaa`.
66 .globl anote_aaa, aaa, bss_aaa, note_aaa
68 .section .myanote.aaa,"aG",@note,aaa
69 anote_aaa:
70 .byte 0
72 .section .mytext.aaa,"axG",@progbits,aaa
73 aaa:
74 .byte 0
76 .section .mybss.aaa,"awG",@nobits,aaa
77 bss_aaa:
78 .byte 0
80 .section .mynote.aaa,"G",@note,aaa
81 note_aaa:
82 .byte 0
84 ## These sections are in a COMDAT group `bbb`.
85 .globl anote_bbb, bbb, bss_bbb, note_bbb
87 .section .myanote.bbb,"aG",@note,bbb,comdat
88 anote_bbb:
89 .byte 0
91 .section .mytext.bbb,"axG",@progbits,bbb,comdat
92 bbb:
93 .byte 0
95 .section .mybss.bbb,"awG",@nobits,bbb,comdat
96 bss_bbb:
97 .byte 0
99 .section .mynote.bbb,"G",@note,bbb,comdat
100 note_bbb:
101 .byte 0
103 ## This section isn't in any group.
104 .section .mynote.ccc,"",@note
105 .byte 0