150
|
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: 0x3218 R_RISCV_IRELATIVE - 0x117C
|
|
16 # RELOC32-NEXT: }
|
|
17
|
|
18 # SYM32: 0001190 0 FUNC GLOBAL DEFAULT {{.*}} func
|
|
19
|
173
|
20 # DIS32: <_start>:
|
150
|
21 # DIS32-NEXT: 1180: auipc a0, 0
|
|
22 # DIS32-NEXT: addi a0, a0, 16
|
|
23 # DIS32: Disassembly of section .iplt:
|
173
|
24 # DIS32: <func>:
|
150
|
25 ## 32-bit: &.got.plt[func]-. = 0x3218-0x1190 = 4096*2+136
|
|
26 # DIS32-NEXT: 1190: auipc t3, 2
|
|
27 # DIS32-NEXT: lw t3, 136(t3)
|
|
28 # DIS32-NEXT: jalr t1, t3
|
|
29 # DIS32-NEXT: nop
|
|
30
|
|
31 # RELOC64: .rela.dyn {
|
|
32 # RELOC64-NEXT: 0x3370 R_RISCV_IRELATIVE - 0x1260
|
|
33 # RELOC64-NEXT: }
|
|
34
|
|
35 # SYM64: 000000000001270 0 FUNC GLOBAL DEFAULT {{.*}} func
|
|
36
|
173
|
37 # DIS64: <_start>:
|
150
|
38 # DIS64-NEXT: 1264: auipc a0, 0
|
|
39 # DIS64-NEXT: addi a0, a0, 12
|
|
40 # DIS64: Disassembly of section .iplt:
|
173
|
41 # DIS64: <func>:
|
150
|
42 ## 64-bit: &.got.plt[func]-. = 0x3370-0x1270 = 4096*2+256
|
|
43 # DIS64-NEXT: 1270: auipc t3, 2
|
|
44 # DIS64-NEXT: ld t3, 256(t3)
|
|
45 # DIS64-NEXT: jalr t1, t3
|
|
46 # DIS64-NEXT: nop
|
|
47
|
|
48 .text
|
|
49 .globl func
|
|
50 .type func, @gnu_indirect_function
|
|
51 func:
|
|
52 ret
|
|
53
|
|
54 .globl _start
|
|
55 _start:
|
|
56 .L:
|
|
57 auipc a0, %pcrel_hi(func)
|
|
58 addi a0, a0, %pcrel_lo(.L)
|