3 ## Additionally test that (a) -no-pie/-pie have the same behavior
4 ## (b) --no-relax/--relax have the same behavior when R_RISCV_RELAX is suppressed.
5 # RUN: llvm-mc -filetype=obj -triple=riscv32 %s -o %t.32.o
6 # RUN: ld.lld --relax %t.32.o -o %t.32
7 # RUN: llvm-nm -p %t.32 | FileCheck --check-prefixes=NM %s
8 # RUN: llvm-objdump -d --no-show-raw-insn %t.32 | FileCheck --check-prefixes=LE %s
9 # RUN: ld.lld -pie --no-relax %t.32.o -o %t.32
10 # RUN: llvm-objdump -d --no-show-raw-insn %t.32 | FileCheck --check-prefixes=LE %s
12 # RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax %s -o %t.64.o
13 # RUN: ld.lld --no-relax %t.64.o -o %t.64
14 # RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefixes=LE %s
15 # RUN: ld.lld -pie --no-relax %t.64.o -o %t.64
16 # RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefixes=LE %s
17 # RUN: ld.lld %t.64.o -o %t.64.relax
18 # RUN: llvm-objdump -d --no-show-raw-insn %t.64.relax | FileCheck --check-prefixes=LE-RELAX %s
20 # RUN: not ld.lld -shared %t.32.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error:
22 # ERR: error: relocation R_RISCV_TPREL_HI20 against .LANCHOR0 cannot be used with -shared
23 # ERR: error: relocation R_RISCV_TPREL_LO12_I against .LANCHOR0 cannot be used with -shared
24 # ERR: error: relocation R_RISCV_TPREL_HI20 against a cannot be used with -shared
25 # ERR: error: relocation R_RISCV_TPREL_LO12_I against a cannot be used with -shared
26 # ERR: error: relocation R_RISCV_TPREL_HI20 against a cannot be used with -shared
27 # ERR: error: relocation R_RISCV_TPREL_LO12_S against a cannot be used with -shared
28 # ERR: error: relocation R_RISCV_TPREL_HI20 against a cannot be used with -shared
29 # ERR: error: relocation R_RISCV_TPREL_LO12_S against a cannot be used with -shared
31 # NM: {{0*}}00000008 b .LANCHOR0
32 # NM: {{0*}}00000800 B a
34 ## .LANCHOR0@tprel = 8
37 # LE-NEXT: add a1, a1, tp
38 # LE-NEXT: addi a1, a1, 8
40 # LE-NEXT: add a2, a2, tp
41 # LE-NEXT: addi a2, a2, 2044
43 # LE-NEXT: addi a0, a0, 1
44 # LE-NEXT: add a3, a3, tp
45 # LE-NEXT: addi a0, a0, 2
46 # LE-NEXT: sw a0, 2044(a3)
48 # LE-NEXT: add a4, a4, tp
49 # LE-NEXT: sw a0, -2048(a4)
53 # LE-RELAX-NEXT: addi a1, tp, 8
54 # LE-RELAX-NEXT: addi a2, tp, 2044
55 # LE-RELAX-NEXT: addi a0, a0, 1
56 # LE-RELAX-NEXT: addi a0, a0, 2
57 # LE-RELAX-NEXT: sw a0, 2044(tp)
58 # LE-RELAX-NEXT: lui a4, 1
59 # LE-RELAX-NEXT: add a4, a4, tp
60 # LE-RELAX-NEXT: sw a0, -2048(a4)
63 lui a1
, %tprel_hi
(.LANCHOR0)
64 add a1
, a1
, tp
, %tprel_add
(.LANCHOR0)
65 addi a1
, a1
, %tprel_lo
(.LANCHOR0)
67 ## hi20(a-4) = hi20(0x7fc) = 0. relaxable
68 lui a2
, %tprel_hi
(a-
4)
69 add a2
, a2
, tp
, %tprel_add
(a-
4)
70 addi a2
, a2
, %tprel_lo
(a-
4)
72 ## hi20(a-4) = hi20(0x7fc) = 0. relaxable
73 ## Test non-adjacent instructions.
74 lui a3
, %tprel_hi
(a-
4)
76 add a3
, a3
, tp
, %tprel_add
(a-
4)
78 sw a0
, %tprel_lo
(a-
4)(a3
)
80 ## hi20(a) = hi20(0x800) = 1. not relaxable
82 add a4
, a4
, tp
, %tprel_add
(a)
83 sw a0
, %tprel_lo
(a)(a4
)