2 ## Test that we can handle R_RISCV_ALIGN.
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 32.o -o 32
8 # RUN: llvm-objdump -td --no-show-raw-insn -M no-aliases 32 | FileCheck %s
9 ## R_RISCV_ALIGN is handled regarldess of --no-relax.
10 # RUN: ld.lld -Ttext=0x10000 --no-relax 32.o -o 32.norelax
11 # RUN: llvm-objdump -td --no-show-raw-insn -M no-aliases 32.norelax | FileCheck %s
13 # RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax %s -o 64.o
14 # RUN: ld.lld -Ttext=0x10000 64.o -o 64
15 # RUN: llvm-objdump -td --no-show-raw-insn -M no-aliases 64 | FileCheck %s
16 # RUN: ld.lld -Ttext=0x10000 --no-relax 64.o -o 64.norelax
17 # RUN: llvm-objdump -td --no-show-raw-insn -M no-aliases 64.norelax | FileCheck %s
19 # RUN: ld.lld -Ttext=0x10000 --gc-sections 64.o -o 64.gc
20 # RUN: llvm-objdump -td --no-show-raw-insn -M no-aliases 64.gc | FileCheck %s --check-prefix=GC
22 ## -r keeps section contents unchanged.
23 # RUN: ld.lld -r 64.o -o 64.r
24 # RUN: llvm-objdump -dr --no-show-raw-insn -M no-aliases 64.r | FileCheck %s --check-prefix=CHECKR
26 # CHECK-DAG: 00010004 l .text {{0*}}1c a
27 # CHECK-DAG: 00010008 l .text {{0*}}28 b
28 # CHECK-DAG: 00010014 l .text {{0*}}20 c
29 # CHECK-DAG: 00010000 g .text {{0*}}38 _start
32 # CHECK-NEXT: addi a0, a0, 1
35 # CHECK-NEXT: addi a0, a0, 2
38 # CHECK-NEXT: addi zero, zero, 0
39 # CHECK-NEXT: addi zero, zero, 0
40 # CHECK-NEXT: 10010: addi a0, a0, 3
43 # CHECK-NEXT: addi a0, a0, 4
44 # CHECK-NEXT: addi a0, a0, 5
45 # CHECK-NEXT: addi zero, zero, 0
46 # CHECK-NEXT: 10020: addi a0, a0, 6
47 # CHECK-NEXT: addi a0, a0, 7
48 # CHECK-NEXT: addi zero, zero, 0
49 # CHECK-NEXT: addi zero, zero, 0
50 # CHECK-NEXT: 10030: addi a0, a0, 8
51 # CHECK-NEXT: addi a0, a0, 9
54 # CHECK-NEXT: addi a0, a0, 1
57 # CHECK-NEXT: 10044: addi a0, a0, 2
58 # CHECK-NEXT: addi zero, zero, 0
59 # CHECK-NEXT: addi zero, zero, 0
60 # CHECK-NEXT: addi zero, zero, 0
61 # CHECK-NEXT: addi zero, zero, 0
62 # CHECK-NEXT: addi zero, zero, 0
63 # CHECK-NEXT: addi zero, zero, 0
64 # CHECK-NEXT: 10060: addi a0, a0, 3
67 ## _start-0x10070 = 0x10000-0x10070 = -112
69 # CHECK-NEXT: 10070: auipc a0, 0
70 # CHECK-NEXT: addi a0, a0, -112
71 # CHECK-NEXT: addi zero, zero, 0
72 # CHECK-NEXT: addi zero, zero, 0
73 # CHECK-NEXT: auipc a0, 0
74 # CHECK-NEXT: addi a0, a0, -112
77 # GC-DAG: 00010004 l .text {{0*}}1c a
78 # GC-DAG: 00010008 l .text {{0*}}28 b
79 # GC-DAG: 00010014 l .text {{0*}}20 c
80 # GC-DAG: 00010000 g .text {{0*}}38 _start
85 # CHECKR-NEXT: addi a0, a0, 1
88 # CHECKR-NEXT: addi a0, a0, 2
91 # CHECKR-NEXT: addi zero, zero, 0
92 # CHECKR-NEXT: 0000000000000008: R_RISCV_ALIGN *ABS*+0xc
93 # CHECKR-NEXT: addi zero, zero, 0
94 # CHECKR-NEXT: addi zero, zero, 0
95 # CHECKR-NEXT: addi a0, a0, 3
98 # CHECKR-NEXT: addi a0, a0, 4
99 # CHECKR-NEXT: addi a0, a0, 5
100 # CHECKR-NEXT: addi zero, zero, 0
101 # CHECKR-NEXT: 0000000000000020: R_RISCV_ALIGN *ABS*+0x1c
102 # CHECKR-NEXT: addi zero, zero, 0
103 # CHECKR-NEXT: addi zero, zero, 0
104 # CHECKR-NEXT: addi zero, zero, 0
105 # CHECKR-NEXT: addi zero, zero, 0
106 # CHECKR-NEXT: addi zero, zero, 0
107 # CHECKR-NEXT: addi zero, zero, 0
108 # CHECKR-NEXT: addi a0, a0, 6
109 # CHECKR-NEXT: addi a0, a0, 7
110 # CHECKR-NEXT: addi zero, zero, 0
111 # CHECKR-NEXT: 0000000000000044: R_RISCV_ALIGN *ABS*+0xc
112 # CHECKR-NEXT: addi zero, zero, 0
113 # CHECKR-NEXT: addi zero, zero, 0
114 # CHECKR-NEXT: addi a0, a0, 8
115 # CHECKR-NEXT: addi a0, a0, 9
137 .size _start, . - _start
139 ## Test another text section.
140 .section .text2,"ax",@progbits
153 ## Test that matching HI20 can be found despite deleted bytes.
154 .section .pcrel,"ax",@progbits
156 auipc a0
, %pcrel_hi
(_start
)
157 addi a0
, a0
, %pcrel_lo
(.L1)
160 auipc a0
, %pcrel_hi
(_start
)
161 addi a0
, a0
, %pcrel_lo
(.L1)