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: ld.lld -pie %t.32.o -o %t.32-apply --apply-dynamic-relocs
5 # RUN: llvm-readobj -r -x .got.plt %t.32 | FileCheck --check-prefixes=RELOC32,NO-APPLY-RELOC32 %s
6 # RUN: llvm-readobj -r -x .got.plt %t.32-apply | FileCheck --check-prefixes=RELOC32,APPLY-RELOC32 %s
7 # RUN: llvm-readelf -s %t.32 | FileCheck --check-prefix=SYM32 %s
8 # RUN: llvm-objdump -d --no-show-raw-insn %t.32 | FileCheck --check-prefix=DIS32 %s
10 # RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t.64.o
11 # RUN: ld.lld -pie %t.64.o -o %t.64
12 # RUN: ld.lld -pie %t.64.o -o %t.64-apply --apply-dynamic-relocs
13 # RUN: llvm-readobj -r -x .got.plt %t.64 | FileCheck --check-prefixes=RELOC64,NO-APPLY-RELOC64 %s
14 # RUN: llvm-readobj -r -x .got.plt %t.64-apply | FileCheck --check-prefixes=RELOC64,APPLY-RELOC64 %s
15 # RUN: llvm-readelf -s %t.64 | FileCheck --check-prefix=SYM64 %s
16 # RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefix=DIS64 %s
18 # RELOC32: .rela.dyn {
19 # RELOC32-NEXT: 0x3200 R_RISCV_IRELATIVE - 0x117C
21 # RELOC32-LABEL: Hex dump of section '.got.plt':
22 # NO-APPLY-RELOC32: 0x00003200 00000000
23 # APPLY-RELOC32: 0x00003200 7c110000
26 # SYM32: 0001190 0 FUNC GLOBAL DEFAULT {{.*}} func
29 # DIS32-NEXT: 1180: auipc a0, 0x0
30 # DIS32-NEXT: addi a0, a0, 0x10
31 # DIS32: Disassembly of section .iplt:
33 ## 32-bit: &.got.plt[func]-. = 0x3200-0x1190 = 4096*2+0x70
34 # DIS32-NEXT: 1190: auipc t3, 0x2
35 # DIS32-NEXT: lw t3, 0x70(t3)
36 # DIS32-NEXT: jalr t1, t3
39 # RELOC64: .rela.dyn {
40 # RELOC64-NEXT: 0x3340 R_RISCV_IRELATIVE - 0x1260
42 # RELOC64-LABEL: Hex dump of section '.got.plt':
43 # NO-APPLY-RELOC64: 0x00003340 00000000 00000000
44 # APPLY-RELOC64: 0x00003340 60120000 00000000
47 # SYM64: 000000000001270 0 FUNC GLOBAL DEFAULT {{.*}} func
50 # DIS64-NEXT: 1264: auipc a0, 0x0
51 # DIS64-NEXT: addi a0, a0, 0xc
52 # DIS64: Disassembly of section .iplt:
54 ## 64-bit: &.got.plt[func]-. = 0x3340-0x1270 = 4096*2+0xd0
55 # DIS64-NEXT: 1270: auipc t3, 0x2
56 # DIS64-NEXT: ld t3, 0xd0(t3)
57 # DIS64-NEXT: jalr t1, t3
62 .type func, @gnu_indirect_function
69 auipc a0
, %pcrel_hi
(func
)
70 addi a0
, a0
, %pcrel_lo
(.L)