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
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
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
45 addis 2, 12, .TOC.-.Lgep@ha
46 addi 2, 2, .TOC.-.Lgep@l
48 .localentry test, .Llep-.Lgep
58 # Check that we are branching to the definitions, and not range-extending
61 # CHECK: 10010014: bl 0x12010010
62 # CHECK: 10010024: b 0x12010020
64 # NEGOFFSET-LABEL: test
65 # NEGOFFSET: 10010014: bl 0xe010014
66 # NEGOFFSET: 10010024: b 0xe010024
68 # THUNK-LABEL: <test>:
69 # THUNK: 10010014: bl 0x10010030
70 # THUNK: 10010024: b 0x10010050
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
80 # THUNK-LABEL: <__long_branch_tail_callee>:
81 # THUNK-NEXT: 10010050: addis 12, 2, 1
82 # THUNK-NEXT: ld 12, -32752(12)
83 # THUNK-NEXT: mtctr 12
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