[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / i386-tlsdesc-gd.s
blob132febed2feb9a42804e708895c82c3bebeb8de5
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=i386 %s -o %t.o
3 # RUN: echo '.tbss; .globl c; c: .zero 4' | llvm-mc -filetype=obj -triple=i386 - -o %t1.o
4 # RUN: ld.lld -shared -soname=t1.so %t1.o -o %t1.so
6 # RUN: ld.lld -shared -z now %t.o %t1.o -o %t.so
7 # RUN: llvm-readobj -r -x .got %t.so | FileCheck --check-prefix=GD-REL %s
8 # RUN: llvm-objdump -h -d --no-show-raw-insn %t.so | FileCheck --check-prefix=GD %s
10 # RUN: ld.lld -shared -z now %t.o %t1.o -o %t-rela.so -z rela
11 # RUN: llvm-readobj -r -x .got %t-rela.so | FileCheck --check-prefix=GD-RELA %s
13 # RUN: ld.lld -z now %t.o %t1.o -o %t
14 # RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
15 # RUN: llvm-objdump -h -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
17 # RUN: ld.lld -z now %t.o %t1.so -o %t
18 # RUN: llvm-readobj -r %t | FileCheck --check-prefix=IE-REL %s
19 # RUN: llvm-objdump -h -d --no-show-raw-insn %t | FileCheck --check-prefix=IE %s
21 # GD-REL: .rel.dyn {
22 # GD-REL-NEXT: 0x2258 R_386_TLS_DESC -
23 # GD-REL-NEXT: 0x2248 R_386_TLS_DESC a
24 # GD-REL-NEXT: 0x2250 R_386_TLS_DESC c
25 # GD-REL-NEXT: }
26 # GD-REL: Hex dump of section '.got':
27 # GD-REL-NEXT: 0x00002248 00000000 00000000 00000000 00000000
28 # GD-REL-NEXT: 0x00002258 00000000 0b000000
30 # GD-RELA: .rela.dyn {
31 # GD-RELA-NEXT: 0x2264 R_386_TLS_DESC - 0xB
32 # GD-RELA-NEXT: 0x2254 R_386_TLS_DESC a 0x0
33 # GD-RELA-NEXT: 0x225C R_386_TLS_DESC c 0x0
34 # GD-RELA-NEXT: }
35 # GD-RELA: Hex dump of section '.got':
36 # GD-RELA-NEXT: 0x00002254 00000000 00000000 00000000 00000000
37 # GD-RELA-NEXT: 0x00002264 00000000 00000000
39 # GD: .got 00000018 00002248
40 # GD: .got.plt 0000000c 00002260
42 # &.rel.dyn[a]-.got.plt = 0x2248-0x2260 = -24
43 # GD: leal -24(%ebx), %eax
44 # GD-NEXT: calll *(%eax)
45 # GD-NEXT: movl %gs:(%eax), %eax
47 # &.rel.dyn[b]-.got.plt = 0x2258-0x2260 = -8
48 # GD-NEXT: leal -8(%ebx), %eax
49 # GD-NEXT: movl %edx, %ebx
50 # GD-NEXT: calll *(%eax)
51 # GD-NEXT: movl %gs:(%eax), %eax
53 # &.rel.dyn[c]-.got.plt = 0x2250-0x2260 = -16
54 # GD-NEXT: leal -16(%ebx), %eax
55 # GD-NEXT: calll *(%eax)
56 # GD-NEXT: movl %gs:(%eax), %eax
58 # NOREL: no relocations
60 ## st_value(a) - tls_size = -8
61 # LE: leal -8, %eax
62 # LE-NEXT: nop
63 # LE-NEXT: movl %gs:(%eax), %eax
64 ## st_value(b) - tls_size = -5
65 # LE: leal -5, %eax
66 # LE-NEXT: movl %edx, %ebx
67 # LE-NEXT: nop
68 # LE-NEXT: movl %gs:(%eax), %eax
69 ## st_value(c) - tls_size = -4
70 # LE: leal -4, %eax
71 # LE-NEXT: nop
72 # LE-NEXT: movl %gs:(%eax), %eax
74 # IE-REL: .rel.dyn {
75 # IE-REL-NEXT: 0x40222C R_386_TLS_TPOFF c
76 # IE-REL-NEXT: }
78 # IE: .got 00000004 0040222c
79 # IE: .got.plt 0000000c 00402230
81 ## a and b are relaxed to use LE.
82 # IE: leal -4, %eax
83 # IE-NEXT: nop
84 # IE-NEXT: movl %gs:(%eax), %eax
85 # IE-NEXT: leal -1, %eax
86 # IE-NEXT: movl %edx, %ebx
87 # IE-NEXT: nop
88 # IE-NEXT: movl %gs:(%eax), %eax
89 ## &.got[a]-.got.plt = 0x2220 - 0x2224 = -4
90 # IE-NEXT: movl -4(%ebx), %eax
91 # IE-NEXT: nop
92 # IE-NEXT: movl %gs:(%eax), %eax
94 leal a@tlsdesc(%ebx), %eax
95 call *a@tlscall(%eax)
96 movl %gs:(%eax), %eax
98 leal b@tlsdesc(%ebx), %eax
99 movl %edx, %ebx # GCC -O0 may add an extra insn in between.
100 call *b@tlscall(%eax)
101 movl %gs:(%eax), %eax
103 leal c@tlsdesc(%ebx), %eax
104 call *c@tlscall(%eax)
105 movl %gs:(%eax), %eax
107 .section .tbss
108 .globl a
109 .zero 8
111 .zero 3
113 .zero 1