xref: /llvm-project/lld/test/ELF/riscv-relax-call-intra-sec.s (revision 6b1d151fe3dc530195d8802f1ecc247c8235dd3a)
1# REQUIRES: riscv
2## Test R_RISCV_CALL referencing the current input section with the displacement
3## close to the boundary.
4
5# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c,+relax %s -o %t.o
6# RUN: ld.lld -Ttext=0x10000 %t.o -o %t
7# RUN: llvm-objdump -d --no-show-raw-insn -M no-aliases %t | FileCheck %s
8
9# CHECK-LABEL:  <_start>:
10# CHECK-NEXT:             jal    ra, {{.*}} <_start>
11# CHECK-NEXT:             jal    ra, {{.*}} <_start>
12# CHECK-EMPTY:
13# CHECK-NEXT:   <a>:
14# CHECK-NEXT:             c.jr   ra
15
16# CHECK-LABEL:  <b>:
17# CHECK:                  jal    zero, {{.*}} <a>
18# CHECK-NEXT:             jal    zero, {{.*}} <c>
19# CHECK-NEXT:             c.j    {{.*}} <c>
20
21# CHECK-LABEL:  <c>:
22# CHECK-NEXT:             c.jr   ra
23
24#--- a.s
25.global _start
26_start:
27  call _start
28  call _start
29
30a:
31  ret
32b:
33  .space 2048
34## Relaxed to jal. If we don't compute the precise value of a, we may consider
35## a reachable by c.j.
36  tail a
37## Relaxed to jal. c.j is unreachable.
38  tail c      # c.j
39## Relaxed to c.j. If we don't compute the precise value of c, we may consider
40## c.j unreachable.
41  tail c      # c.j
42  .space 2042
43c:
44  ret
45