1# REQUIRES: ppc 2 3# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o 4# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \ 5# RUN: -z separate-code %t.o -o %t 6# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s 7# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \ 8# RUN: -z separate-code %t.o -o %t 9# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s 10# RUN: ld.lld --defsym callee=0xE010014 --defsym tail_callee=0xE010024 \ 11# RUN: -z separate-code %t.o -o %t 12# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=NEGOFFSET %s 13# RUN: ld.lld --defsym callee=0x12010018 --defsym tail_callee=0x12010028 \ 14# RUN: -z separate-code %t.o -o %t 15# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=THUNK %s 16# RUN: llvm-readelf --sections %t | FileCheck --check-prefix=BRANCHLT %s 17# RUN: not ld.lld --defsym callee=0x1001002D --defsym tail_callee=0x1001002F \ 18# RUN: -z separate-code %t.o -o %t 2>&1 | FileCheck --check-prefix=MISSALIGNED %s 19 20# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o 21# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \ 22# RUN: -z separate-code %t.o -o %t 23# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s 24# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \ 25# RUN: -z separate-code %t.o -o %t 26# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s 27# RUN: ld.lld --defsym callee=0xE010014 --defsym tail_callee=0xE010024 \ 28# RUN: -z separate-code %t.o -o %t 29# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=NEGOFFSET %s 30# RUN: ld.lld --defsym callee=0x12010018 --defsym tail_callee=0x12010028 \ 31# RUN: -z separate-code %t.o -o %t 32# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=THUNK %s 33# RUN: llvm-readelf --sections %t | FileCheck --check-prefix=BRANCHLT %s 34# RUN: not ld.lld --defsym callee=0x1001002D --defsym tail_callee=0x1001002F \ 35# RUN: -z separate-code %t.o -o %t 2>&1 | FileCheck --check-prefix=MISSALIGNED %s 36 37# MISSALIGNED: ld.lld: error: {{.*}}.o:(.text+0x14): improper alignment for relocation R_PPC64_REL24: 0x19 is not aligned to 4 bytes 38# MISSALIGNED: ld.lld: error: {{.*}}.o:(.text+0x24): improper alignment for relocation R_PPC64_REL24: 0xB is not aligned to 4 bytes 39 40 .global test 41 .p2align 4 42 .type test,@function 43test: 44.Lgep: 45 addis 2, 12, .TOC.-.Lgep@ha 46 addi 2, 2, .TOC.-.Lgep@l 47.Llep: 48 .localentry test, .Llep-.Lgep 49 mflr 0 50 std 0, 16(1) 51 stdu 1, 32(1) 52 bl callee 53 addi 1, 1, 32 54 ld 0, 16(1) 55 mtlr 0 56 b tail_callee 57 58# Check that we are branching to the definitions, and not range-extending 59# thunks. 60# CHECK-LABEL: test 61# CHECK: 10010014: bl 0x12010010 62# CHECK: 10010024: b 0x12010020 63 64# NEGOFFSET-LABEL: test 65# NEGOFFSET: 10010014: bl 0xe010014 66# NEGOFFSET: 10010024: b 0xe010024 67 68# THUNK-LABEL: <test>: 69# THUNK: 10010014: bl 0x10010030 70# THUNK: 10010024: b 0x10010040 71 72# .branch_lt[0] 73# THUNK-LABEL: <__long_branch_callee>: 74# THUNK-NEXT: 10010030: addis 12, 2, 1 75# THUNK-NEXT: ld 12, -32760(12) 76# THUNK-NEXT: mtctr 12 77# THUNK-NEXT: bctr 78 79# .branch_lt[1] 80# THUNK-LABEL: <__long_branch_tail_callee>: 81# THUNK-NEXT: 10010040: addis 12, 2, 1 82# THUNK-NEXT: ld 12, -32752(12) 83# THUNK-NEXT: mtctr 12 84# THUNK-NEXT: bctr 85 86# The offset from the TOC to the .branch_lt section is (-1 << 16) - 32768. 87# Name Type Address Off Size 88# BRANCHLT: .got PROGBITS 0000000010020000 020000 000008 89# BRANCHLT: .branch_lt PROGBITS 0000000010030008 020008 000010 90# BRANCHLT-NOT: .plt 91