[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / common-page.s
blobfd6564cb0036145f633234db2a9560f3322531f2
1 # REQUIRES: x86
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
5 # exits with return code 42 on linux
6 .globl _start
7 _start:
8 nop
10 # Increase max-page-size to 64k while using the default x86_64 common page size
11 # of 4k. If the last loadable segment is executable then lld aligns the next
12 # section using the common page size.
14 # RUN: ld.lld -z max-page-size=0x10000 -z common-page-size=0x1000 %t -o %t2 2>&1 | count 0
15 # RUN: llvm-readobj --sections -l %t2 | FileCheck --check-prefix=CHECK-MAX %s
17 # CHECK-MAX: Sections [
18 # CHECK-MAX-NEXT: Section {
19 # CHECK-MAX-NEXT: Index: 0
20 # CHECK-MAX-NEXT: Name: (0)
21 # CHECK-MAX-NEXT: Type: SHT_NULL (0x0)
22 # CHECK-MAX-NEXT: Flags [ (0x0)
23 # CHECK-MAX-NEXT: ]
24 # CHECK-MAX-NEXT: Address: 0x0
25 # CHECK-MAX-NEXT: Offset: 0x0
26 # CHECK-MAX-NEXT: Size: 0
27 # CHECK-MAX-NEXT: Link: 0
28 # CHECK-MAX-NEXT: Info: 0
29 # CHECK-MAX-NEXT: AddressAlignment: 0
30 # CHECK-MAX-NEXT: EntrySize: 0
31 # CHECK-MAX-NEXT: }
32 # CHECK-MAX-NEXT: Section {
33 # CHECK-MAX-NEXT: Index: 1
34 # CHECK-MAX-NEXT: Name: .text (1)
35 # CHECK-MAX-NEXT: Type: SHT_PROGBITS (0x1)
36 # CHECK-MAX-NEXT: Flags [ (0x6)
37 # CHECK-MAX-NEXT: SHF_ALLOC (0x2)
38 # CHECK-MAX-NEXT: SHF_EXECINSTR (0x4)
39 # CHECK-MAX-NEXT: ]
40 # CHECK-MAX-NEXT: Address: 0x210120
41 # CHECK-MAX-NEXT: Offset: 0x120
42 # CHECK-MAX-NEXT: Size: 1
43 # CHECK-MAX-NEXT: Link: 0
44 # CHECK-MAX-NEXT: Info: 0
45 # CHECK-MAX-NEXT: AddressAlignment: 4
46 # CHECK-MAX-NEXT: EntrySize: 0
47 # CHECK-MAX-NEXT: }
48 # CHECK-MAX-NEXT: Section {
49 # CHECK-MAX-NEXT: Index: 2
50 # CHECK-MAX-NEXT: Name: .comment (7)
51 # CHECK-MAX-NEXT: Type: SHT_PROGBITS (0x1)
52 # CHECK-MAX-NEXT: Flags [ (0x30)
53 # CHECK-MAX-NEXT: SHF_MERGE (0x10)
54 # CHECK-MAX-NEXT: SHF_STRINGS (0x20)
55 # CHECK-MAX-NEXT: ]
56 # CHECK-MAX-NEXT: Address: 0x0
57 # CHECK-MAX-NEXT: Offset: 0x121
58 # CHECK-MAX-NEXT: Size: 8
59 # CHECK-MAX-NEXT: Link: 0
60 # CHECK-MAX-NEXT: Info: 0
61 # CHECK-MAX-NEXT: AddressAlignment: 1
62 # CHECK-MAX-NEXT: EntrySize: 1
64 # CHECK-MAX: ProgramHeaders [
65 # CHECK-MAX-NEXT: ProgramHeader {
66 # CHECK-MAX-NEXT: Type: PT_PHDR (0x6)
67 # CHECK-MAX-NEXT: Offset: 0x40
68 # CHECK-MAX-NEXT: VirtualAddress: 0x200040
69 # CHECK-MAX-NEXT: PhysicalAddress: 0x200040
70 # CHECK-MAX-NEXT: FileSize: 224
71 # CHECK-MAX-NEXT: MemSize: 224
72 # CHECK-MAX-NEXT: Flags [ (0x4)
73 # CHECK-MAX-NEXT: PF_R (0x4)
74 # CHECK-MAX-NEXT: ]
75 # CHECK-MAX-NEXT: Alignment: 8
76 # CHECK-MAX-NEXT: }
77 # CHECK-MAX-NEXT: ProgramHeader {
78 # CHECK-MAX-NEXT: Type: PT_LOAD (0x1)
79 # CHECK-MAX-NEXT: Offset: 0x0
80 # CHECK-MAX-NEXT: VirtualAddress: 0x200000
81 # CHECK-MAX-NEXT: PhysicalAddress: 0x200000
82 # CHECK-MAX-NEXT: FileSize: 288
83 # CHECK-MAX-NEXT: MemSize: 288
84 # CHECK-MAX-NEXT: Flags [ (0x4)
85 # CHECK-MAX-NEXT: PF_R (0x4)
86 # CHECK-MAX-NEXT: ]
87 # CHECK-MAX-NEXT: Alignment: 65536
88 # CHECK-MAX-NEXT: }
89 # CHECK-MAX-NEXT: ProgramHeader {
90 # CHECK-MAX-NEXT: Type: PT_LOAD (0x1)
91 # CHECK-MAX-NEXT: Offset: 0x120
92 # CHECK-MAX-NEXT: VirtualAddress: 0x210120
93 # CHECK-MAX-NEXT: PhysicalAddress: 0x210120
94 # CHECK-MAX-NEXT: FileSize: 1
95 # CHECK-MAX-NEXT: MemSize: 1
96 # CHECK-MAX-NEXT: Flags [ (0x5)
97 # CHECK-MAX-NEXT: PF_R (0x4)
98 # CHECK-MAX-NEXT: PF_X (0x1)
99 # CHECK-MAX-NEXT: ]
100 # CHECK-MAX-NEXT: Alignment: 65536
101 # CHECK-MAX-NEXT: }
102 # CHECK-MAX-NEXT: ProgramHeader {
103 # CHECK-MAX-NEXT: Type: PT_GNU_STACK (0x6474E551)
104 # CHECK-MAX-NEXT: Offset: 0x0
105 # CHECK-MAX-NEXT: VirtualAddress: 0x0
106 # CHECK-MAX-NEXT: PhysicalAddress: 0x0
107 # CHECK-MAX-NEXT: FileSize: 0
108 # CHECK-MAX-NEXT: MemSize: 0
109 # CHECK-MAX-NEXT: Flags [ (0x6)
110 # CHECK-MAX-NEXT: PF_R (0x4)
111 # CHECK-MAX-NEXT: PF_W (0x2)
112 # CHECK-MAX-NEXT: ]
113 # CHECK-MAX-NEXT: Alignment: 0
115 # Increase common-page-size to max-page-size. Expect to see a larger offset
116 # of the first Section after the executable loadable segment due to the higher
117 # alignment requirement.
119 # RUN: ld.lld -z max-page-size=0x10000 -z common-page-size=0x10000 %t -o %t3
120 # RUN: llvm-readobj --sections -l %t3 | FileCheck --check-prefix=CHECK-COMMON %s
122 # Check that we truncate common-page-size to max-page-size
124 # RUN: ld.lld -z max-page-size=0x10000 -z common-page-size=0x100000 %t -o %t4
125 # RUN: llvm-readobj --sections -l %t4 | FileCheck --check-prefix=CHECK-COMMON %s
127 # CHECK-COMMON: Sections [
128 # CHECK-COMMON-NEXT: Section {
129 # CHECK-COMMON-NEXT: Index: 0
130 # CHECK-COMMON-NEXT: Name: (0)
131 # CHECK-COMMON-NEXT: Type: SHT_NULL (0x0)
132 # CHECK-COMMON-NEXT: Flags [ (0x0)
133 # CHECK-COMMON-NEXT: ]
134 # CHECK-COMMON-NEXT: Address: 0x0
135 # CHECK-COMMON-NEXT: Offset: 0x0
136 # CHECK-COMMON-NEXT: Size: 0
137 # CHECK-COMMON-NEXT: Link: 0
138 # CHECK-COMMON-NEXT: Info: 0
139 # CHECK-COMMON-NEXT: AddressAlignment: 0
140 # CHECK-COMMON-NEXT: EntrySize: 0
141 # CHECK-COMMON-NEXT: }
142 # CHECK-COMMON-NEXT: Section {
143 # CHECK-COMMON-NEXT: Index: 1
144 # CHECK-COMMON-NEXT: Name: .text (1)
145 # CHECK-COMMON-NEXT: Type: SHT_PROGBITS (0x1)
146 # CHECK-COMMON-NEXT: Flags [ (0x6)
147 # CHECK-COMMON-NEXT: SHF_ALLOC (0x2)
148 # CHECK-COMMON-NEXT: SHF_EXECINSTR (0x4)
149 # CHECK-COMMON-NEXT: ]
150 # CHECK-COMMON-NEXT: Address: 0x210120
151 # CHECK-COMMON-NEXT: Offset: 0x120
152 # CHECK-COMMON-NEXT: Size: 1
153 # CHECK-COMMON-NEXT: Link: 0
154 # CHECK-COMMON-NEXT: Info: 0
155 # CHECK-COMMON-NEXT: AddressAlignment: 4
156 # CHECK-COMMON-NEXT: EntrySize: 0
157 # CHECK-COMMON-NEXT: }
158 # CHECK-COMMON-NEXT: Section {
159 # CHECK-COMMON-NEXT: Index: 2
160 # CHECK-COMMON-NEXT: Name: .comment (7)
161 # CHECK-COMMON-NEXT: Type: SHT_PROGBITS (0x1)
162 # CHECK-COMMON-NEXT: Flags [ (0x30)
163 # CHECK-COMMON-NEXT: SHF_MERGE (0x10)
164 # CHECK-COMMON-NEXT: SHF_STRINGS (0x20)
165 # CHECK-COMMON-NEXT: ]
166 # CHECK-COMMON-NEXT: Address: 0x0
167 # CHECK-COMMON-NEXT: Offset: 0x121
168 # CHECK-COMMON-NEXT: Size: 8
169 # CHECK-COMMON-NEXT: Link: 0
170 # CHECK-COMMON-NEXT: Info: 0
171 # CHECK-COMMON-NEXT: AddressAlignment: 1
172 # CHECK-COMMON-NEXT: EntrySize: 1
174 # CHECK-COMMON: ProgramHeaders [
175 # CHECK-COMMON-NEXT: ProgramHeader {
176 # CHECK-COMMON-NEXT: Type: PT_PHDR (0x6)
177 # CHECK-COMMON-NEXT: Offset: 0x40
178 # CHECK-COMMON-NEXT: VirtualAddress: 0x200040
179 # CHECK-COMMON-NEXT: PhysicalAddress: 0x200040
180 # CHECK-COMMON-NEXT: FileSize: 224
181 # CHECK-COMMON-NEXT: MemSize: 224
182 # CHECK-COMMON-NEXT: Flags [ (0x4)
183 # CHECK-COMMON-NEXT: PF_R (0x4)
184 # CHECK-COMMON-NEXT: ]
185 # CHECK-COMMON-NEXT: Alignment: 8
186 # CHECK-COMMON-NEXT: }
187 # CHECK-COMMON-NEXT: ProgramHeader {
188 # CHECK-COMMON-NEXT: Type: PT_LOAD (0x1)
189 # CHECK-COMMON-NEXT: Offset: 0x0
190 # CHECK-COMMON-NEXT: VirtualAddress: 0x200000
191 # CHECK-COMMON-NEXT: PhysicalAddress: 0x200000
192 # CHECK-COMMON-NEXT: FileSize: 288
193 # CHECK-COMMON-NEXT: MemSize: 288
194 # CHECK-COMMON-NEXT: Flags [ (0x4)
195 # CHECK-COMMON-NEXT: PF_R (0x4)
196 # CHECK-COMMON-NEXT: ]
197 # CHECK-COMMON-NEXT: Alignment: 65536
198 # CHECK-COMMON-NEXT: }
199 # CHECK-COMMON-NEXT: ProgramHeader {
200 # CHECK-COMMON-NEXT: Type: PT_LOAD (0x1)
201 # CHECK-COMMON-NEXT: Offset: 0x120
202 # CHECK-COMMON-NEXT: VirtualAddress: 0x210120
203 # CHECK-COMMON-NEXT: PhysicalAddress: 0x210120
204 # CHECK-COMMON-NEXT: FileSize: 1
205 # CHECK-COMMON-NEXT: MemSize: 1
206 # CHECK-COMMON-NEXT: Flags [ (0x5)
207 # CHECK-COMMON-NEXT: PF_R (0x4)
208 # CHECK-COMMON-NEXT: PF_X (0x1)
209 # CHECK-COMMON-NEXT: ]
210 # CHECK-COMMON-NEXT: Alignment: 65536
211 # CHECK-COMMON-NEXT: }
212 # CHECK-COMMON-NEXT: ProgramHeader {
213 # CHECK-COMMON-NEXT: Type: PT_GNU_STACK (0x6474E551)
214 # CHECK-COMMON-NEXT: Offset: 0x0
215 # CHECK-COMMON-NEXT: VirtualAddress: 0x0
216 # CHECK-COMMON-NEXT: PhysicalAddress: 0x0
217 # CHECK-COMMON-NEXT: FileSize: 0
218 # CHECK-COMMON-NEXT: MemSize: 0
219 # CHECK-COMMON-NEXT: Flags [ (0x6)
220 # CHECK-COMMON-NEXT: PF_R (0x4)
221 # CHECK-COMMON-NEXT: PF_W (0x2)
222 # CHECK-COMMON-NEXT: ]
223 # CHECK-COMMON-NEXT: Alignment: 0
225 # RUN: not ld.lld -z max-page-size=0x10001 -z common-page-size=0x1001 %t -o /dev/null 2>&1 | FileCheck %s --check-prefix=INVALID
227 # INVALID: error: max-page-size: value isn't a power of 2
228 # INVALID-NEXT: error: common-page-size: value isn't a power of 2