1# REQUIRES: ppc
2# RUN: echo 'SECTIONS { \
3# RUN:   .text_default_stother0 0x10010000: { *(.text_default_stother0) } \
4# RUN:   .text_default_stother1 0x10020000: { *(.text_default_stother1) } \
5# RUN:   .text_hidden_stother0 0x10030000: { *(.text_hidden_stother0) } \
6# RUN:   .text_hidden_stother1 0x10040000: { *(.text_hidden_stother1) } \
7# RUN:   }' > %t.script
8
9# RUN: llvm-mc -filetype=obj -triple=powerpc64le -defsym HIDDEN=1 %s -o %t1.o
10# RUN: llvm-mc -filetype=obj -triple=powerpc64le %p/Inputs/ppc64-callee-global-hidden.s -o %t2.o
11# RUN: ld.lld -T %t.script -shared %t1.o %t2.o -o %t.so
12# RUN: llvm-readelf -s %t.so | FileCheck %s --check-prefix=SYMBOL
13# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t.so | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HIDDEN %s
14
15# RUN: llvm-mc -filetype=obj -triple=powerpc64le -defsym GLOBAL=1 %s -o %t3.o
16# RUN: ld.lld -T %t.script %t3.o -o %t
17# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL-GLOBAL
18# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t | FileCheck %s
19
20# RUN: llvm-mc -filetype=obj -triple=powerpc64 -defsym HIDDEN=1 %s -o %t1.o
21# RUN: llvm-mc -filetype=obj -triple=powerpc64 %p/Inputs/ppc64-callee-global-hidden.s -o %t2.o
22# RUN: ld.lld -T %t.script -shared %t1.o %t2.o -o %t.so
23# RUN: llvm-readelf -s %t.so | FileCheck %s --check-prefix=SYMBOL
24# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t.so | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HIDDEN %s
25
26# RUN: llvm-mc -filetype=obj -triple=powerpc64 -defsym GLOBAL=1 %s -o %t3.o
27# RUN: ld.lld -T %t.script %t3.o -o %t
28# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL-GLOBAL
29# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t | FileCheck %s
30
31# SYMBOL:      2: 0000000010010000 0 NOTYPE LOCAL DEFAULT 5 callee1_stother0_default
32# SYMBOL-NEXT: 3: 0000000010020004 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 6 callee2_stother1_default
33# SYMBOL-NEXT: 4: 0000000010010004 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 5 caller1
34# SYMBOL-NEXT: 5: 000000001002000c 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 6 caller2
35# SYMBOL-NEXT: 6: 0000000010030000 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 7 caller3
36# SYMBOL-NEXT: 7: 0000000010040000 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 8 caller4
37# SYMBOL-NEXT: 8: 0000000010020000 0 NOTYPE LOCAL DEFAULT 6 func_local
38# SYMBOL-NEXT: 9: 0000000010040008 0 NOTYPE LOCAL DEFAULT 9 func_extern
39# SYMBOL-NEXT: 10: 000000001004000c 0 NOTYPE LOCAL HIDDEN 9 callee3_stother0_hidden
40# SYMBOL-NEXT: 11: 0000000010040010 0 NOTYPE LOCAL HIDDEN [<other: 0x22>] 9 callee4_stother1_hidden
41
42# SYMBOL-GLOBAL:      2: 0000000010010004 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 1 caller1
43# SYMBOL-GLOBAL-NEXT: 3: 000000001002000c 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 2 caller2
44# SYMBOL-GLOBAL-NEXT: 4: 0000000010020000 0 NOTYPE LOCAL DEFAULT 2 func_local
45# SYMBOL-GLOBAL-NEXT: 5: 0000000010010000 0 NOTYPE GLOBAL DEFAULT 1 callee1_stother0_default
46# SYMBOL-GLOBAL-NEXT: 6: 0000000010020004 0 NOTYPE GLOBAL DEFAULT [<other: 0x20>] 2 callee2_stother1_default
47
48# CHECK-LABEL: <callee1_stother0_default>:
49# CHECK-NEXT:  10010000: blr
50
51# CHECK-LABEL: <caller1>:
52# CHECK:       10010004: bl 0x10010000
53# CHECK-NEXT:  10010008: b 0x10010000
54.section .text_default_stother0, "ax", %progbits
55.ifdef GLOBAL
56.globl callee1_stother0_default
57.endif
58callee1_stother0_default:
59  blr
60caller1:
61  .localentry caller1, 1
62  ## nop is not needed after bl for R_PPC64_REL24_NOTOC
63  bl callee1_stother0_default@notoc
64  b callee1_stother0_default@notoc
65
66# CHECK-LABEL: <func_local>:
67# CHECK-NEXT:  10020000: blr
68
69# CHECK-LABEL: <callee2_stother1_default>:
70# CHECK-NEXT:  10020004: bl 0x10020000
71# CHECK-NEXT:  10020008: blr
72
73# CHECK-LABEL: <caller2>:
74# CHECK:       1002000c: bl 0x10020004
75# CHECK-NEXT:  10020010: b 0x10020004
76.section .text_default_stother1, "ax", %progbits
77func_local:
78  blr
79.ifdef GLOBAL
80.globl callee2_stother1_default
81.endif
82callee2_stother1_default:
83  .localentry callee2_stother1_default, 1
84  ## nop is not needed after bl for R_PPC64_REL24_NOTOC
85  bl func_local@notoc
86  blr
87caller2:
88  .localentry caller2, 1
89  ## nop is not needed after bl for R_PPC64_REL24_NOTOC
90  bl callee2_stother1_default@notoc
91  b callee2_stother1_default@notoc
92
93# CHECK-HIDDEN-LABEL: <caller3>:
94# CHECK-HIDDEN-NEXT:  10030000: bl 0x1004000c
95# CHECK-HIDDEN-NEXT:  10030004: b 0x1004000c
96
97# CHECK-HIDDEN-LABEL: <caller4>:
98# CHECK-HIDDEN-NEXT:  10040000: bl 0x10040010
99# CHECK-HIDDEN-NEXT:  10040004: b 0x10040010
100
101# CHECK-HIDDEN-LABEL: <func_extern>:
102# CHECK-HIDDEN-NEXT:  10040008: blr
103
104# CHECK-HIDDEN-LABEL: <callee3_stother0_hidden>:
105# CHECK-HIDDEN-NEXT:  1004000c: blr
106
107# CHECK-HIDDEN-LABEL: <callee4_stother1_hidden>:
108# CHECK-HIDDEN-NEXT:  10040010: bl 0x10040008
109# CHECK-HIDDEN-NEXT:  10040014: blr
110.ifdef HIDDEN
111.section .text_hidden_stother0, "ax", %progbits
112caller3:
113  .localentry caller3, 1
114  ## nop is not needed after bl for R_PPC64_REL24_NOTOC
115  bl callee3_stother0_hidden@notoc
116  b callee3_stother0_hidden@notoc
117
118.section .text_hidden_stother1, "ax", %progbits
119caller4:
120  .localentry caller4, 1
121  ## nop is not needed after bl for R_PPC64_REL24_NOTOC
122  bl callee4_stother1_hidden@notoc
123  b callee4_stother1_hidden@notoc
124.endif
125