|
| 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 |
| 13 | + |
| 14 | +# Fixups for %pcrel_hi / %pcrel_lo can be evaluated within a section, |
| 15 | +# regardless of the fragment containing the target address. |
| 16 | + |
| 17 | +function: |
| 18 | +.Lpcrel_label1: |
| 19 | + auipc a0, %pcrel_hi(other_function) |
| 20 | + addi a1, a0, %pcrel_lo(.Lpcrel_label1) |
| 21 | +# NORELAX: auipc a0, 0 |
| 22 | +# NORELAX-NOT: R_RISCV |
| 23 | +# NORELAX: addi a1, a0, 16 |
| 24 | +# NORELAX-NOT: R_RISCV |
| 25 | + |
| 26 | +# RELAX: auipc a0, 0 |
| 27 | +# RELAX: R_RISCV_PCREL_HI20 other_function |
| 28 | +# RELAX: R_RISCV_RELAX *ABS* |
| 29 | +# RELAX: addi a1, a0, 0 |
| 30 | +# RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label1 |
| 31 | +# RELAX: R_RISCV_RELAX *ABS* |
| 32 | + |
| 33 | + .p2align 2 # Cause a new fragment be emitted here |
| 34 | +.Lpcrel_label2: |
| 35 | + auipc a0, %pcrel_hi(other_function) |
| 36 | + addi a1, a0, %pcrel_lo(.Lpcrel_label2) |
| 37 | +# NORELAX: auipc a0, 0 |
| 38 | +# NORELAX-NOT: R_RISCV |
| 39 | +# NORELAX: addi a1, a0, 8 |
| 40 | +# NORELAX-NOT: R_RISCV |
| 41 | + |
| 42 | +# RELAX: auipc a0, 0 |
| 43 | +# RELAX: R_RISCV_PCREL_HI20 other_function |
| 44 | +# RELAX: R_RISCV_RELAX *ABS* |
| 45 | +# RELAX: addi a1, a0, 0 |
| 46 | +# RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label2 |
| 47 | +# RELAX: R_RISCV_RELAX *ABS* |
| 48 | + |
| 49 | + .type other_function,@function |
| 50 | +other_function: |
| 51 | + ret |
| 52 | + |
0 commit comments