3 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
4 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-bsymbolic-local-def.s -o %t2.o
5 # RUN: ld.lld -Bsymbolic -shared %t1.o %t2.o -o %t
6 # RUN: llvm-objdump -d -r --no-show-raw-insn %t | FileCheck %s
7 # RUN: not ld.lld -shared %t1.o %t2.o -o /dev/null 2>&1 | FileCheck --check-prefix=FAIL %s
9 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
10 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-bsymbolic-local-def.s -o %t2.o
11 # RUN: ld.lld -Bsymbolic -shared %t1.o %t2.o -o %t
12 # RUN: llvm-objdump -d -r --no-show-raw-insn %t | FileCheck %s
13 # RUN: not ld.lld -shared %t1.o %t2.o -o /dev/null 2>&1 | FileCheck --check-prefix=FAIL %s
15 # FAIL: call to def lacks nop, can't restore toc
17 # Test to document the toc-restore behavior with -Bsymbolic option. Since
18 # -Bsymbolic causes the call to bind to the internal definition we know the
19 # caller and callee share the same TOC base. This means branching to the
20 # local entry point of the callee, and no need for a nop to follow the call
21 # (since there is no need to restore the TOC-pointer after the call).
28 .type caller, @function
31 addis 2, 12, .TOC.-.Lcaller_gep@ha
32 addi 2, 2, .TOC.-.Lcaller_gep@l
34 .localentry caller, .-caller
48 # Note that the bl .+44 is a call to def's local entry, jumping past the first 2
49 # instructions. Branching to the global entry would corrupt the TOC pointer
50 # since the global entry requires that %r12 hold the address of the function
54 # CHECK: bl 0x[[DEF:[0-9a-f]+]]
55 # CHECK-NEXT: mr 31, 3
56 # CHECK-NEXT: bl 0x[[NOT_DEFINED:[0-9a-f]+]]
57 # CHECK-NEXT: ld 2, 24(1)
58 # CHECK-NEXT: add 3, 3, 31
59 # CHECK-NEXT: addi 1, 1, 32
60 # CHECK-NEXT: ld 0, -16(1)
65 # CHECK-NEXT: addis 2, 12, 2
66 # CHECK-NEXT: addi 2, 2, -32432
67 # CHECK-NEXT: [[DEF]]: li 3, 55
72 # CHECK-NEXT: 00000000000[[NOT_DEFINED]] <__plt_not_defined>: