91 lines · plain
1# REQUIRES: ppc2 3# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o4# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \5# RUN: -z separate-code %t.o -o %t6# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s7# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \8# RUN: -z separate-code %t.o -o %t9# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s10# RUN: ld.lld --defsym callee=0xE010014 --defsym tail_callee=0xE010024 \11# RUN: -z separate-code %t.o -o %t12# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=NEGOFFSET %s13# RUN: ld.lld --defsym callee=0x12010018 --defsym tail_callee=0x12010028 \14# RUN: -z separate-code %t.o -o %t15# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=THUNK %s16# RUN: llvm-readelf --sections %t | FileCheck --check-prefix=BRANCHLT %s17# 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 %s19 20# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o21# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \22# RUN: -z separate-code %t.o -o %t23# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s24# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \25# RUN: -z separate-code %t.o -o %t26# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s27# RUN: ld.lld --defsym callee=0xE010014 --defsym tail_callee=0xE010024 \28# RUN: -z separate-code %t.o -o %t29# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=NEGOFFSET %s30# RUN: ld.lld --defsym callee=0x12010018 --defsym tail_callee=0x12010028 \31# RUN: -z separate-code %t.o -o %t32# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=THUNK %s33# RUN: llvm-readelf --sections %t | FileCheck --check-prefix=BRANCHLT %s34# 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 %s36 37# MISSALIGNED: ld.lld: error: {{.*}}.o:(.text+0x14): improper alignment for relocation R_PPC64_REL24: 0x19 is not aligned to 4 bytes38# MISSALIGNED: ld.lld: error: {{.*}}.o:(.text+0x24): improper alignment for relocation R_PPC64_REL24: 0xB is not aligned to 4 bytes39 40 .global test41 .p2align 442 .type test,@function43test:44.Lgep:45 addis 2, 12, .TOC.-.Lgep@ha46 addi 2, 2, .TOC.-.Lgep@l47.Llep:48 .localentry test, .Llep-.Lgep49 mflr 050 std 0, 16(1)51 stdu 1, 32(1)52 bl callee53 addi 1, 1, 3254 ld 0, 16(1)55 mtlr 056 b tail_callee57 58# Check that we are branching to the definitions, and not range-extending59# thunks.60# CHECK-LABEL: test61# CHECK: 10010014: bl 0x1201001062# CHECK: 10010024: b 0x1201002063 64# NEGOFFSET-LABEL: test65# NEGOFFSET: 10010014: bl 0xe01001466# NEGOFFSET: 10010024: b 0xe01002467 68# THUNK-LABEL: <test>:69# THUNK: 10010014: bl 0x1001003070# THUNK: 10010024: b 0x1001005071 72# .branch_lt[0]73# THUNK-LABEL: <__long_branch_callee>:74# THUNK-NEXT: 10010030: addis 12, 2, 175# THUNK-NEXT: ld 12, -32760(12)76# THUNK-NEXT: mtctr 1277# THUNK-NEXT: bctr78 79# .branch_lt[1]80# THUNK-LABEL: <__long_branch_tail_callee>:81# THUNK-NEXT: 10010050: addis 12, 2, 182# THUNK-NEXT: ld 12, -32752(12)83# THUNK-NEXT: mtctr 1284# THUNK-NEXT: bctr85 86# The offset from the TOC to the .branch_lt section is (-1 << 16) - 32768.87# Name Type Address Off Size88# BRANCHLT: .got PROGBITS 0000000010020000 020000 00000889# BRANCHLT: .branch_lt PROGBITS 0000000010030008 020008 00001090# BRANCHLT-NOT: .plt91