125 lines · plain
1# RUN: llvm-mc -triple riscv32 -mattr=-relax -filetype obj %s \2# RUN: | llvm-objdump --no-print-imm-hex -M no-aliases -d -r - \3# RUN: | FileCheck --check-prefix NORELAX %s4# RUN: llvm-mc -triple riscv32 -mattr=+relax -filetype obj %s \5# RUN: | llvm-objdump --no-print-imm-hex -M no-aliases -d -r - \6# RUN: | FileCheck --check-prefix RELAX %s7# RUN: llvm-mc -triple riscv64 -mattr=-relax -filetype obj %s \8# RUN: | llvm-objdump --no-print-imm-hex -M no-aliases -d -r - \9# RUN: | FileCheck --check-prefix NORELAX %s10# RUN: llvm-mc -triple riscv64 -mattr=+relax -filetype obj %s \11# RUN: | llvm-objdump --no-print-imm-hex -M no-aliases -d -r - \12# RUN: | FileCheck --check-prefix RELAX %s13 14# Fixups for %pcrel_hi / %pcrel_lo can be evaluated within a section,15# regardless of the fragment containing the target address, provided symbol16# binding allows it.17 18function:19.Lpcrel_label1:20 auipc a0, %pcrel_hi(local_function)21 addi a1, a0, %pcrel_lo(.Lpcrel_label1)22# NORELAX: auipc a0, 023# NORELAX-NOT: R_RISCV24# NORELAX: addi a1, a0, 1625# NORELAX-NOT: R_RISCV26 27# RELAX: auipc a0, 028# RELAX: R_RISCV_PCREL_HI20 local_function29# RELAX: R_RISCV_RELAX *ABS*30# RELAX: addi a1, a0, 031# RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label132# RELAX: R_RISCV_RELAX *ABS*33 34 .p2align 2 # Cause a new fragment be emitted here35.Lpcrel_label2:36 auipc a0, %pcrel_hi(local_function)37 addi a1, a0, %pcrel_lo(.Lpcrel_label2)38# NORELAX: auipc a0, 039# NORELAX-NOT: R_RISCV40# NORELAX: addi a1, a0, 841# NORELAX-NOT: R_RISCV42 43# RELAX: auipc a0, 044# RELAX: R_RISCV_PCREL_HI20 local_function45# RELAX: R_RISCV_RELAX *ABS*46# RELAX: addi a1, a0, 047# RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label248# RELAX: R_RISCV_RELAX *ABS*49 50 .type local_function,@function51local_function:52 ret53 54# Check we correctly evaluate when fixups are in different fragments55 56.Lpcrel_label3:57 auipc a0, %pcrel_hi(local_function)58 .p2align 2 # Cause a new fragment be emitted here59 addi a1, a0, %pcrel_lo(.Lpcrel_label3)60# NORELAX: auipc a0, 061# NORELAX-NOT: R_RISCV62# NORELAX: addi a1, a0, -463# NORELAX-NOT: R_RISCV64 65# RELAX: auipc a0, 066# RELAX: R_RISCV_PCREL_HI20 local_function67# RELAX: R_RISCV_RELAX *ABS*68# RELAX: addi a1, a0, 069# RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label370# RELAX: R_RISCV_RELAX *ABS*71 72# Check handling of symbol binding.73 74.Lpcrel_label4:75 auipc a0, %pcrel_hi(global_function)76 addi a1, a0, %pcrel_lo(.Lpcrel_label4)77# NORELAX: auipc a0, 078# NORELAX: R_RISCV_PCREL_HI20 global_function79# NORELAX: addi a1, a0, 080# NORELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label481 82# RELAX: auipc a0, 083# RELAX: R_RISCV_PCREL_HI20 global_function84# RELAX: R_RISCV_RELAX *ABS*85# RELAX: addi a1, a0, 086# RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label487# RELAX: R_RISCV_RELAX *ABS*88 89.Lpcrel_label5:90 auipc a0, %pcrel_hi(weak_function)91 addi a1, a0, %pcrel_lo(.Lpcrel_label5)92# NORELAX: auipc a0, 093# NORELAX: R_RISCV_PCREL_HI20 weak_function94# NORELAX: addi a1, a0, 095# NORELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label596 97# RELAX: auipc a0, 098# RELAX: R_RISCV_PCREL_HI20 weak_function99# RELAX: R_RISCV_RELAX *ABS*100# RELAX: addi a1, a0, 0101# RELAX: R_RISCV_PCREL_LO12_I .Lpcrel_label5102# RELAX: R_RISCV_RELAX *ABS*103 104.Lpcrel_label6:105 auipc a0, %pcrel_hi(ifunc)106# NORELAX: auipc a0, 0107# NORELAX: R_RISCV_PCREL_HI20 ifunc108 109# RELAX: auipc a0, 0110# RELAX: R_RISCV_PCREL_HI20 ifunc111# RELAX: R_RISCV_RELAX *ABS*112 113 .global global_function114 .type global_function,@function115global_function:116 ret117 118 .weak weak_function119 .type weak_function,@function120weak_function:121 ret122 123.type ifunc, %gnu_indirect_function124.set ifunc, global_function125