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
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: 00000097 auipc ra, 0x0
11 # CHECK-NEXT: 008080e7 jalr 0x8(ra)
12 # CHECK: 00000097 auipc ra, 0x0
13 # CHECK-NEXT: ff8080e7 jalr -0x8(ra)
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: 7ffff097 auipc ra, 0x7ffff
20 # LIMITS-NEXT: 7ff080e7 jalr 0x7ff(ra)
21 # LIMITS-NEXT: 80000097 auipc ra, 0x80000
22 # LIMITS-NEXT: 800080e7 jalr -0x800(ra)
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_PLT out of range: 524288 is not in [-524288, 524287]; references 'foo'
28 # ERROR: relocation R_RISCV_CALL_PLT out of range: -524289 is not in [-524288, 524287]; references 'bar'