150
|
1 # REQUIRES: ppc
|
|
2 # RUN: echo 'SECTIONS { \
|
|
3 # RUN: .text_low 0x2000: { *(.text_low) } \
|
|
4 # RUN: .text_high 0x2002000 : { *(.text_high) } \
|
|
5 # RUN: }' > %t.script
|
|
6
|
|
7 # RUN: llvm-mc -filetype=obj -triple=ppc64le %s -o %t.o
|
|
8 # RUN: ld.lld -T %t.script %t.o -o %t
|
|
9 # RUN: llvm-readelf -S -r %t | FileCheck --check-prefix=SEC %s
|
|
10 # RUN: llvm-readelf -x .branch_lt %t | FileCheck --check-prefix=BRANCH-LE %s
|
|
11 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
|
173
|
12 # RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s
|
150
|
13
|
|
14 # RUN: llvm-mc -filetype=obj -triple=ppc64 %s -o %t.o
|
|
15 # RUN: ld.lld -T %t.script %t.o -o %t
|
|
16 # RUN: llvm-readelf -S -r %t | FileCheck --check-prefix=SEC %s
|
|
17 # RUN: llvm-readelf -x .branch_lt %t | FileCheck --check-prefix=BRANCH-BE %s
|
|
18 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
|
173
|
19 # RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s
|
150
|
20
|
|
21 # SEC: Name Type Address Off Size ES Flg Lk Inf Al
|
|
22 # SEC: .got PROGBITS 0000000002002028 2002028 000008 00 WA 0 0 8
|
|
23 # SEC: .branch_lt PROGBITS 0000000002002030 2002030 000018 00 WA 0 0 8
|
|
24
|
|
25 # SEC: There are no relocations in this file.
|
|
26
|
|
27 ## high@localentry (high+8), .text_high+16 and .text_low+8
|
|
28 # BRANCH-LE: 0x02002030 08200002 00000000 10200002 00000000
|
|
29 # BRANCH-LE-NEXT: 0x02002040 08200000 00000000
|
|
30 # BRANCH-BE: 0x02002030 00000000 02002008 00000000 02002010
|
|
31 # BRANCH-BE-NEXT: 0x02002040 00000000 00002008
|
|
32
|
173
|
33 # CHECK: <_start>:
|
|
34 # CHECK-NEXT: 2000: bl 0x2018
|
|
35 # CHECK-NEXT: bl 0x2018
|
|
36 # CHECK-NEXT: bl 0x2018
|
|
37 # CHECK-NEXT: bl 0x2002008
|
150
|
38
|
|
39 ## &.branch_lt[0] - .TOC. = .branch_lt - (.got+0x8000) = -32760
|
173
|
40 # CHECK: <__long_branch_high>:
|
150
|
41 # CHECK-NEXT: 2018: addis 12, 2, 0
|
|
42 # CHECK-NEXT: ld 12, -32760(12)
|
|
43 # CHECK-NEXT: mtctr 12
|
|
44 # CHECK-NEXT: bctr
|
|
45
|
|
46 ## &.branch_lt[1] - .TOC. = .branch_lt - (.got+0x8000) = -32752
|
173
|
47 # CHECK: <__long_branch_>:
|
150
|
48 # CHECK-NEXT: 2028: addis 12, 2, 0
|
|
49 # CHECK-NEXT: ld 12, -32752(12)
|
|
50 # CHECK-NEXT: mtctr 12
|
|
51 # CHECK-NEXT: bctr
|
|
52
|
|
53 .section .text_low, "ax", %progbits
|
|
54 .globl _start
|
|
55 _start:
|
|
56 bl high # Need a thunk
|
|
57 bl high # Need a thunk
|
|
58 bl high # Need a thunk
|
|
59 bl high
|
|
60 bl .text_high+16 # Need a thunk
|
|
61 blr
|
|
62
|
|
63 # CHECK: Disassembly of section .text_high:
|
|
64 # CHECK-EMPTY:
|
173
|
65 # CHECK-NEXT: <high>:
|
150
|
66 # CHECK-NEXT: 2002000: addis 2, 12, 1
|
|
67 # CHECK-NEXT: addi 2, 2, -32728
|
173
|
68 # CHECK-NEXT: bl 0x2008
|
|
69 # CHECK-NEXT: bl 0x2002014
|
|
70 # CHECK: <__long_branch_>:
|
150
|
71 # CHECK-NEXT: 2002014: addis 12, 2, 0
|
|
72 # CHECK-NEXT: ld 12, -32744(12)
|
|
73 # CHECK-NEXT: mtctr 12
|
|
74 # CHECK-NEXT: bctr
|
|
75
|
|
76 .section .text_high, "ax", %progbits
|
|
77 .globl high
|
|
78 high:
|
|
79 addis 2, 12, .TOC.-high@ha
|
|
80 addi 2, 2, .TOC.-high@l
|
|
81 .localentry high, 8
|
|
82 bl .text_low+8
|
|
83 bl .text_low+8 # Need a thunk
|
|
84 blr
|
173
|
85
|
|
86 # NM: d .TOC.
|
|
87 # NM-NEXT: t __long_branch_high
|
|
88 # NM-NEXT: t __long_branch_{{$}}
|
|
89 # NM-NEXT: t __long_branch_{{$}}
|
|
90 # NM-NEXT: T _start
|
|
91 # NM-NEXT: T high
|