2 # RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
3 # RUN: echo '.globl f, g, h; f: g: h:' | llvm-mc -filetype=obj -triple=powerpc - -o %t1.o
4 # RUN: ld.lld -shared %t1.o -soname t1.so -o %t1.so
6 ## Check we can create PLT entries for -fno-PIE executable.
7 # RUN: ld.lld %t.o %t1.so -o %t
8 # RUN: llvm-readobj -r -d %t | FileCheck --check-prefix=RELOC %s
9 # RUN: llvm-readelf -S %t | FileCheck --check-prefix=SEC %s
10 # RUN: llvm-readelf -x .plt %t | FileCheck --check-prefix=HEX %s
11 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
13 # SEC: .got PROGBITS 100202b8
14 # RELOC: PPC_GOT 0x100202B8
17 # RELOC-NEXT: 0x100302C4 R_PPC_JMP_SLOT f 0x0
18 # RELOC-NEXT: 0x100302C8 R_PPC_JMP_SLOT g 0x0
21 ## .got2+0x8000-0x10004 = 0x30000+0x8000-0x10004 = 65536*2+32764
22 # CHECK-LABEL: <_start>:
23 # CHECK-NEXT: bl 0x100101d0
24 # CHECK-NEXT: bl 0x100101d0
25 # CHECK-NEXT: bl 0x100101e0
26 # CHECK-NEXT: bl 0x100101e0
29 ## -fno-PIC call stubs of f and g.
30 ## .plt[0] = 0x100302c4 = 65536*4099+708
31 ## .plt[1] = 0x100302c8 = 65536*4099+712
32 # CHECK-NEXT: <00000000.plt_call32.f>:
33 # CHECK-NEXT: lis 11, 4099
34 # CHECK-NEXT: lwz 11, 708(11)
35 # CHECK-NEXT: mtctr 11
38 # CHECK-NEXT: <00000000.plt_call32.g>:
39 # CHECK-NEXT: lis 11, 4099
40 # CHECK-NEXT: lwz 11, 712(11)
41 # CHECK-NEXT: mtctr 11
45 ## In Secure PLT ABI, .plt stores function pointers to first instructions of .glink
46 # HEX: 0x100302c4 10010200 10010204
48 ## These instructions are referenced by .plt entries.
49 # CHECK: 10010200 <.glink>:
50 # CHECK-NEXT: b 0x10010208
51 # CHECK-NEXT: b 0x10010208
54 ## Operands of lis & lwz: .got+4 = 0x10020070+4 = 65536*4098+700
55 ## Operands of addis & addi: -.glink = -0x10010200 = 65536*-4097-512
56 # CHECK-NEXT: lis 12, 4098
57 # CHECK-NEXT: addis 11, 11, -4097
58 # CHECK-NEXT: lwz 0, 700(12)
59 # CHECK-NEXT: addi 11, 11, -512
62 # CHECK-NEXT: add 0, 11, 11
63 # CHECK-NEXT: lwz 12, 704(12)
64 # CHECK-NEXT: add 11, 0, 11
67 ## glibc crti.o references _GLOBAL_OFFSET_TABLE_.
72 addis 30, 30, _GLOBAL_OFFSET_TABLE_-
.L@ha
73 addi 30, 30, _GLOBAL_OFFSET_TABLE_-
.L@l