[ELF] Make section member orders consistent
[llvm-project.git] / lld / test / ELF / tls.s
blob4f50e9d29c030f4cc1a692d59b7f700016291316
1 // REQUIRES: x86
2 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3 // RUN: ld.lld %t -o %tout
4 // RUN: llvm-readobj -S -l --symbols %tout | FileCheck %s
5 // RUN: llvm-objdump --no-print-imm-hex -d %tout | FileCheck %s --check-prefix=DIS
7 /// Reject local-exec TLS relocations for -shared, regardless of the preemptibility.
8 // RUN: not ld.lld -shared %t -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR
9 // RUN: not ld.lld -shared -Bsymbolic %t -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR
11 // ERR: error: relocation R_X86_64_TPOFF32 against a cannot be used with -shared
12 // ERR-NEXT: defined in {{.*}}
13 // ERR-NEXT: referenced by {{.*}}:(.text+0x4)
14 // ERR-EMPTY:
15 // ERR-NEXT: error: relocation R_X86_64_TPOFF32 against b cannot be used with -shared
16 // ERR-NEXT: defined in {{.*}}
17 // ERR-NEXT: referenced by {{.*}}:(.text+0xC)
18 // ERR-EMPTY:
19 // ERR-NEXT: error: relocation R_X86_64_TPOFF32 against c cannot be used with -shared
20 // ERR-NEXT: defined in {{.*}}
21 // ERR-NEXT: referenced by {{.*}}:(.text+0x14)
22 // ERR-EMPTY:
23 // ERR-NEXT: error: relocation R_X86_64_TPOFF32 against d cannot be used with -shared
24 // ERR-NEXT: defined in {{.*}}
25 // ERR-NEXT: referenced by {{.*}}:(.text+0x1C)
27 .global _start
28 _start:
29 movl %fs:a@tpoff, %eax
30 movl %fs:b@tpoff, %eax
31 movl %fs:c@tpoff, %eax
32 movl %fs:d@tpoff, %eax
34 .global a
35 .section .tbss,"awT",@nobits
37 .long 0
39 .global b
40 .section .tdata,"awT",@progbits
42 .long 1
44 .global c
45 .section .thread_bss,"awT",@nobits
47 .long 0
49 .global d
50 .section .thread_data,"awT",@progbits
52 .long 2
54 // CHECK: Name: .tdata
55 // CHECK-NEXT: Type: SHT_PROGBITS
56 // CHECK-NEXT: Flags [
57 // CHECK-NEXT: SHF_ALLOC
58 // CHECK-NEXT: SHF_TLS
59 // CHECK-NEXT: SHF_WRITE
60 // CHECK-NEXT: ]
61 // CHECK-NEXT: Address: [[TDATA_ADDR:0x.*]]
62 // CHECK-NEXT: Offset:
63 // CHECK-NEXT: Size: 4
64 // CHECK-NEXT: Link:
65 // CHECK-NEXT: Info:
66 // CHECK-NEXT: AddressAlignment:
67 // CHECK-NEXT: EntrySize:
68 // CHECK-NEXT: }
69 // CHECK-NEXT: Section {
70 // CHECK-NEXT: Index:
71 // CHECK-NEXT: Name: .thread_data
72 // CHECK-NEXT: Type: SHT_PROGBITS
73 // CHECK-NEXT: Flags [
74 // CHECK-NEXT: SHF_ALLOC
75 // CHECK-NEXT: SHF_TLS
76 // CHECK-NEXT: SHF_WRITE
77 // CHECK-NEXT: ]
78 // CHECK-NEXT: Address:
79 // CHECK-NEXT: Offset:
80 // CHECK-NEXT: Size: 4
81 // CHECK-NEXT: Link:
82 // CHECK-NEXT: Info:
83 // CHECK-NEXT: AddressAlignment:
84 // CHECK-NEXT: EntrySize:
85 // CHECK-NEXT: }
86 // CHECK-NEXT: Section {
87 // CHECK-NEXT: Index:
88 // CHECK-NEXT: Name: .tbss
89 // CHECK-NEXT: Type: SHT_NOBITS
90 // CHECK-NEXT: Flags [
91 // CHECK-NEXT: SHF_ALLOC
92 // CHECK-NEXT: SHF_TLS
93 // CHECK-NEXT: SHF_WRITE
94 // CHECK-NEXT: ]
95 // CHECK-NEXT: Address: [[TBSS_ADDR:0x.*]]
96 // CHECK-NEXT: Offset:
97 // CHECK-NEXT: Size: 4
98 // CHECK-NEXT: Link:
99 // CHECK-NEXT: Info:
100 // CHECK-NEXT: AddressAlignment:
101 // CHECK-NEXT: EntrySize:
102 // CHECK-NEXT: }
103 // CHECK-NEXT: Section {
104 // CHECK-NEXT: Index:
105 // CHECK-NEXT: Name: .thread_bss
106 // CHECK-NEXT: Type: SHT_NOBITS
107 // CHECK-NEXT: Flags [
108 // CHECK-NEXT: SHF_ALLOC
109 // CHECK-NEXT: SHF_TLS
110 // CHECK-NEXT: SHF_WRITE
111 // CHECK-NEXT: ]
113 // 0x2021F4 = TBSS_ADDR + 4
115 // CHECK-NEXT: Address: 0x2021F4
116 // CHECK-NEXT: Offset:
117 // CHECK-NEXT: Size: 4
118 // CHECK-NEXT: Link:
119 // CHECK-NEXT: Info:
120 // CHECK-NEXT: AddressAlignment:
121 // CHECK-NEXT: EntrySize:
122 // CHECK-NEXT: }
124 // CHECK: ProgramHeaders [
125 // CHECK: Type: PT_LOAD
126 // CHECK: Type: PT_LOAD
127 // CHECK: Type: PT_LOAD
128 // CHECK: FileSize: 8
129 // CHECK-NEXT: MemSize: [[#]]
130 // CHECK-NEXT: Flags [
131 // CHECK-NEXT: PF_R
132 // CHECK-NEXT: PF_W
133 // CHECK-NEXT: ]
134 // CHECK: Type: PT_TLS
135 // CHECK-NEXT: Offset:
136 // CHECK-NEXT: VirtualAddress: [[TDATA_ADDR]]
137 // CHECK-NEXT: PhysicalAddress: [[TDATA_ADDR]]
138 // CHECK-NEXT: FileSize: 8
139 // CHECK-NEXT: MemSize: 16
140 // CHECK-NEXT: Flags [
141 // CHECK-NEXT: PF_R
142 // CHECK-NEXT: ]
143 // CHECK-NEXT: Alignment:
144 // CHECK-NEXT: }
146 // CHECK: Symbols [
147 // CHECK: Name: a
148 // CHECK-NEXT: Value: 0x8
149 // CHECK-NEXT: Size:
150 // CHECK-NEXT: Binding: Global
151 // CHECK-NEXT: Type: TLS
152 // CHECK-NEXT: Other: 0
153 // CHECK-NEXT: Section: .tbss
154 // CHECK-NEXT: }
155 // CHECK-NEXT: Symbol {
156 // CHECK-NEXT: Name: b
157 // CHECK-NEXT: Value: 0x0
158 // CHECK-NEXT: Size:
159 // CHECK-NEXT: Binding: Global
160 // CHECK-NEXT: Type: TLS
161 // CHECK-NEXT: Other: 0
162 // CHECK-NEXT: Section: .tdata
163 // CHECK-NEXT: }
164 // CHECK-NEXT: Symbol {
165 // CHECK-NEXT: Name: c
166 // CHECK-NEXT: Value: 0xC
167 // CHECK-NEXT: Size:
168 // CHECK-NEXT: Binding: Global
169 // CHECK-NEXT: Type: TLS
170 // CHECK-NEXT: Other: 0
171 // CHECK-NEXT: Section: .thread_bss
172 // CHECK-NEXT: }
173 // CHECK-NEXT: Symbol {
174 // CHECK-NEXT: Name: d
175 // CHECK-NEXT: Value: 0x4
176 // CHECK-NEXT: Size:
177 // CHECK-NEXT: Binding: Global
178 // CHECK-NEXT: Type: TLS
179 // CHECK-NEXT: Other: 0
180 // CHECK-NEXT: Section: .thread_data
181 // CHECK-NEXT: }
183 // DIS: Disassembly of section .text:
184 // DIS-EMPTY:
185 // DIS-NEXT: <_start>:
186 // DIS-NEXT: movl %fs:-8, %eax
187 // DIS-NEXT: movl %fs:-16, %eax
188 // DIS-NEXT: movl %fs:-4, %eax
189 // DIS-NEXT: movl %fs:-12, %eax