|
1 | 1 | # REQUIRES: ppc
|
2 | 2 |
|
3 | 3 | # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
|
4 |
| -# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o |
5 |
| -# RUN: ld.lld -shared %t2.o -o %t2.so |
6 |
| -# RUN: ld.lld %t.o %t2.so -o %t |
7 |
| -# RUN: llvm-objdump -D %t | FileCheck %s |
8 |
| -# RUN: llvm-readelf -dynamic-table %t | FileCheck --check-prefix=DT %s |
9 |
| -# RUN: llvm-readelf -dyn-relocations %t | FileCheck --check-prefix=DYNREL %s |
| 4 | +# RUN: ld.lld %t.o -o %t |
| 5 | +# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s |
| 6 | +# RUN: llvm-readelf -S %t | FileCheck --check-prefix=SECTIONS %s |
| 7 | +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s |
| 8 | +# RUN: llvm-readelf -r %t | FileCheck --check-prefix=DYNREL %s |
10 | 9 |
|
11 | 10 | # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
|
12 |
| -# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o |
13 |
| -# RUN: ld.lld -shared %t2.o -o %t2.so |
14 |
| -# RUN: ld.lld %t.o %t2.so -o %t |
15 |
| -# RUN: llvm-objdump -D %t | FileCheck %s |
16 |
| -# RUN: llvm-readelf -dynamic-table %t | FileCheck --check-prefix=DT %s |
17 |
| -# RUN: llvm-readelf -dyn-relocations %t | FileCheck --check-prefix=DYNREL %s |
| 11 | +# RUN: ld.lld %t.o -o %t |
| 12 | +# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s |
| 13 | +# RUN: llvm-readelf -S %t | FileCheck --check-prefix=SECTIONS %s |
| 14 | +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s |
| 15 | +# RUN: llvm-readelf -r %t | FileCheck --check-prefix=DYNREL %s |
18 | 16 |
|
19 |
| -# CHECK: Disassembly of section .text: |
| 17 | +# NM-DAG: 0000000010028000 d .TOC. |
| 18 | +# NM-DAG: 0000000010010028 T ifunc |
| 19 | +# NM-DAG: 000000001001002c T ifunc2 |
20 | 20 |
|
21 |
| -# Tocbase + (0 << 16) + 32560 |
22 |
| -# 0x100280e0 + 0 + 32560 = 0x10030010 (.plt[2]) |
23 |
| -# CHECK: __plt_foo: |
| 21 | +# SECTIONS: .plt NOBITS 0000000010030000 |
| 22 | + |
| 23 | +# .plt[0] - .TOC. = 0x10030000 - 0x10028000 = (1<<16) - 32768 |
| 24 | +# CHECK: __plt_ifunc: |
24 | 25 | # CHECK-NEXT: std 2, 24(1)
|
25 |
| -# CHECK-NEXT: addis 12, 2, 0 |
26 |
| -# CHECK-NEXT: ld 12, 32560(12) |
| 26 | +# CHECK-NEXT: addis 12, 2, 1 |
| 27 | +# CHECK-NEXT: ld 12, -32768(12) |
27 | 28 | # CHECK-NEXT: mtctr 12
|
28 | 29 | # CHECK-NEXT: bctr
|
29 | 30 |
|
30 |
| -# Tocbase + (0 << 16) + 32568 |
31 |
| -# 0x100280e0 + 0 + 32568 = 0x1003018 (.plt[3]) |
32 |
| -# CHECK: __plt_ifunc: |
| 31 | +# .plt[1] - .TOC. = 0x10030000+8 - 0x10028000 = (1<<16) - 32760 |
| 32 | +# CHECK: __plt_ifunc2: |
33 | 33 | # CHECK-NEXT: std 2, 24(1)
|
34 |
| -# CHECK-NEXT: addis 12, 2, 0 |
35 |
| -# CHECK-NEXT: ld 12, 32568(12) |
| 34 | +# CHECK-NEXT: addis 12, 2, 1 |
| 35 | +# CHECK-NEXT: ld 12, -32760(12) |
36 | 36 | # CHECK-NEXT: mtctr 12
|
37 | 37 | # CHECK-NEXT: bctr
|
38 | 38 |
|
39 |
| -# CHECK: ifunc: |
40 |
| -# CHECK-NEXT: 10010028: {{.*}} nop |
41 |
| - |
| 39 | +# __plt_ifunc - . = 0x10010000 - 0x10010038 = -56 |
| 40 | +# __plt_ifunc2 - . = 0x10010014 - 0x10010040 = -44 |
42 | 41 | # CHECK: _start:
|
43 |
| -# CHECK-NEXT: addis 2, 12, 2 |
44 |
| -# CHECK-NEXT: addi 2, 2, -32588 |
45 |
| -# CHECK-NEXT: bl .-52 |
46 |
| -# CHECK-NEXT: ld 2, 24(1) |
47 |
| -# CHECK-NEXT: bl .-40 |
48 |
| -# CHECK-NEXT: ld 2, 24(1) |
49 |
| - |
50 |
| -# Check tocbase |
51 |
| -# CHECK: Disassembly of section .got: |
52 |
| -# CHECK-NEXT: .got: |
53 |
| -# CHECK-NEXT: 100200e0 |
54 |
| - |
55 |
| -# Check .plt address |
56 |
| -# DT_PLTGOT should point to the start of the .plt section. |
57 |
| -# DT: 0x0000000000000003 PLTGOT 0x10030000 |
58 |
| - |
59 |
| -# Check that we emit the correct dynamic relocation type for an ifunc |
60 |
| -# DYNREL: 'PLT' relocation section at offset 0x{{[0-9a-f]+}} contains 48 bytes: |
61 |
| -# 48 bytes --> 2 Elf64_Rela relocations |
62 |
| -# DYNREL-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend |
63 |
| -# DYNREL-NEXT: {{[0-9a-f]+}} {{[0-9a-f]+}} R_PPC64_JMP_SLOT {{0+}} foo + 0 |
64 |
| -# DYNREL-NEXT: {{[0-9a-f]+}} {{[0-9a-f]+}} R_PPC64_IRELATIVE 10010028 |
| 42 | +# CHECK-NEXT: addis 2, 12, 1 |
| 43 | +# CHECK-NEXT: addi 2, 2, 32720 |
| 44 | +# CHECK-NEXT: 10010038: bl .-56 |
| 45 | +# CHECK-NEXT: ld 2, 24(1) |
| 46 | +# CHECK-NEXT: 10010040: bl .-44 |
| 47 | +# CHECK-NEXT: ld 2, 24(1) |
65 | 48 |
|
66 |
| - |
67 |
| - .text |
68 |
| - .abiversion 2 |
| 49 | +# Check that we emit 2 R_PPC64_IRELATIVE. |
| 50 | +# DYNREL: R_PPC64_IRELATIVE 10010028 |
| 51 | +# DYNREL: R_PPC64_IRELATIVE 1001002c |
69 | 52 |
|
70 | 53 | .type ifunc STT_GNU_IFUNC
|
71 | 54 | .globl ifunc
|
72 | 55 | ifunc:
|
73 |
| - nop |
| 56 | + nop |
| 57 | + |
| 58 | +.type ifunc2 STT_GNU_IFUNC |
| 59 | +.globl ifunc2 |
| 60 | +ifunc2: |
| 61 | + nop |
74 | 62 |
|
75 |
| - .global _start |
76 |
| - .type _start,@function |
| 63 | +.global _start |
| 64 | +.type _start,@function |
77 | 65 |
|
78 | 66 | _start:
|
79 | 67 | .Lfunc_gep0:
|
80 | 68 | addis 2, 12, .TOC.-.Lfunc_gep0@ha
|
81 | 69 | addi 2, 2, .TOC.-.Lfunc_gep0@l
|
82 | 70 | .Lfunc_lep0:
|
83 | 71 | .localentry _start, .Lfunc_lep0-.Lfunc_gep0
|
84 |
| - bl foo |
85 |
| - nop |
86 | 72 | bl ifunc
|
87 | 73 | nop
|
| 74 | + bl ifunc2 |
| 75 | + nop |
0 commit comments