[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / i386-tls-dynamic.s
blobd61ee5526bb11848c89612ce9e8a6631e6519754
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=i686 %s -o %t.o
3 # RUN: ld.lld -shared %t.o -o %t.so
4 # RUN: llvm-readobj --sections -r %t.so | FileCheck %s
5 # RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck %s --check-prefix=DIS
7 .type tls0,@object
8 .section .tbss,"awT",@nobits
9 .globl tls0
10 .align 4
11 tls0:
12 .long 0
13 .size tls0, 4
15 .type tls1,@object
16 .globl tls1
17 .align 4
18 tls1:
19 .long 0
20 .size tls1, 4
22 .type tls2,@object
23 .globl tls2
24 .hidden tls2
25 .align 4
26 tls2:
27 .long 0
28 .size tls2, 8
30 .section .text
31 .globl _start
32 _start:
33 leal tls0@tlsgd(,%ebx,1),%eax
34 call __tls_get_addr@plt
36 leal tls1@tlsgd(,%ebx,1),%eax
37 call __tls_get_addr@plt
39 leal tls2@tlsldm(%ebx),%eax
40 call __tls_get_addr@plt
41 leal tls2@dtpoff(%eax),%edx
43 leal tls2@tlsldm(%ebx),%eax
44 call __tls_get_addr@plt
45 leal tls2@dtpoff+4(%eax),%edx
47 movl %gs:0,%eax
48 addl tls0@gotntpoff(%ebx),%eax
50 movl %gs:0,%eax
51 addl tls1@gotntpoff(%ebx),%eax
53 # CHECK: Name: .got (
54 # CHECK-NEXT: Type: SHT_PROGBITS
55 # CHECK-NEXT: Flags [
56 # CHECK-NEXT: SHF_ALLOC
57 # CHECK-NEXT: SHF_WRITE
58 # CHECK-NEXT: ]
59 # CHECK-NEXT: Address: 0x2358
60 # CHECK-NEXT: Offset: 0x358
61 # CHECK-NEXT: Size: 32
62 # CHECK-NEXT: Link: 0
63 # CHECK-NEXT: Info: 0
64 # CHECK-NEXT: AddressAlignment: 4
65 # CHECK-NEXT: EntrySize: 0
67 # CHECK: Relocations [
68 # CHECK: Section ({{.+}}) .rel.dyn {
69 # CHECK-NEXT: 0x2370 R_386_TLS_DTPMOD32 -
70 # CHECK-NEXT: 0x2358 R_386_TLS_DTPMOD32 tls0
71 # CHECK-NEXT: 0x235C R_386_TLS_DTPOFF32 tls0
72 # CHECK-NEXT: 0x2360 R_386_TLS_TPOFF tls0
73 # CHECK-NEXT: 0x2364 R_386_TLS_DTPMOD32 tls1
74 # CHECK-NEXT: 0x2368 R_386_TLS_DTPOFF32 tls1
75 # CHECK-NEXT: 0x236C R_386_TLS_TPOFF tls1
76 # CHECK-NEXT: }
78 # DIS: Disassembly of section .text:
79 # DIS-EMPTY:
80 # DIS-NEXT: <_start>:
81 ## General dynamic model:
82 ## -4128 and -4116 are first and second GOT entries offsets.
83 ## Each one is a pair of records.
84 # DIS-NEXT: 1260: leal -4128(,%ebx), %eax
85 # DIS-NEXT: 1267: calll 0x12d0
86 # DIS-NEXT: 126c: leal -4116(,%ebx), %eax
87 # DIS-NEXT: 1273: calll 0x12d0
88 ## Local dynamic model:
89 ## -16 is a local module tls index offset.
90 # DIS-NEXT: 1278: leal -4104(%ebx), %eax
91 # DIS-NEXT: 127e: calll 0x12d0
92 # DIS-NEXT: 1283: leal 8(%eax), %edx
93 # DIS-NEXT: 1289: leal -4104(%ebx), %eax
94 # DIS-NEXT: 128f: calll 0x12d0
95 # DIS-NEXT: 1294: leal 12(%eax), %edx
96 ## Initial exec model:
97 # DIS-NEXT: 129a: movl %gs:0, %eax
98 # DIS-NEXT: 12a0: addl -4120(%ebx), %eax
99 # DIS-NEXT: 12a6: movl %gs:0, %eax
100 # DIS-NEXT: 12ac: addl -4108(%ebx), %eax