File: x86-64-tlsdesc-gd.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 (115 lines) | stat: -rw-r--r-- 3,707 bytes parent folder | download | duplicates (8)
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
106
107
108
109
110
111
112
113
114
115
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
# RUN: echo '.tbss; .globl c; c: .zero 4' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
# RUN: ld.lld -shared -soname=t1.so %t1.o -o %t1.so

# RUN: ld.lld -shared %t.o %t1.o -o %t.so
# RUN: llvm-readobj -r -x .got %t.so | FileCheck --check-prefix=GD-RELA %s
# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.so | FileCheck --check-prefix=GD %s

# RUN: ld.lld -shared %t.o %t1.o -o %t-rel.so -z rel
# RUN: llvm-readobj -r -x .got %t-rel.so | FileCheck --check-prefix=GD-REL %s

# RUN: ld.lld %t.o %t1.o -o %t
# RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s

# RUN: ld.lld %t.o %t1.so -o %t
# RUN: llvm-readobj -r %t | FileCheck --check-prefix=IE-REL %s
# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck --check-prefix=IE %s

# GD-RELA:      .rela.dyn {
# GD-RELA-NEXT:   0x23D0 R_X86_64_TLSDESC - 0xB
# GD-RELA-NEXT:   0x23B0 R_X86_64_TLSDESC a 0x0
# GD-RELA-NEXT:   0x23C0 R_X86_64_TLSDESC c 0x0
# GD-RELA-NEXT: }
# GD-RELA:      Hex dump of section '.got':
# GD-RELA-NEXT: 0x000023b0 00000000 00000000 00000000 00000000
# GD-RELA-NEXT: 0x000023c0 00000000 00000000 00000000 00000000
# GD-RELA-NEXT: 0x000023d0 00000000 00000000 00000000 00000000

# GD-REL:       .rel.dyn {
# GD-REL-NEXT:    0x23B8 R_X86_64_TLSDESC -
# GD-REL-NEXT:    0x2398 R_X86_64_TLSDESC a
# GD-REL-NEXT:    0x23A8 R_X86_64_TLSDESC c
# GD-REL-NEXT:  }
# GD-REL:       Hex dump of section '.got':
# GD-REL-NEXT:  0x00002398 00000000 00000000 00000000 00000000
# GD-REL-NEXT:  0x000023a8 00000000 00000000 00000000 00000000
# GD-REL-NEXT:  0x000023b8 00000000 00000000 0b000000 00000000

## &.rela.dyn[a]-pc = 0x23B0-0x12e7 = 4297
# GD:            leaq 4297(%rip), %rax
# GD-NEXT: 12e7: callq *(%rax)
# GD-NEXT:       movl %fs:(%rax), %eax

## &.rela.dyn[b]-pc = 0x23D0-0x12f3 = 4317
# GD-NEXT:       leaq 4317(%rip), %rcx
# GD-NEXT: 12f3: movq %rcx, %rax
# GD-NEXT:       callq *(%rax)
# GD-NEXT:       movl %fs:(%rax), %eax

## &.rela.dyn[c]-pc = 0x23C0-0x1302 = 4286
# GD-NEXT:       leaq 4286(%rip), %r15
# GD-NEXT: 1302: movq %r15, %rax
# GD-NEXT:       callq *(%rax)
# GD-NEXT:       movl %fs:(%rax), %eax

# NOREL: no relocations

## tpoff(a) = st_value(a) - tls_size = -8
# LE:      movq $-8, %rax
# LE-NEXT: nop
# LE-NEXT: movl %fs:(%rax), %eax
## tpoff(b) = st_value(b) - tls_size = -5
# LE:      movq $-5, %rcx
# LE-NEXT: movq %rcx, %rax
# LE-NEXT: nop
# LE-NEXT: movl %fs:(%rax), %eax
## tpoff(c) = st_value(c) - tls_size = -4
# LE:      movq $-4, %r15
# LE-NEXT: movq %r15, %rax
# LE-NEXT: nop
# LE-NEXT: movl %fs:(%rax), %eax

# IE-REL:      .rela.dyn {
# IE-REL-NEXT:   0x202378 R_X86_64_TPOFF64 c 0x0
# IE-REL-NEXT: }

## a is relaxed to use LE.
# IE:              movq $-4, %rax
# IE-NEXT:         nop
# IE-NEXT:         movl %fs:(%rax), %eax
# IE-NEXT:         movq $-1, %rcx
# IE-NEXT:         movq %rcx, %rax
# IE-NEXT:         nop
# IE-NEXT:         movl %fs:(%rax), %eax
## &.rela.dyn[c]-pc = 0x202378 - 0x2012aa = 4302
# IE-NEXT:         movq 4302(%rip), %r15
# IE-NEXT: 2012aa: movq %r15, %rax
# IE-NEXT:         nop
# IE-NEXT:         movl %fs:(%rax), %eax

leaq a@tlsdesc(%rip), %rax
call *a@tlscall(%rax)
movl %fs:(%rax), %eax

## leaq/call may not be adjacent:  https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665
## Test non-RAX registers as well.
leaq b@tlsdesc(%rip), %rcx
movq %rcx, %rax
call *b@tlscall(%rax)
movl %fs:(%rax), %eax

leaq c@tlsdesc(%rip), %r15
movq %r15, %rax
call *c@tlscall(%rax)
movl %fs:(%rax), %eax

.section .tbss
.globl a
.zero 8
a:
.zero 3
b:
.zero 1