• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: riscv
2
3# RUN: llvm-mc -filetype=obj -triple=riscv32-unknown-elf -mattr=-relax %s -o %t.rv32.o
4# RUN: llvm-mc -filetype=obj -triple=riscv64-unknown-elf -mattr=-relax %s -o %t.rv64.o
5
6# RUN: ld.lld %t.rv32.o --defsym foo=_start+8 --defsym bar=_start -o %t.rv32
7# RUN: ld.lld %t.rv64.o --defsym foo=_start+8 --defsym bar=_start -o %t.rv64
8# RUN: llvm-objdump -d %t.rv32 | FileCheck %s
9# RUN: llvm-objdump -d %t.rv64 | FileCheck %s
10# CHECK:      97 00 00 00     auipc   ra, 0
11# CHECK-NEXT: e7 80 80 00     jalr    8(ra)
12# CHECK:      97 00 00 00     auipc   ra, 0
13# CHECK-NEXT: e7 80 80 ff     jalr    -8(ra)
14
15# RUN: ld.lld %t.rv32.o --defsym foo=_start+0x7ffff7ff --defsym bar=_start+8-0x80000800 -o %t.rv32.limits
16# RUN: ld.lld %t.rv64.o --defsym foo=_start+0x7ffff7ff --defsym bar=_start+8-0x80000800 -o %t.rv64.limits
17# RUN: llvm-objdump -d %t.rv32.limits | FileCheck --check-prefix=LIMITS %s
18# RUN: llvm-objdump -d %t.rv64.limits | FileCheck --check-prefix=LIMITS %s
19# LIMITS:      97 f0 ff 7f     auipc   ra, 524287
20# LIMITS-NEXT: e7 80 f0 7f     jalr    2047(ra)
21# LIMITS-NEXT: 97 00 00 80     auipc   ra, 524288
22# LIMITS-NEXT: e7 80 00 80     jalr    -2048(ra)
23
24# RUN: ld.lld %t.rv32.o --defsym foo=_start+0x7ffff800 --defsym bar=_start+8-0x80000801 -o %t
25# RUN: not ld.lld %t.rv64.o --defsym foo=_start+0x7ffff800 --defsym bar=_start+8-0x80000801 -o /dev/null 2>&1 | \
26# RUN:   FileCheck --check-prefix=ERROR %s
27# ERROR: relocation R_RISCV_CALL out of range: 524288 is not in [-524288, 524287]; references foo
28# ERROR: relocation R_RISCV_CALL out of range: -524289 is not in [-524288, 524287]; references bar
29
30.global _start
31_start:
32    call    foo
33    call    bar
34