File: gc-sections-group.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (105 lines) | stat: -rw-r--r-- 3,509 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# REQUIRES: x86
## Check that group members are retained or discarded as a unit, and
## non-SHF_ALLOC sections in a group are subject to garbage collection,
## if at least one member has the SHF_ALLOC flag.

# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
# RUN: ld.lld --gc-sections %t.o -o %t.dead
# RUN: llvm-readobj -S %t.dead | FileCheck %s --check-prefix=CHECK-DEAD

## .mynote.ccc is retained because it is not in a group.
# CHECK-DEAD-NOT: Name: .myanote.aaa
# CHECK-DEAD-NOT: Name: .mytext.aaa
# CHECK-DEAD-NOT: Name: .mybss.aaa
# CHECK-DEAD-NOT: Name: .mynote.aaa
# CHECK-DEAD-NOT: Name: .myanote.bbb
# CHECK-DEAD-NOT: Name: .mytext.bbb
# CHECK-DEAD-NOT: Name: .mybss.bbb
# CHECK-DEAD-NOT: Name: .mynote.bbb
# CHECK-DEAD:     Name: .mynote.ccc

# RUN: ld.lld --gc-sections %t.o -o %t -e anote_aaa
# RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-GROUP
# RUN: ld.lld --gc-sections %t.o -o %t -e aaa
# RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-GROUP
# RUN: ld.lld --gc-sections %t.o -o %t -e bss_aaa
# RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-GROUP

## note_zero as the entry point does not make much sense because it is defined
## in a non-SHF_ALLOC section. This is just to demonstrate the behavior.
# RUN: ld.lld --gc-sections %t.o -o %t -e note_aaa
# RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-GROUP

# CHECK-LIVE-GROUP: Name: .myanote.aaa
# CHECK-LIVE-GROUP: Name: .mytext.aaa
# CHECK-LIVE-GROUP: Name: .mybss.aaa
# CHECK-LIVE-GROUP: Name: .mynote.aaa
# CHECK-LIVE-GROUP-NOT: Name: .myanote.bbb
# CHECK-LIVE-GROUP-NOT: Name: .mytext.bbb
# CHECK-LIVE-GROUP-NOT: Name: .mybss.bbb
# CHECK-LIVE-GROUP-NOT: Name: .mynote.bbb
# CHECK-LIVE-GROUP: Name: .mynote.ccc

# RUN: ld.lld --gc-sections %t.o -o %t -e anote_bbb
# RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-COMDAT
# RUN: ld.lld --gc-sections %t.o -o %t -e bbb
# RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-COMDAT
# RUN: ld.lld --gc-sections %t.o -o %t -e bss_bbb
# RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-COMDAT

## note_bbb as the entry point does not make much sense because it is defined
## in a non-SHF_ALLOC section. This is just to demonstrate the behavior.
# RUN: ld.lld --gc-sections %t.o -o %t -e note_bbb
# RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=CHECK-LIVE-COMDAT

# CHECK-LIVE-COMDAT-NOT: Name: .myanote.aaa
# CHECK-LIVE-COMDAT-NOT: Name: .mytext.aaa
# CHECK-LIVE-COMDAT-NOT: Name: .mybss.aaa
# CHECK-LIVE-COMDAT-NOT: Name: .mynote.aaa
# CHECK-LIVE-COMDAT: Name: .myanote.bbb
# CHECK-LIVE-COMDAT: Name: .mytext.bbb
# CHECK-LIVE-COMDAT: Name: .mybss.bbb
# CHECK-LIVE-COMDAT: Name: .mynote.bbb
# CHECK-LIVE-COMDAT: Name: .mynote.ccc

## These sections are in a zero flag group `aaa`.
.globl anote_aaa, aaa, bss_aaa, note_aaa

.section .myanote.aaa,"aG",@note,aaa
anote_aaa:
.byte 0

.section .mytext.aaa,"axG",@progbits,aaa
aaa:
.byte 0

.section .mybss.aaa,"awG",@nobits,aaa
bss_aaa:
.byte 0

.section .mynote.aaa,"G",@note,aaa
note_aaa:
.byte 0

## These sections are in a COMDAT group `bbb`.
.globl anote_bbb, bbb, bss_bbb, note_bbb

.section .myanote.bbb,"aG",@note,bbb,comdat
anote_bbb:
.byte 0

.section .mytext.bbb,"axG",@progbits,bbb,comdat
bbb:
.byte 0

.section .mybss.bbb,"awG",@nobits,bbb,comdat
bss_bbb:
.byte 0

.section .mynote.bbb,"G",@note,bbb,comdat
note_bbb:
.byte 0

## This section isn't in any group.
.section .mynote.ccc,"",@note
.byte 0