[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / lld / test / ELF / mips-tls-64.s
blob3976b50274be4ef8420f07b33cd0c1dde929c8e9
1 # REQUIRES: mips
2 # Check MIPS TLS 64-bit relocations handling.
4 # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
5 # RUN: %p/Inputs/mips-tls.s -o %t.so.o
6 # RUN: ld.lld -shared %t.so.o -soname=t.so -o %t.so
7 # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o
9 # RUN: echo "SECTIONS { \
10 # RUN: . = 0x10000; .text : { *(.text) } \
11 # RUN: . = 0x30000; .got : { *(.got) } \
12 # RUN: }" > %t.script
14 # RUN: ld.lld %t.o %t.so -script %t.script -o %t.exe
15 # RUN: llvm-objdump --no-print-imm-hex -d -s -t --no-show-raw-insn %t.exe \
16 # RUN: | FileCheck -check-prefix=DIS %s
17 # RUN: llvm-readobj -r -A %t.exe | FileCheck %s
19 # RUN: ld.lld -pie %t.o %t.so -script %t.script -o %t.pie
20 # RUN: llvm-objdump --no-print-imm-hex -d -s -t --no-show-raw-insn %t.pie \
21 # RUN: | FileCheck -check-prefix=DIS %s
22 # RUN: llvm-readobj -r -A %t.pie | FileCheck %s
24 # RUN: ld.lld -shared %t.o %t.so -script %t.script -o %t-out.so
25 # RUN: llvm-objdump --no-print-imm-hex -d -s -t --no-show-raw-insn %t-out.so \
26 # RUN: | FileCheck -check-prefix=DIS-SO %s
27 # RUN: llvm-readobj -r -A %t-out.so | FileCheck -check-prefix=SO %s
29 # DIS: 0000000000000000 l .tdata 0000000000000000 loc
30 # DIS: 0000000000000000 *UND* 0000000000000000 foo
31 # DIS: 0000000000000004 g .tdata 0000000000000000 bar
33 # DIS: Contents of section .got:
34 # DIS-NEXT: 30000 00000000 00000000 80000000 00000000
35 # DIS-NEXT: 30010 00000000 00000000 ffffffff ffff9000
36 # DIS-NEXT: 30020 ffffffff ffff9004 00000000 00000000
37 # DIS-NEXT: 30030 00000000 00000000 00000000 00000001
38 # DIS-NEXT: 30040 00000000 00000000 00000000 00000001
39 # DIS-NEXT: 30050 ffffffff ffff8004
41 # DIS: <__start>:
42 # DIS-NEXT: addiu $2, $3, -32712
43 # DIS-NEXT: addiu $2, $3, -32736
44 # DIS-NEXT: addiu $2, $3, -32696
45 # DIS-NEXT: addiu $2, $3, -32728
46 # DIS-NEXT: addiu $2, $3, -32680
47 # DIS-NEXT: addiu $2, $3, -32720
49 # CHECK: Relocations [
50 # CHECK-NEXT: Section (7) .rel.dyn {
51 # CHECK-NEXT: 0x30010 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo
52 # CHECK-NEXT: 0x30028 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo
53 # CHECK-NEXT: 0x30030 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo
54 # CHECK-NEXT: }
55 # CHECK-NEXT: ]
56 # CHECK: Primary GOT {
57 # CHECK-NEXT: Canonical gp value: 0x37FF0
58 # CHECK-NEXT: Reserved entries [
59 # CHECK: ]
60 # CHECK-NEXT: Local entries [
61 # CHECK-NEXT: ]
62 # CHECK-NEXT: Global entries [
63 # CHECK-NEXT: ]
64 # CHECK-NEXT: Number of TLS and multi-GOT entries: 9
65 # ^-- -32736 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64 foo
66 # ^-- -32728 R_MIPS_TLS_GOTTPREL VA - 0x7000 loc
67 # ^-- -32720 R_MIPS_TLS_GOTTPREL VA - 0x7000 bar
68 # ^-- -32712 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD64 foo
69 # ^-- -32704 R_MIPS_TLS_DTPREL64 foo
70 # ^-- -32696 R_MIPS_TLS_LDM 1 loc
71 # ^-- -32688 0 loc
72 # ^-- -32680 R_MIPS_TLS_GD 1 bar
73 # ^-- -32672 VA - 0x8000 bar
75 # DIS-SO: Contents of section .got:
76 # DIS-SO-NEXT: 30000 00000000 00000000 80000000 00000000
77 # DIS-SO-NEXT: 30010 00000000 00000000 00000000 00000000
78 # DIS-SO-NEXT: 30020 00000000 00000004 00000000 00000000
79 # DIS-SO-NEXT: 30030 00000000 00000000 00000000 00000000
80 # DIS-SO-NEXT: 30040 00000000 00000000 00000000 00000000
81 # DIS-SO-NEXT: 30050 00000000 00000000
83 # SO: Relocations [
84 # SO-NEXT: Section (7) .rel.dyn {
85 # SO-NEXT: 0x30018 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE -
86 # SO-NEXT: 0x30038 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE -
87 # SO-NEXT: 0x30010 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo
88 # SO-NEXT: 0x30028 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo
89 # SO-NEXT: 0x30030 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo
90 # SO-NEXT: 0x30020 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE bar
91 # SO-NEXT: 0x30048 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE bar
92 # SO-NEXT: 0x30050 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE bar
93 # SO-NEXT: }
94 # SO-NEXT: ]
95 # SO: Primary GOT {
96 # SO-NEXT: Canonical gp value: 0x37FF0
97 # SO-NEXT: Reserved entries [
98 # SO: ]
99 # SO-NEXT: Local entries [
100 # SO-NEXT: ]
101 # SO-NEXT: Global entries [
102 # SO-NEXT: ]
103 # SO-NEXT: Number of TLS and multi-GOT entries: 9
104 # ^-- -32736 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64 foo
105 # ^-- -32728 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64 loc
106 # ^-- -32720 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64 bar
107 # ^-- -32712 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD64 foo
108 # ^-- -32704 R_MIPS_TLS_DTPREL64 foo
109 # ^-- -32696 R_MIPS_TLS_LDM R_MIPS_TLS_DTPMOD64 loc
110 # ^-- -32688 0 loc
111 # ^-- -32680 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD64 bar
112 # ^-- -32672 R_MIPS_TLS_DTPREL64 bar
114 .text
115 .global __start
116 __start:
117 addiu $2, $3, %tlsgd(foo) # R_MIPS_TLS_GD
118 addiu $2, $3, %gottprel(foo) # R_MIPS_TLS_GOTTPREL
119 addiu $2, $3, %tlsldm(loc) # R_MIPS_TLS_LDM
120 addiu $2, $3, %gottprel(loc) # R_MIPS_TLS_GOTTPREL
121 addiu $2, $3, %tlsgd(bar) # R_MIPS_TLS_GD
122 addiu $2, $3, %gottprel(bar) # R_MIPS_TLS_GOTTPREL
124 .section .tdata,"awT",%progbits
125 .global bar
126 loc:
127 .word 0
128 bar:
129 .word 0