[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / lld / test / ELF / riscv-jal.s
blob2129e445470661297c1de7f08b18609c8b47b494
1 # REQUIRES: riscv
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+4 --defsym bar=_start -o %t.rv32
7 # RUN: ld.lld %t.rv64.o --defsym foo=_start+4 --defsym bar=_start -o %t.rv64
8 # RUN: llvm-objdump -d %t.rv32 | FileCheck %s --check-prefix=CHECK-32
9 # RUN: llvm-objdump -d %t.rv64 | FileCheck %s --check-prefix=CHECK-64
10 # CHECK-32: 0040006f j 0x110b8
11 # CHECK-32: ffdff0ef jal 0x110b4
12 # CHECK-64: 0040006f j 0x11124
13 # CHECK-64: ffdff0ef jal 0x11120
15 # RUN: ld.lld %t.rv32.o --defsym foo=_start+0xffffe --defsym bar=_start+4-0x100000 -o %t.rv32.limits
16 # RUN: ld.lld %t.rv64.o --defsym foo=_start+0xffffe --defsym bar=_start+4-0x100000 -o %t.rv64.limits
17 # RUN: llvm-objdump -d %t.rv32.limits | FileCheck --check-prefix=LIMITS-32 %s
18 # RUN: llvm-objdump -d %t.rv64.limits | FileCheck --check-prefix=LIMITS-64 %s
19 # LIMITS-32: 7ffff06f j 0x1110b2
20 # LIMITS-32-NEXT: 800000ef jal 0xfff110b8
21 # LIMITS-64: 7ffff06f j 0x11111e
22 # LIMITS-64-NEXT: 800000ef jal 0xfffffffffff11124
24 # RUN: not ld.lld %t.rv32.o --defsym foo=_start+0x100000 --defsym bar=_start+4-0x100002 -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR-RANGE %s
25 # RUN: not ld.lld %t.rv64.o --defsym foo=_start+0x100000 --defsym bar=_start+4-0x100002 -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR-RANGE %s
26 # ERROR-RANGE: relocation R_RISCV_JAL out of range: 1048576 is not in [-1048576, 1048575]; references 'foo'
27 # ERROR-RANGE: relocation R_RISCV_JAL out of range: -1048578 is not in [-1048576, 1048575]; references 'bar'
29 # RUN: not ld.lld %t.rv32.o --defsym foo=_start+1 --defsym bar=_start+4+3 -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR-ALIGN %s
30 # RUN: not ld.lld %t.rv64.o --defsym foo=_start+1 --defsym bar=_start+4+3 -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR-ALIGN %s
31 # ERROR-ALIGN: improper alignment for relocation R_RISCV_JAL: 0x1 is not aligned to 2 bytes
32 # ERROR-ALIGN: improper alignment for relocation R_RISCV_JAL: 0x3 is not aligned to 2 bytes
34 .global _start
36 _start:
37 jal x0, foo
38 jal x1, bar