2 ## Test that we can handle --emit-relocs while relaxing.
4 # RUN: rm -rf %t && mkdir %t && cd %t
6 # RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+relax %s -o 32.o
7 # RUN: ld.lld -Ttext=0x10000 --emit-relocs 32.o -o 32
8 # RUN: llvm-objdump -dr --no-show-raw-insn -M no-aliases 32 | FileCheck %s
10 # RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax %s -o 64.o
11 # RUN: ld.lld -Ttext=0x10000 --emit-relocs 64.o -o 64
12 # RUN: llvm-objdump -dr --no-show-raw-insn -M no-aliases 64 | FileCheck %s
14 ## -r should keep original relocations.
15 # RUN: ld.lld -r 64.o -o 64.r
16 # RUN: llvm-objdump -dr --no-show-raw-insn -M no-aliases 64.r | FileCheck %s --check-prefix=CHECKR
18 ## --no-relax should keep original relocations.
19 # RUN: ld.lld --emit-relocs --no-relax 64.o -o 64.norelax
20 # RUN: llvm-objdump -dr --no-show-raw-insn -M no-aliases 64.norelax | FileCheck %s --check-prefix=CHECKNORELAX
23 # CHECK-NEXT: jal ra, 0x10008 <f>
24 # CHECK-NEXT: R_RISCV_JAL f
25 # CHECK-NEXT: R_RISCV_RELAX *ABS*
26 # CHECK-NEXT: jal ra, 0x10008 <f>
27 # CHECK-NEXT: R_RISCV_JAL f
28 # CHECK-NEXT: R_RISCV_RELAX *ABS*
31 # CHECK-NEXT: jalr zero, 0(ra)
32 # CHECK-NEXT: R_RISCV_ALIGN *ABS*+0x4
35 # CHECKR-NEXT: auipc ra, 0
36 # CHECKR-NEXT: R_RISCV_CALL_PLT f
37 # CHECKR-NEXT: R_RISCV_RELAX *ABS*
38 # CHECKR-NEXT: jalr ra, 0(ra)
39 # CHECKR-NEXT: auipc ra, 0
40 # CHECKR-NEXT: R_RISCV_CALL_PLT f
41 # CHECKR-NEXT: R_RISCV_RELAX *ABS*
42 # CHECKR-NEXT: jalr ra, 0(ra)
43 # CHECKR-NEXT: addi zero, zero, 0
44 # CHECKR-NEXT: R_RISCV_ALIGN *ABS*+0x4
47 # CHECKR-NEXT: jalr zero, 0(ra)
49 # CHECKNORELAX: <_start>:
50 # CHECKNORELAX-NEXT: auipc ra, 0
51 # CHECKNORELAX-NEXT: R_RISCV_CALL_PLT f
52 # CHECKNORELAX-NEXT: R_RISCV_RELAX *ABS*
53 # CHECKNORELAX-NEXT: jalr ra, 16(ra)
54 # CHECKNORELAX-NEXT: auipc ra, 0
55 # CHECKNORELAX-NEXT: R_RISCV_CALL_PLT f
56 # CHECKNORELAX-NEXT: R_RISCV_RELAX *ABS*
57 # CHECKNORELAX-NEXT: jalr ra, 8(ra)
59 # CHECKNORELAX-NEXT: <f>:
60 # CHECKNORELAX-NEXT: jalr zero, 0(ra)
61 # CHECKNORELAX-NEXT: R_RISCV_ALIGN *ABS*+0x4