173
|
1 # REQUIRES: ppc
|
|
2 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
|
|
3 # RUN: echo 'addis 5, 2, .LC0@toc@ha; ld 5, .LC0@toc@l(5); foo: \
|
|
4 # RUN: .section .toc,"aw",@progbits; .LC0: .tc foo[TC], foo' \
|
|
5 # RUN: | llvm-mc -filetype=obj -triple=powerpc64le - -o %t1.o
|
|
6 # RUN: ld.lld %t.o %t1.o -o %t
|
|
7 # RUN: llvm-objdump -d %t | FileCheck %s
|
|
8
|
|
9 # CHECK-LABEL: <_start>:
|
|
10 .globl _start
|
|
11 _start:
|
|
12 ## Perform toc-indirect to toc-relative relaxation even if there are unrelated instructions in between.
|
|
13 # CHECK-NEXT: addis 3, 2, -2
|
|
14 # CHECK-NEXT: li 9, 0
|
|
15 # CHECK-NEXT: addi 3, 3, 32752
|
|
16 # CHECK-NEXT: lwa 3, 0(3)
|
|
17 addis 3, 2, .LC1@toc@ha # R_PPC64_TOC16_HA
|
|
18 li 9, 0
|
|
19 ld 3, .LC1@toc@l(3) # R_PPC64_TOC16_LO_DS
|
|
20 lwa 3, 0(3)
|
|
21
|
|
22 ## R_PPC64_TOC16_HA and R_PPC64_TOC16_LO_DS can interleave.
|
|
23 # CHECK-NEXT: addis 3, 2, -2
|
|
24 # CHECK-NEXT: addis 4, 2, -2
|
|
25 # CHECK-NEXT: addi 3, 3, 32752
|
|
26 # CHECK-NEXT: addi 4, 4, 32756
|
|
27 addis 3, 2, .LC1@toc@ha
|
|
28 addis 4, 2, .LC2@toc@ha
|
|
29 ld 3, .LC1@toc@l(3)
|
|
30 ld 4, .LC2@toc@l(4)
|
|
31
|
|
32 ## We choose to be conservative: the presence of R_PPC64_TOC16_LO
|
|
33 ## suppresses relaxation for the symbol.
|
|
34 ## R_PPC64_TOC16_HA and R_PPC64_TOC16_LO_DS pairs are not relaxed as well.
|
|
35 # CHECK-NEXT: nop
|
|
36 # CHECK-NEXT: addi 3, 2, -32768
|
|
37 # CHECK-NEXT: li 9, 0
|
|
38 # CHECK-NEXT: nop
|
|
39 # CHECK-NEXT: ld 4, -32768(2)
|
|
40 addis 3, 2, .LC0@toc@ha # R_PPC64_TOC16_HA
|
|
41 addi 3, 3, .LC0@toc@l # R_PPC64_TOC16_LO
|
|
42 li 9, 0
|
|
43 addis 4, 2, .LC0@toc@ha
|
|
44 ld 4, .LC0@toc@l(4)
|
|
45
|
|
46 # CHECK-COUNT-3: blr
|
|
47 AES_encrypt:
|
|
48 blr
|
|
49 AES_decrypt:
|
|
50 blr
|
|
51 BN_free:
|
|
52 blr
|
|
53
|
|
54 ## %t1.o has relaxable relocation pairs referencing its .toc which is different
|
|
55 ## from %t.o(.toc). The suppression in %t.o does not affect %t1.o even if
|
|
56 ## the relocation addends are the same.
|
|
57 # CHECK-NEXT: addis 5, 2, -1
|
|
58 # CHECK-NEXT: addi 5, 5, -32768
|
|
59
|
|
60 .section .toc,"aw",@progbits
|
|
61 .LC0:
|
|
62 .tc AES_encrypt[TC], AES_encrypt
|
|
63 .LC1:
|
|
64 .tc AES_decrypt[TC], AES_decrypt
|
|
65 .LC2:
|
|
66 .tc BN_free[TC], BN_free
|