[ELF] Make SyntheticSection parameter order match InputSection
[llvm-project.git] / lld / test / ELF / mips-tls.s
blobb98f3bb53d18dfdb3a36d16a02394ee790d1d3b9
1 # REQUIRES: mips
2 # Check MIPS TLS relocations handling.
4 # RUN: llvm-mc -filetype=obj -triple=mips-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=mips-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: 00000000 l .tdata 00000000 loc
30 # DIS: 00000000 *UND* 00000000 foo
31 # DIS: 00000004 g .tdata 00000000 bar
33 # DIS: Contents of section .got:
34 # DIS-NEXT: 30000 00000000 80000000 00000000 ffff9000
35 # DIS-NEXT: 30010 ffff9004 00000000 00000000 00000001
36 # DIS-NEXT: 30020 00000000 00000001 ffff8004
38 # DIS: <__start>:
39 # DIS-NEXT: addiu $2, $3, -32732
40 # DIS-NEXT: addiu $2, $3, -32744
41 # DIS-NEXT: addiu $2, $3, -32724
42 # DIS-NEXT: addiu $2, $3, -32740
43 # DIS-NEXT: addiu $2, $3, -32716
44 # DIS-NEXT: addiu $2, $3, -32736
46 # CHECK: Relocations [
47 # CHECK-NEXT: Section (7) .rel.dyn {
48 # CHECK-NEXT: 0x30008 R_MIPS_TLS_TPREL32 foo
49 # CHECK-NEXT: 0x30014 R_MIPS_TLS_DTPMOD32 foo
50 # CHECK-NEXT: 0x30018 R_MIPS_TLS_DTPREL32 foo
51 # CHECK-NEXT: }
52 # CHECK-NEXT: ]
53 # CHECK: Primary GOT {
54 # CHECK-NEXT: Canonical gp value: 0x37FF0
55 # CHECK-NEXT: Reserved entries [
56 # CHECK: ]
57 # CHECK-NEXT: Local entries [
58 # CHECK-NEXT: ]
59 # CHECK-NEXT: Global entries [
60 # CHECK-NEXT: ]
61 # CHECK-NEXT: Number of TLS and multi-GOT entries: 9
62 # ^-- -32744 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 foo
63 # ^-- -32740 R_MIPS_TLS_GOTTPREL VA - 0x7000 loc
64 # ^-- -32736 R_MIPS_TLS_GOTTPREL VA - 0x7000 bar
65 # ^-- -32732 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 foo
66 # ^-- -32728 R_MIPS_TLS_DTPREL32 foo
67 # ^-- -32724 R_MIPS_TLS_LDM 1 loc
68 # ^-- -32720 0 loc
69 # ^-- -32716 R_MIPS_TLS_GD 1 bar
70 # ^-- -32712 VA - 0x8000 bar
72 # DIS-SO: Contents of section .got:
73 # DIS-SO-NEXT: 30000 00000000 80000000 00000000 00000000
74 # DIS-SO-NEXT: 30010 00000004 00000000 00000000 00000000
75 # DIS-SO-NEXT: 30020 00000000 00000000 00000000
77 # SO: Relocations [
78 # SO-NEXT: Section (7) .rel.dyn {
79 # SO-NEXT: 0x3000C R_MIPS_TLS_TPREL32 -
80 # SO-NEXT: 0x3001C R_MIPS_TLS_DTPMOD32 -
81 # SO-NEXT: 0x30008 R_MIPS_TLS_TPREL32 foo
82 # SO-NEXT: 0x30014 R_MIPS_TLS_DTPMOD32 foo
83 # SO-NEXT: 0x30018 R_MIPS_TLS_DTPREL32 foo
84 # SO-NEXT: 0x30010 R_MIPS_TLS_TPREL32 bar
85 # SO-NEXT: 0x30024 R_MIPS_TLS_DTPMOD32 bar
86 # SO-NEXT: 0x30028 R_MIPS_TLS_DTPREL32 bar
87 # SO-NEXT: }
88 # SO-NEXT: ]
89 # SO: Primary GOT {
90 # SO-NEXT: Canonical gp value: 0x37FF0
91 # SO-NEXT: Reserved entries [
92 # SO: ]
93 # SO-NEXT: Local entries [
94 # SO-NEXT: ]
95 # SO-NEXT: Global entries [
96 # SO-NEXT: ]
97 # SO-NEXT: Number of TLS and multi-GOT entries: 9
98 # ^-- -32744 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 foo
99 # ^-- -32740 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 loc
100 # ^-- -32736 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 bar
101 # ^-- -32732 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 foo
102 # ^-- -32728 R_MIPS_TLS_DTPREL32 foo
103 # ^-- -32724 R_MIPS_TLS_LDM R_MIPS_TLS_DTPMOD32 loc
104 # ^-- -32720 0 loc
105 # ^-- -32716 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 bar
106 # ^-- -32712 R_MIPS_TLS_DTPREL32 bar
108 .text
109 .global __start
110 __start:
111 addiu $2, $3, %tlsgd(foo) # R_MIPS_TLS_GD
112 addiu $2, $3, %gottprel(foo) # R_MIPS_TLS_GOTTPREL
113 addiu $2, $3, %tlsldm(loc) # R_MIPS_TLS_LDM
114 addiu $2, $3, %gottprel(loc) # R_MIPS_TLS_GOTTPREL
115 addiu $2, $3, %tlsgd(bar) # R_MIPS_TLS_GD
116 addiu $2, $3, %gottprel(bar) # R_MIPS_TLS_GOTTPREL
118 .section .tdata,"awT",%progbits
119 .global bar
120 loc:
121 .word 0
122 bar:
123 .word 0