• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: ppc
2# RUN: echo 'SECTIONS { \
3# RUN:   .text_func   0x10010000 : { *(.text_func) } \
4# RUN:   .text_callee 0x10020000 : { *(.text_callee) } \
5# RUN:   .text_caller 0x10030000 : { *(.text_caller) } \
6# RUN:   }' > %t.script
7
8# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
9# RUN: ld.lld -T %t.script %t.o -o %t
10# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
11# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t | FileCheck %s
12
13# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t.o
14# RUN: ld.lld -T %t.script %t.o -o %t
15# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
16# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t | FileCheck %s
17
18## When a function without TOC accesses a function using TOC, an r12 setup stub
19## is inserted
20
21# SYMBOL:      1: 0000000010020000 0 NOTYPE LOCAL DEFAULT [<other: 0x60>] 2 callee
22# SYMBOL-NEXT: 2: 0000000010030000 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 3 caller
23# SYMBOL-NEXT: 3: 0000000010010000 0 NOTYPE LOCAL DEFAULT 1 func
24# SYMBOL:      6: 0000000010030010 16 FUNC LOCAL DEFAULT 3 __gep_setup_callee
25
26# CHECK-LABEL: <func>:
27# CHECK-NEXT:  blr
28
29# CHECK-LABEL: <callee>:
30# CHECK:       bl 0x10010000
31# CHECK-NEXT:  addis 4, 2, -1
32# CHECK-NEXT:  lwz 4, 32744(4)
33# CHECK-NEXT:  blr
34
35# CHECK-LABEL: <caller>:
36# CHECK-NEXT:  bl 0x10030010
37# CHECK-NEXT:  blr
38
39# CHECK-LABEL: <__gep_setup_callee>:
40# CHECK-NEXT:  paddi 12, 0, -65552, 1
41# CHECK-NEXT:  mtctr 12
42# CHECK-NEXT:  bctr
43
44.section .text_func, "ax", %progbits
45func:
46  blr
47
48.section .text_callee, "ax", %progbits
49callee:
50.Lfunc_gep1:
51  addis 2, 12, .TOC.-.Lfunc_gep1@ha
52  addi 2, 2, .TOC.-.Lfunc_gep1@l
53.Lfunc_lep1:
54  .localentry callee, .Lfunc_lep1-.Lfunc_gep1
55  bl func
56  addis 4, 2, global@toc@ha
57  lwz 4, global@toc@l(4)
58  blr
59
60.section .text_caller, "ax", %progbits
61caller:
62  .localentry caller, 1
63  bl callee@notoc
64  blr
65global:
66  .long	0
67  .size	global, 4
68