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# The point of this test is to make sure that when a function with TOC access
18# a local function with st_other=1, a TOC save stub is inserted.
19
20# SYMBOL: Symbol table '.symtab' contains 7 entries
21# SYMBOL: 10010000     0 NOTYPE  LOCAL  DEFAULT [<other: 0x20>]   1 callee
22# SYMBOL: 10020000     0 NOTYPE  LOCAL  DEFAULT [<other: 0x60>]   2 caller
23# SYMBOL: 10020020     0 NOTYPE  LOCAL  DEFAULT [<other: 0x60>]   2 caller_14
24# SYMBOL: 10020040     8 FUNC    LOCAL  DEFAULT                   2 __toc_save_callee
25
26# CHECK-LABEL: callee
27# CHECK:       blr
28
29# CHECK-LABEL: caller
30# CHECK:       bl 0x10020040
31# CHECK-NEXT:  ld 2, 24(1)
32# CHECK-NEXT:  blr
33
34# CHECK-LABEL: caller_14
35# CHECK:       bfl 0, 0x10020040
36# CHECK-NEXT:  ld 2, 24(1)
37# CHECK-NEXT:  blr
38
39# CHECK-LABEL: __toc_save_callee
40# CHECK-NEXT:  std 2, 24(1)
41# CHECK-NEXT:  b 0x10010000
42
43
44.section .text_callee, "ax", %progbits
45callee:
46  .localentry callee, 1
47  blr
48
49.section .text_caller, "ax", %progbits
50caller:
51.Lfunc_gep1:
52  addis 2, 12, .TOC.-.Lfunc_gep1@ha
53  addi 2, 2, .TOC.-.Lfunc_gep1@l
54.Lfunc_lep1:
55  .localentry caller, .Lfunc_lep1-.Lfunc_gep1
56  addis 30, 2, global@toc@ha
57  lwz 3, global@toc@l(30)
58  bl callee
59  nop
60  blr
61global:
62  .long	0
63
64caller_14:
65.Lfunc_gep2:
66  addis 2, 12, .TOC.-.Lfunc_gep1@ha
67  addi 2, 2, .TOC.-.Lfunc_gep1@l
68.Lfunc_lep2:
69  .localentry caller_14, .Lfunc_lep2-.Lfunc_gep2
70  addis 30, 2, global@toc@ha
71  lwz 3, global@toc@l(30)
72  bcl 4, 0, callee
73  nop
74  blr
75