brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 052d15f Raw
73 lines · plain
1# REQUIRES: ppc2 3# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o4# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-bsymbolic-local-def.s  -o %t2.o5# RUN: ld.lld -Bsymbolic -shared %t1.o %t2.o -o %t6# RUN: llvm-objdump -d -r --no-show-raw-insn %t | FileCheck %s7# RUN: not ld.lld -shared %t1.o %t2.o -o /dev/null 2>&1 | FileCheck --check-prefix=FAIL %s8 9# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o10# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-bsymbolic-local-def.s  -o %t2.o11# RUN: ld.lld -Bsymbolic -shared %t1.o %t2.o -o %t12# RUN: llvm-objdump -d -r --no-show-raw-insn %t | FileCheck %s13# RUN: not ld.lld -shared %t1.o %t2.o -o /dev/null 2>&1 | FileCheck --check-prefix=FAIL %s14 15# FAIL: call to def lacks nop, can't restore toc16 17# Test to document the toc-restore behavior with -Bsymbolic option. Since18# -Bsymbolic causes the call to bind to the internal definition we know the19# caller and callee share the same TOC base. This means branching to the20# local entry point of the callee, and no need for a nop to follow the call21# (since there is no need to restore the TOC-pointer after the call).22 23        .abiversion 224        .section ".text"25 26        .p2align 227        .global caller28        .type caller, @function29caller:30.Lcaller_gep:31    addis 2, 12, .TOC.-.Lcaller_gep@ha32    addi  2, 2, .TOC.-.Lcaller_gep@l33.Lcaller_lep:34    .localentry caller, .-caller35    mflr 036    std 0, -16(1)37    stdu 1, -32(1)38    bl def39    mr 31, 340    bl not_defined41    nop42    add 3, 3, 3143    addi 1, 1, 3244    ld 0, -16(1)45    mtlr 046    blr47 48# Note that the bl .+44 is a call to def's local entry, jumping past the first 249# instructions. Branching to the global entry would corrupt the TOC pointer50# since the global entry requires that %r12 hold the address of the function51# being called.52 53# CHECK-LABEL: caller54# CHECK:         bl 0x[[DEF:[0-9a-f]+]]55# CHECK-NEXT:    mr 31, 356# CHECK-NEXT:    bl 0x[[NOT_DEFINED:[0-9a-f]+]]57# CHECK-NEXT:    ld 2, 24(1)58# CHECK-NEXT:    add 3, 3, 3159# CHECK-NEXT:    addi 1, 1, 3260# CHECK-NEXT:    ld 0, -16(1)61# CHECK-NEXT:    mtlr 062# CHECK-NEXT:    blr63# CHECK-EMPTY:64# CHECK-NEXT:  <def>:65# CHECK-NEXT:    addis 2, 12, 266# CHECK-NEXT:    addi 2, 2, -3243267# CHECK-NEXT:    [[DEF]]: li 3, 5568# CHECK-NEXT:    blr69# CHECK-NEXT:    trap70# CHECK-NEXT:    trap71# CHECK-EMPTY:72# CHECK-NEXT:  00000000000[[NOT_DEFINED]] <__plt_not_defined>:73