3 # RUN: llvm-mc -filetype=obj -triple=riscv32 %s -o %t.32.o
5 # RUN: ld.lld -shared %t.32.o -o %t.32.so
6 # RUN: llvm-readobj -r -d %t.32.so | FileCheck --check-prefix=IE32-REL %s
7 # RUN: llvm-objdump -d --no-show-raw-insn %t.32.so | FileCheck --check-prefixes=IE,IE32 %s
9 # RUN: ld.lld %t.32.o -o %t.32
10 # RUN: llvm-readelf -r %t.32 | FileCheck --check-prefix=NOREL %s
11 # RUN: llvm-readelf -x .got %t.32 | FileCheck --check-prefix=LE32-GOT %s
12 # RUN: llvm-objdump -d --no-show-raw-insn %t.32 | FileCheck --check-prefixes=LE,LE32 %s
14 # RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t.64.o
16 # RUN: ld.lld -shared %t.64.o -o %t.64.so
17 # RUN: llvm-readobj -r -d %t.64.so | FileCheck --check-prefix=IE64-REL %s
18 # RUN: llvm-objdump -d --no-show-raw-insn %t.64.so | FileCheck --check-prefixes=IE,IE64 %s
20 # RUN: ld.lld %t.64.o -o %t.64
21 # RUN: llvm-readelf -r %t.64 | FileCheck --check-prefix=NOREL %s
22 # RUN: llvm-readelf -x .got %t.64 | FileCheck --check-prefix=LE64-GOT %s
23 # RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefixes=LE,LE64 %s
25 # IE32-REL: FLAGS STATIC_TLS
26 # IE32-REL: .rela.dyn {
27 # IE32-REL-NEXT: 0x221C R_RISCV_TLS_TPREL32 - 0xC
28 # IE32-REL-NEXT: 0x2218 R_RISCV_TLS_TPREL32 a 0x0
31 # IE64-REL: FLAGS STATIC_TLS
32 # IE64-REL: .rela.dyn {
33 # IE64-REL-NEXT: 0x2378 R_RISCV_TLS_TPREL64 - 0xC
34 # IE64-REL-NEXT: 0x2370 R_RISCV_TLS_TPREL64 a 0x0
37 ## rv32: &.got[0] - . = 0x2218 - . = 4096*1+116
38 ## rv64: &.got[0] - . = 0x2378 - . = 4096*1+208
40 # IE32-NEXT: lw a4, 0x74(a4)
41 # IE64-NEXT: ld a4, 0xd0(a4)
42 # IE-NEXT: add a4, a4, tp
43 ## rv32: &.got[1] - . = 0x221c - . = 4096*1+108
44 ## rv64: &.got[1] - . = 0x2378 - . = 4096*1+204
46 # IE32-NEXT: lw a5, 0x6c(a5)
47 # IE64-NEXT: ld a5, 0xcc(a5)
48 # IE-NEXT: add a5, a5, tp
50 # NOREL: no relocations
52 # a@tprel = st_value(a) = 0x8
53 # b@tprel = st_value(a) = 0xc
54 # LE32-GOT: section '.got':
55 # LE32-GOT-NEXT: 0x0001212c 00000000 08000000 0c000000
56 # LE64-GOT: section '.got':
57 # LE64-GOT-NEXT: 0x000121e0 00000000 00000000 08000000 00000000
58 # LE64-GOT-NEXT: 0x000121f0 0c000000 00000000
60 ## rv32: &.got[0] - . = 0x12130 - 0x11114 = 4096*1+28
61 ## rv64: &.got[0] - . = 0x121e8 - 0x111c8 = 4096*1+32
62 # LE32: 11114: auipc a4, 0x1
63 # LE32-NEXT: lw a4, 0x1c(a4)
64 # LE64: 111c8: auipc a4, 0x1
65 # LE64-NEXT: ld a4, 0x20(a4)
66 # LE-NEXT: add a4, a4, tp
67 ## rv32: &.got[1] - . = 0x12134 - 0x11120 = 4096*1+20
68 ## rv64: &.got[1] - . = 0x121f0 - 0x111d4 = 4096*1+28
69 # LE32: 11120: auipc a5, 0x1
70 # LE32-NEXT: lw a5, 0x14(a5)
71 # LE64: 111d4: auipc a5, 0x1
72 # LE64-NEXT: ld a5, 0x1c(a5)
73 # LE-NEXT: add a5, a5, tp