brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.6 KiB · 6b0685b Raw
146 lines · plain
1# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+relax < %s \2# RUN:     | llvm-readobj -r - | FileCheck -check-prefix=RELAX-RELOC %s3# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=-relax < %s \4# RUN:     | llvm-readobj -r - | FileCheck -check-prefix=NORELAX-RELOC %s5# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+relax < %s \6# RUN:     | llvm-readobj -r - | FileCheck -check-prefix=RELAX-RELOC %s7# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=-relax < %s \8# RUN:     | llvm-readobj -r - | FileCheck -check-prefix=NORELAX-RELOC %s9 10.long foo11 12call foo13# NORELAX-RELOC: R_RISCV_CALL_PLT foo 0x014# NORELAX-RELOC-NOT: R_RISCV_RELAX15# RELAX-RELOC: R_RISCV_CALL_PLT foo 0x016# RELAX-RELOC: R_RISCV_RELAX - 0x017 18lui t1, %hi(foo)19# NORELAX-RELOC: R_RISCV_HI20 foo 0x020# NORELAX-RELOC-NOT: R_RISCV_RELAX21# RELAX-RELOC: R_RISCV_HI20 foo 0x022# RELAX-RELOC: R_RISCV_RELAX - 0x023 24addi t1, t1, %lo(foo)25# NORELAX-RELOC: R_RISCV_LO12_I foo 0x026# NORELAX-RELOC-NOT: R_RISCV_RELAX27# RELAX-RELOC: R_RISCV_LO12_I foo 0x028# RELAX-RELOC: R_RISCV_RELAX - 0x029 30sb t1, %lo(foo)(a2)31# NORELAX-RELOC: R_RISCV_LO12_S foo 0x032# NORELAX-RELOC-NOT: R_RISCV_RELAX33# RELAX-RELOC: R_RISCV_LO12_S foo 0x034# RELAX-RELOC: R_RISCV_RELAX - 0x035 361:37auipc t1, %pcrel_hi(foo)38# NORELAX-RELOC: R_RISCV_PCREL_HI20 foo 0x039# NORELAX-RELOC-NOT: R_RISCV_RELAX40# RELAX-RELOC: R_RISCV_PCREL_HI20 foo 0x041# RELAX-RELOC: R_RISCV_RELAX - 0x042 43addi t1, t1, %pcrel_lo(1b)44# NORELAX-RELOC: R_RISCV_PCREL_LO12_I .Ltmp0 0x045# NORELAX-RELOC-NOT: R_RISCV_RELAX46# RELAX-RELOC: R_RISCV_PCREL_LO12_I .Ltmp0 0x047# RELAX-RELOC: R_RISCV_RELAX - 0x048 49sb t1, %pcrel_lo(1b)(a2)50# NORELAX-RELOC: R_RISCV_PCREL_LO12_S .Ltmp0 0x051# NORELAX-RELOC-NOT: R_RISCV_RELAX52# RELAX-RELOC: R_RISCV_PCREL_LO12_S .Ltmp0 0x053# RELAX-RELOC: R_RISCV_RELAX - 0x054 55 56# Check behaviour when a locally defined symbol is referenced.57bar:58 59beq s1, s1, bar60# NORELAX-RELOC-NOT: R_RISCV_BRANCH61 62call bar63# NORELAX-RELOC-NOT: R_RISCV_CALL64# NORELAX-RELOC-NOT: R_RISCV_RELAX65# RELAX-RELOC-NEXT: R_RISCV_CALL_PLT bar 0x066# RELAX-RELOC: R_RISCV_RELAX - 0x067 68beq s1, s1, bar69# NORELAX-RELOC-NOT: R_RISCV_BRANCH70# RELAX-RELOC-NEXT: R_RISCV_BRANCH bar 0x071 72lui t1, %hi(bar)73# NORELAX-RELOC: R_RISCV_HI20 bar 0x074# NORELAX-RELOC-NOT: R_RISCV_RELAX75# RELAX-RELOC: R_RISCV_HI20 bar 0x076# RELAX-RELOC: R_RISCV_RELAX - 0x077 78addi t1, t1, %lo(bar)79# NORELAX-RELOC: R_RISCV_LO12_I bar 0x080# NORELAX-RELOC-NOT: R_RISCV_RELAX81# RELAX-RELOC: R_RISCV_LO12_I bar 0x082# RELAX-RELOC: R_RISCV_RELAX - 0x083 84sb t1, %lo(bar)(a2)85# NORELAX-RELOC: R_RISCV_LO12_S bar 0x086# NORELAX-RELOC-NOT: R_RISCV_RELAX87# RELAX-RELOC: R_RISCV_LO12_S bar 0x088# RELAX-RELOC: R_RISCV_RELAX - 0x089 902:91auipc t1, %pcrel_hi(bar)92# NORELAX-RELOC-NOT: R_RISCV_PCREL_HI2093# NORELAX-RELOC-NOT: R_RISCV_RELAX94# RELAX-RELOC: R_RISCV_PCREL_HI20 bar 0x095# RELAX-RELOC: R_RISCV_RELAX - 0x096 97addi t1, t1, %pcrel_lo(2b)98# NORELAX-RELOC-NOT: R_RISCV_PCREL_LO12_I99# NORELAX-RELOC-NOT: R_RISCV_RELAX100# RELAX-RELOC: R_RISCV_PCREL_LO12_I .Ltmp1 0x0101# RELAX-RELOC: R_RISCV_RELAX - 0x0102 103sb t1, %pcrel_lo(2b)(a2)104# NORELAX-RELOC-NOT: R_RISCV_PCREL_LO12_S105# NORELAX-RELOC-NOT: R_RISCV_RELAX106# RELAX-RELOC: R_RISCV_PCREL_LO12_S .Ltmp1 0x0107# RELAX-RELOC: R_RISCV_RELAX - 0x0108 109## %hi/%lo on an absolute symbol (not yet defined) leads to relocations when relaxation is enabled.110lui t2, %hi(abs)111# NORELAX-RELOC-NOT: R_RISCV_112# RELAX-RELOC:      R_RISCV_HI20 - 0x12345113# RELAX-RELOC-NEXT: R_RISCV_RELAX - 0x0114 115addi t2, t2, %lo(abs)116# NORELAX-RELOC-NOT: R_RISCV_117# RELAX-RELOC:      R_RISCV_LO12_I - 0x12345118# RELAX-RELOC-NEXT: R_RISCV_RELAX - 0x0119 120.set abs, 0x12345121 122lui t3, %hi(abs)123# RELAX-RELOC:      R_RISCV_HI20 - 0x12345124# RELAX-RELOC-NEXT: R_RISCV_RELAX - 0x0125 126# Check that a relocation is not emitted for a symbol difference which has127# been folded to a fixup with an absolute value. This can happen when a128# difference expression refers to two symbols, at least one of which is129# not defined at the point it is referenced. Then during *assembler*130# relaxation when both symbols have become defined the difference may be folded131# down to a fixup simply containing the absolute value. We want to ensure that132# we don't force a relocation to be emitted for this absolute value even133# when linker relaxation is enabled. The reason for this is that one instance134# where this pattern appears in in the .eh_frame section (the CIE 'length'135# field), and the .eh_frame section cannot be parsed by the linker unless the136# fixup has been resolved to a concrete value instead of a relocation.137  .data138lo:139  .word hi-lo140  .quad hi-lo141# NORELAX-RELOC-NOT: R_RISCV_32142# NORELAX-RELOC-NOT: R_RISCV_64143# RELAX-RELOC-NOT: R_RISCV_32144# RELAX-RELOC-NOT: R_RISCV_64145hi:146