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=0 --defsym bar=42 -o %t.rv32
7 # RUN: ld.lld %t.rv64.o --defsym foo=0 --defsym bar=42 -o %t.rv64
8 # RUN: llvm-objdump -d %t.rv32 | FileCheck %s
9 # RUN: llvm-objdump -d %t.rv64 | FileCheck %s
10 # CHECK: 00000537 lui a0, 0x0
11 # CHECK-NEXT: 00050513 mv a0, a0
12 # CHECK-NEXT: 00a52023 sw a0, 0x0(a0)
13 # CHECK-NEXT: 000005b7 lui a1, 0x0
14 # CHECK-NEXT: 02a58593 addi a1, a1, 0x2a
15 # CHECK-NEXT: 02b5a523 sw a1, 0x2a(a1)
17 # RUN: ld.lld %t.rv32.o --defsym foo=0x7ffff7ff --defsym bar=0x7ffff800 -o %t.rv32.limits
18 # RUN: ld.lld %t.rv64.o --defsym foo=0x7ffff7ff --defsym bar=0xffffffff7ffff800 -o %t.rv64.limits
19 # RUN: llvm-objdump -d %t.rv32.limits | FileCheck --check-prefix=LIMITS %s
20 # RUN: llvm-objdump -d %t.rv64.limits | FileCheck --check-prefix=LIMITS %s
21 # LIMITS: 7ffff537 lui a0, 0x7ffff
22 # LIMITS-NEXT: 7ff50513 addi a0, a0, 0x7ff
23 # LIMITS-NEXT: 7ea52fa3 sw a0, 0x7ff(a0)
24 # LIMITS-NEXT: 800005b7 lui a1, 0x80000
25 # LIMITS-NEXT: 80058593 addi a1, a1, -0x800
26 # LIMITS-NEXT: 80b5a023 sw a1, -0x800(a1)
28 # RUN: not ld.lld %t.rv64.o --defsym foo=0x7ffff800 --defsym bar=0xffffffff7ffff7ff -o /dev/null 2>&1 | FileCheck --check-prefix ERROR %s
29 # ERROR: relocation R_RISCV_HI20 out of range: 524288 is not in [-524288, 524287]; references 'foo'
30 # ERROR: relocation R_RISCV_HI20 out of range: -524289 is not in [-524288, 524287]; references 'bar'