1# REQUIRES: ppc
2# RUN: echo 'SECTIONS { \
3# RUN:       .text_callee 0x10010000 : { *(.text_callee) } \
4# RUN:       .text_caller 0x10020000 : { *(.text_caller) } \
5# RUN:       }' > %t.script
6
7# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
8# RUN: ld.lld -T %t.script %t.o -o %t
9# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
10# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=future %t | FileCheck %s
11
12# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t.o
13# RUN: ld.lld -T %t.script %t.o -o %t
14# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
15# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=future %t | FileCheck %s
16
17# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t.o
18# RUN: ld.lld -T %t.script %t.o -o %t --no-power10-stubs
19# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
20# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=future %t \
21# RUN: | FileCheck %s
22
23# The point of this test is to make sure that when a function with TOC access
24# a local function with st_other=1, a TOC save stub is inserted.
25
26# SYMBOL: Symbol table '.symtab' contains 7 entries
27# SYMBOL: 10010000     0 NOTYPE  LOCAL  DEFAULT [<other: 0x20>]   1 callee
28# SYMBOL: 10020000     0 NOTYPE  LOCAL  DEFAULT [<other: 0x60>]   2 caller
29# SYMBOL: 10020020     0 NOTYPE  LOCAL  DEFAULT [<other: 0x60>]   2 caller_14
30# SYMBOL: 10020040     8 FUNC    LOCAL  DEFAULT                   2 __toc_save_callee
31
32# CHECK-LABEL: callee
33# CHECK:       blr
34
35# CHECK-LABEL: caller
36# CHECK:       bl 0x10020040
37# CHECK-NEXT:  ld 2, 24(1)
38# CHECK-NEXT:  blr
39
40# CHECK-LABEL: caller_14
41# CHECK:       bfl 0, 0x10020040
42# CHECK-NEXT:  ld 2, 24(1)
43# CHECK-NEXT:  blr
44
45# CHECK-LABEL: __toc_save_callee
46# CHECK-NEXT:  std 2, 24(1)
47# CHECK-NEXT:  b 0x10010000
48
49
50.section .text_callee, "ax", %progbits
51callee:
52  .localentry callee, 1
53  blr
54
55.section .text_caller, "ax", %progbits
56caller:
57.Lfunc_gep1:
58  addis 2, 12, .TOC.-.Lfunc_gep1@ha
59  addi 2, 2, .TOC.-.Lfunc_gep1@l
60.Lfunc_lep1:
61  .localentry caller, .Lfunc_lep1-.Lfunc_gep1
62  addis 30, 2, global@toc@ha
63  lwz 3, global@toc@l(30)
64  bl callee
65  nop
66  blr
67global:
68  .long	0
69
70caller_14:
71.Lfunc_gep2:
72  addis 2, 12, .TOC.-.Lfunc_gep1@ha
73  addi 2, 2, .TOC.-.Lfunc_gep1@l
74.Lfunc_lep2:
75  .localentry caller_14, .Lfunc_lep2-.Lfunc_gep2
76  addis 30, 2, global@toc@ha
77  lwz 3, global@toc@l(30)
78  bcl 4, 0, callee
79  nop
80  blr
81