• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: riscv
2# RUN: llvm-mc -filetype=obj -triple=riscv32 %s -o %t.32.o
3# RUN: ld.lld -pie %t.32.o -o %t.32
4# RUN: llvm-readobj -r %t.32 | FileCheck --check-prefix=RELOC32 %s
5# RUN: llvm-readelf -s %t.32 | FileCheck --check-prefix=SYM32 %s
6# RUN: llvm-objdump -d --no-show-raw-insn %t.32 | FileCheck --check-prefix=DIS32 %s
7
8# RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t.64.o
9# RUN: ld.lld -pie %t.64.o -o %t.64
10# RUN: llvm-readobj -r %t.64 | FileCheck --check-prefix=RELOC64 %s
11# RUN: llvm-readelf -s %t.64 | FileCheck --check-prefix=SYM64 %s
12# RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefix=DIS64 %s
13
14# RELOC32:      .rela.dyn {
15# RELOC32-NEXT:   0x3220 R_RISCV_IRELATIVE - 0x117C
16# RELOC32-NEXT: }
17
18# SYM32: 0001190 0 FUNC GLOBAL DEFAULT {{.*}} func
19
20# DIS32:      <_start>:
21# DIS32-NEXT: 1180: auipc a0, 0
22# DIS32-NEXT:       addi a0, a0, 16
23# DIS32:      Disassembly of section .iplt:
24# DIS32:      <func>:
25## 32-bit: &.got.plt[func]-. = 0x3220-0x1190 = 4096*2+144
26# DIS32-NEXT: 1190: auipc t3, 2
27# DIS32-NEXT:       lw t3, 144(t3)
28# DIS32-NEXT:       jalr t1, t3
29# DIS32-NEXT:       nop
30
31# RELOC64:      .rela.dyn {
32# RELOC64-NEXT:   0x3380 R_RISCV_IRELATIVE - 0x1260
33# RELOC64-NEXT: }
34
35# SYM64: 000000000001270 0 FUNC GLOBAL DEFAULT {{.*}} func
36
37# DIS64:      <_start>:
38# DIS64-NEXT: 1264: auipc a0, 0
39# DIS64-NEXT:       addi a0, a0, 12
40# DIS64:      Disassembly of section .iplt:
41# DIS64:      <func>:
42## 64-bit: &.got.plt[func]-. = 0x3380-0x1270 = 4096*2+272
43# DIS64-NEXT: 1270: auipc t3, 2
44# DIS64-NEXT:       ld t3, 272(t3)
45# DIS64-NEXT:       jalr t1, t3
46# DIS64-NEXT:       nop
47
48.text
49.globl func
50.type func, @gnu_indirect_function
51func:
52  ret
53
54.globl _start
55_start:
56.L:
57  auipc a0, %pcrel_hi(func)
58  addi a0, a0, %pcrel_lo(.L)
59