1 # RUN: llvm-mc -triple riscv32 -mattr=-relax -filetype obj %s \
2 # RUN: | llvm-objdump -M no-aliases -d -r - \
3 # RUN: | FileCheck --check-prefix NORELAX %s
4 # RUN: llvm-mc -triple riscv32 -mattr=+relax -filetype obj %s \
5 # RUN: | llvm-objdump -M no-aliases -d -r - \
6 # RUN: | FileCheck --check-prefix RELAX %s
7 # RUN: llvm-mc -triple riscv64 -mattr=-relax -filetype obj %s \
8 # RUN: | llvm-objdump -M no-aliases -d -r - \
9 # RUN: | FileCheck --check-prefix NORELAX %s
10 # RUN: llvm-mc -triple riscv64 -mattr=+relax -filetype obj %s \
11 # RUN: | llvm-objdump -M no-aliases -d -r - \
12 # RUN: | FileCheck --check-prefix RELAX %s
14 # Fixups for %pcrel_hi / %pcrel_lo can be evaluated within a section,
15 # regardless of the fragment containing the target address, provided symbol
20 auipc a0
, %pcrel_hi
(local_function
)
21 addi a1
, a0
, %pcrel_lo
(.Lpcrel_label1)
22 # NORELAX: auipc a0, 0
23 # NORELAX-NOT: R_RISCV
24 # NORELAX: addi a1, a0, 16
25 # NORELAX-NOT: R_RISCV
28 # RELAX: R_RISCV_PCREL_HI20 local_function
29 # RELAX: R_RISCV_RELAX *ABS*
30 # RELAX: addi a1, a0, 0
31 # RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label1
32 # RELAX: R_RISCV_RELAX *ABS*
34 .p2align 2 # Cause a new fragment be emitted here
36 auipc a0
, %pcrel_hi
(local_function
)
37 addi a1
, a0
, %pcrel_lo
(.Lpcrel_label2)
38 # NORELAX: auipc a0, 0
39 # NORELAX-NOT: R_RISCV
40 # NORELAX: addi a1, a0, 8
41 # NORELAX-NOT: R_RISCV
44 # RELAX: R_RISCV_PCREL_HI20 local_function
45 # RELAX: R_RISCV_RELAX *ABS*
46 # RELAX: addi a1, a0, 0
47 # RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label2
48 # RELAX: R_RISCV_RELAX *ABS*
50 .type local_function,@function
54 # Check we correctly evaluate when fixups are in different fragments
57 auipc a0
, %pcrel_hi
(local_function
)
58 .p2align 2 # Cause a new fragment be emitted here
59 addi a1
, a0
, %pcrel_lo
(.Lpcrel_label3)
60 # NORELAX: auipc a0, 0
61 # NORELAX-NOT: R_RISCV
62 # NORELAX: addi a1, a0, -4
63 # NORELAX-NOT: R_RISCV
66 # RELAX: R_RISCV_PCREL_HI20 local_function
67 # RELAX: R_RISCV_RELAX *ABS*
68 # RELAX: addi a1, a0, 0
69 # RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label3
70 # RELAX: R_RISCV_RELAX *ABS*
72 # Check handling of symbol binding.
75 auipc a0
, %pcrel_hi
(global_function
)
76 addi a1
, a0
, %pcrel_lo
(.Lpcrel_label4)
77 # NORELAX: auipc a0, 0
78 # NORELAX: R_RISCV_PCREL_HI20 global_function
79 # NORELAX: addi a1, a0, 0
80 # NORELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label4
83 # RELAX: R_RISCV_PCREL_HI20 global_function
84 # RELAX: R_RISCV_RELAX *ABS*
85 # RELAX: addi a1, a0, 0
86 # RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label4
87 # RELAX: R_RISCV_RELAX *ABS*
90 auipc a0
, %pcrel_hi
(weak_function
)
91 addi a1
, a0
, %pcrel_lo
(.Lpcrel_label5)
92 # NORELAX: auipc a0, 0
93 # NORELAX: R_RISCV_PCREL_HI20 weak_function
94 # NORELAX: addi a1, a0, 0
95 # NORELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label5
98 # RELAX: R_RISCV_PCREL_HI20 weak_function
99 # RELAX: R_RISCV_RELAX *ABS*
100 # RELAX: addi a1, a0, 0
101 # RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label5
102 # RELAX: R_RISCV_RELAX *ABS*
104 .global global_function
105 .type global_function,@function
110 .type weak_function,@function