aboutsummaryrefslogtreecommitdiff
path: root/test/ELF/mips-tls-64.s
blob: 39459cf2efac1e90bffe02b4d48869a2fe1d71f1 (plain) (blame)
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
# Check MIPS TLS 64-bit relocations handling.

# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
# RUN:         %p/Inputs/mips-tls.s -o %t.so.o
# RUN: ld.lld -shared %t.so.o -o %t.so
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o

# RUN: ld.lld %t.o %t.so -o %t.exe
# RUN: llvm-objdump -d -s -t %t.exe | FileCheck -check-prefix=DIS %s
# RUN: llvm-readobj -r -mips-plt-got %t.exe | FileCheck %s

# RUN: ld.lld -shared %t.o %t.so -o %t-out.so
# RUN: llvm-objdump -d -s -t %t-out.so | FileCheck -check-prefix=DIS-SO %s
# RUN: llvm-readobj -r -mips-plt-got %t-out.so | FileCheck -check-prefix=SO %s

# REQUIRES: mips

# DIS:      __start:
# DIS-NEXT:    20000:   24 62 80 20   addiu   $2, $3, -32736
# DIS-NEXT:    20004:   24 62 80 30   addiu   $2, $3, -32720
# DIS-NEXT:    20008:   24 62 80 38   addiu   $2, $3, -32712
# DIS-NEXT:    2000c:   24 62 80 48   addiu   $2, $3, -32696
# DIS-NEXT:    20010:   24 62 80 58   addiu   $2, $3, -32680

# DIS:      Contents of section .got:
# DIS-NEXT:  40008 00000000 00000000 80000000 00000000
# DIS-NEXT:  40018 00000000 00000000 00000000 00000000
# DIS-NEXT:  40028 00000000 00000000 00000000 00000001
# DIS-NEXT:  40038 00000000 00000000 00000000 00000001
# DIS-NEXT:  40048 ffffffff ffff8004 ffffffff ffff9004

# DIS: 0000000000040000 l       .tdata          00000000 .tdata
# DIS: 0000000000040000 l       .tdata          00000000 loc
# DIS: 0000000000000004 g       .tdata          00000000 bar
# DIS: 0000000000000000 g       *UND*           00000000 foo

# CHECK:      Relocations [
# CHECK-NEXT:   Section (7) .rela.dyn {
# CHECK-NEXT:     0x40018 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# CHECK-NEXT:     0x40020 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# CHECK-NEXT:     0x40028 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# CHECK-NEXT:   }
# CHECK-NEXT: ]
# CHECK-NEXT: Primary GOT {
# CHECK-NEXT:   Canonical gp value: 0x47FF8
# CHECK-NEXT:   Reserved entries [
# CHECK:        ]
# CHECK-NEXT:   Local entries [
# CHECK-NEXT:   ]
# CHECK-NEXT:   Global entries [
# CHECK-NEXT:   ]
# CHECK-NEXT:   Number of TLS and multi-GOT entries: 8
#               ^-- -32736 R_MIPS_TLS_GD       R_MIPS_TLS_DTPMOD64 foo
#               ^-- -32728                     R_MIPS_TLS_DTPREL64 foo
#               ^-- -32720 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64  foo
#               ^-- -32712 R_MIPS_TLS_LDM      1 loc
#               ^-- -32704                     0 loc
#               ^-- -32696 R_MIPS_TLS_GD       1 bar
#               ^-- -32688                     VA - 0x8000 bar
#               ^-- -32680 R_MIPS_TLS_GOTTPREL VA - 0x7000 bar

# DIS-SO:      Contents of section .got:
# DIS-SO-NEXT:  20008 00000000 00000000 80000000 00000000
# DIS-SO-NEXT:  20018 00000000 00000000 00000000 00000000
# DIS-SO-NEXT:  20028 00000000 00000000 00000000 00000000
# DIS-SO-NEXT:  20038 00000000 00000000 00000000 00000000
# DIS-SO-NEXT:  20048 00000000 00000000 00000000 00000000

# SO:      Relocations [
# SO-NEXT:   Section (7) .rela.dyn {
# SO-NEXT:     0x20030 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE - 0x0
# SO-NEXT:     0x20040 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
# SO-NEXT:     0x20048 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
# SO-NEXT:     0x20050 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
# SO-NEXT:     0x20018 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# SO-NEXT:     0x20020 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# SO-NEXT:     0x20028 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# SO-NEXT:   }
# SO-NEXT: ]
# SO-NEXT: Primary GOT {
# SO-NEXT:   Canonical gp value: 0x27FF8
# SO-NEXT:   Reserved entries [
# SO:        ]
# SO-NEXT:   Local entries [
# SO-NEXT:   ]
# SO-NEXT:   Global entries [
# SO-NEXT:   ]
# SO-NEXT:   Number of TLS and multi-GOT entries: 8
#            ^-- 0x20018 R_MIPS_TLS_GD       R_MIPS_TLS_DTPMOD64 foo
#            ^-- 0x20020                     R_MIPS_TLS_DTPREL64 foo
#            ^-- 0x20028 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64  foo
#            ^-- 0x20030 R_MIPS_TLS_LDM      R_MIPS_TLS_DTPMOD64 loc
#            ^-- 0x20038                     0 loc
#            ^-- 0x20040 R_MIPS_TLS_GD       R_MIPS_TLS_DTPMOD64 bar
#            ^-- 0x20048                     R_MIPS_TLS_DTPREL64 bar
#            ^-- 0x20050 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64  bar

  .text
  .global  __start
__start:
  addiu $2, $3, %tlsgd(foo)     # R_MIPS_TLS_GD
  addiu $2, $3, %gottprel(foo)  # R_MIPS_TLS_GOTTPREL
  addiu $2, $3, %tlsldm(loc)    # R_MIPS_TLS_LDM
  addiu $2, $3, %tlsgd(bar)     # R_MIPS_TLS_GD
  addiu $2, $3, %gottprel(bar)  # R_MIPS_TLS_GOTTPREL

 .section .tdata,"awT",%progbits
 .global bar
loc:
 .word 0
bar:
 .word 0