1# REQUIRES: ppc 2# RUN: split-file %s %t 3 4# RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/asm -o %t.o 5# RUN: ld.lld -T %t/lts %t.o -o %t_le 6# RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_le | FileCheck %s 7# RUN: llvm-readelf -s %t_le | FileCheck %s --check-prefix=SYM 8 9# RUN: llvm-mc -filetype=obj -triple=powerpc64 %t/asm -o %t.o 10# RUN: ld.lld -T %t/lts %t.o -o %t_be 11# RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_be | FileCheck %s 12# RUN: llvm-readelf -s %t_be | FileCheck %s --check-prefix=SYM 13 14# SYM: Symbol table '.symtab' contains 9 entries: 15# SYM: 1: 0000000010010000 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 1 callee 16# SYM-NEXT: 2: 0000000020020008 0 NOTYPE LOCAL DEFAULT [<other: 0x60>] 3 caller 17# SYM-NEXT: 3: 0000000010020008 0 NOTYPE LOCAL DEFAULT 2 caller_close 18# SYM-NEXT: 4: 0000000520020008 0 NOTYPE LOCAL DEFAULT 4 caller_far 19# SYM-NEXT: 5: 0000000520028038 0 NOTYPE LOCAL HIDDEN 6 .TOC. 20# SYM-NEXT: 6: 0000000010020020 8 FUNC LOCAL DEFAULT 2 __toc_save_callee 21# SYM-NEXT: 7: 0000000020020020 20 FUNC LOCAL DEFAULT 3 __toc_save_callee 22# SYM-NEXT: 8: 0000000520020020 20 FUNC LOCAL DEFAULT 4 __toc_save_callee 23 24#--- lts 25PHDRS { 26 callee PT_LOAD FLAGS(0x1 | 0x4); 27 close PT_LOAD FLAGS(0x1 | 0x4); 28 caller PT_LOAD FLAGS(0x1 | 0x4); 29 far PT_LOAD FLAGS(0x1 | 0x4); 30} 31SECTIONS { 32 .text_callee 0x10010000 : { *(.text_callee) } :callee 33 .text_caller_close 0x10020000 : { *(.text_caller_close) } :close 34 .text_caller 0x20020000 : { *(.text_caller) } :caller 35 .text_caller_far 0x520020000 : { *(.text_caller_far) } :far 36} 37 38#--- asm 39# CHECK-LABEL: <callee>: 40# CHECK: blr 41.section .text_callee, "ax", %progbits 42callee: 43 .localentry callee, 1 44 blr 45 46# CHECK-LABEL: <caller_close>: 47# CHECK: bl 0x10020020 48# CHECK-NEXT: ld 2, 24(1) 49# CHECK-NEXT: blr 50# CHECK-LABEL: <__toc_save_callee>: 51# CHECK: std 2, 24(1) 52# CHECK-NEXT: b 0x10010000 53.section .text_caller_close, "ax", %progbits 54.Lfunc_toc1: 55 .quad .TOC.-.Lfunc_gep1 56caller_close: 57.Lfunc_gep1: 58 ld 2, .Lfunc_toc1-.Lfunc_gep1(12) 59 add 2, 2, 12 60.Lfunc_lep1: 61 .localentry caller, .Lfunc_lep1-.Lfunc_gep1 62 bl callee 63 nop 64 blr 65 66# CHECK-LABEL: <caller>: 67# CHECK: bl 0x20020020 68# CHECK-NEXT: ld 2, 24(1) 69# CHECK-NEXT: blr 70# CHECK-LABEL: <__toc_save_callee>: 71# CHECK: std 2, 24(1) 72# CHECK-NEXT: paddi 12, 0, -268501028, 1 73# CHECK-NEXT: mtctr 12 74# CHECK-NEXT: bctr 75.section .text_caller, "ax", %progbits 76.Lfunc_toc2: 77 .quad .TOC.-.Lfunc_gep2 78caller: 79.Lfunc_gep2: 80 ld 2, .Lfunc_toc2-.Lfunc_gep2(12) 81 add 2, 2, 12 82.Lfunc_lep2: 83 .localentry caller, .Lfunc_lep2-.Lfunc_gep2 84 bl callee 85 nop 86 blr 87 88# CHECK-LABEL: <caller_far>: 89# CHECK: ld 2, -8(12) 90# CHECK-NEXT: add 2, 2, 12 91# CHECK-NEXT: bl 0x520020020 92# CHECK-NEXT: ld 2, 24(1) 93# CHECK-NEXT: blr 94# CHECK-LABEL: <__toc_save_callee>: 95# CHECK: std 2, 24(1) 96# CHECK-NEXT: addis 12, 2, 0 97# CHECK-NEXT: ld 12, -32760(12) 98# CHECK-NEXT: mtctr 12 99# CHECK-NEXT: bctr 100.section .text_caller_far, "ax", %progbits 101.Lfunc_toc3: 102 .quad .TOC.-.Lfunc_gep3 103caller_far: 104.Lfunc_gep3: 105 ld 2, .Lfunc_toc3-.Lfunc_gep3(12) 106 add 2, 2, 12 107.Lfunc_lep3: 108 .localentry caller, .Lfunc_lep3-.Lfunc_gep3 109 bl callee 110 nop 111 blr 112