92 lines · plain
1# REQUIRES: riscv2 3## Additionally test that (a) -no-pie/-pie have the same behavior4## (b) --no-relax/--relax have the same behavior when R_RISCV_RELAX is suppressed.5# RUN: llvm-mc -filetype=obj -triple=riscv32 %s -o %t.32.o6# RUN: ld.lld --relax %t.32.o -o %t.327# RUN: llvm-nm -p %t.32 | FileCheck --check-prefixes=NM %s8# RUN: llvm-objdump -d --no-show-raw-insn %t.32 | FileCheck --check-prefixes=LE %s9# RUN: ld.lld -pie --no-relax %t.32.o -o %t.3210# RUN: llvm-objdump -d --no-show-raw-insn %t.32 | FileCheck --check-prefixes=LE %s11 12# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax %s -o %t.64.o13# RUN: ld.lld --no-relax %t.64.o -o %t.6414# RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefixes=LE %s15# RUN: ld.lld -pie --no-relax %t.64.o -o %t.6416# RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefixes=LE %s17# RUN: ld.lld %t.64.o -o %t.64.relax18# RUN: llvm-objdump -d --no-show-raw-insn %t.64.relax | FileCheck --check-prefixes=LE-RELAX %s19 20# RUN: not ld.lld -shared %t.32.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error:21 22# ERR: error: relocation R_RISCV_TPREL_HI20 against .LANCHOR0 cannot be used with -shared23# ERR: error: relocation R_RISCV_TPREL_LO12_I against .LANCHOR0 cannot be used with -shared24# ERR: error: relocation R_RISCV_TPREL_HI20 against a cannot be used with -shared25# ERR: error: relocation R_RISCV_TPREL_LO12_I against a cannot be used with -shared26# ERR: error: relocation R_RISCV_TPREL_HI20 against a cannot be used with -shared27# ERR: error: relocation R_RISCV_TPREL_LO12_S against a cannot be used with -shared28# ERR: error: relocation R_RISCV_TPREL_HI20 against a cannot be used with -shared29# ERR: error: relocation R_RISCV_TPREL_LO12_S against a cannot be used with -shared30 31# NM: {{0*}}00000008 b .LANCHOR032# NM: {{0*}}00000800 B a33 34## .LANCHOR0@tprel = 835## a@tprel = 1236# LE: lui a1, 0x037# LE-NEXT: add a1, a1, tp38# LE-NEXT: addi a1, a1, 0x839# LE-NEXT: lui a2, 0x040# LE-NEXT: add a2, a2, tp41# LE-NEXT: addi a2, a2, 0x7fc42# LE-NEXT: lui a3, 0x043# LE-NEXT: addi a0, a0, 0x144# LE-NEXT: add a3, a3, tp45# LE-NEXT: addi a0, a0, 0x246# LE-NEXT: sw a0, 0x7fc(a3)47# LE-NEXT: lui a4, 0x148# LE-NEXT: add a4, a4, tp49# LE-NEXT: sw a0, -0x800(a4)50# LE-EMPTY:51 52# LE-RELAX: <.text>:53# LE-RELAX-NEXT: addi a1, tp, 0x854# LE-RELAX-NEXT: addi a2, tp, 0x7fc55# LE-RELAX-NEXT: addi a0, a0, 0x156# LE-RELAX-NEXT: addi a0, a0, 0x257# LE-RELAX-NEXT: sw a0, 0x7fc(tp)58# LE-RELAX-NEXT: lui a4, 0x159# LE-RELAX-NEXT: add a4, a4, tp60# LE-RELAX-NEXT: sw a0, -0x800(a4)61# LE-RELAX-EMPTY:62 63lui a1, %tprel_hi(.LANCHOR0)64add a1, a1, tp, %tprel_add(.LANCHOR0)65addi a1, a1, %tprel_lo(.LANCHOR0)66 67## hi20(a-4) = hi20(0x7fc) = 0. relaxable68lui a2, %tprel_hi(a-4)69add a2, a2, tp, %tprel_add(a-4)70addi a2, a2, %tprel_lo(a-4)71 72## hi20(a-4) = hi20(0x7fc) = 0. relaxable73## Test non-adjacent instructions.74lui a3, %tprel_hi(a-4)75addi a0, a0, 0x176add a3, a3, tp, %tprel_add(a-4)77addi a0, a0, 0x278sw a0, %tprel_lo(a-4)(a3)79 80## hi20(a) = hi20(0x800) = 1. not relaxable81lui a4, %tprel_hi(a)82add a4, a4, tp, %tprel_add(a)83sw a0, %tprel_lo(a)(a4)84 85.section .tbss86.space 887.LANCHOR0:88.space 0x800-889.globl a90a:91.zero 492