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
9 # CHECK-LABEL: <_start>:
12 ## Perform toc-indirect to toc-relative relaxation even if there are unrelated instructions in between.
13 # CHECK-NEXT: addis 3, 2, -2
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
19 ld 3, .LC1@toc@l(3) # R_PPC64_TOC16_LO_DS
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
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.
36 # CHECK-NEXT: addi 3, 2, -32768
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
43 addis 4, 2, .LC0@toc@ha
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
60 .section .toc,"aw",@progbits
62 .tc AES_encrypt[TC], AES_encrypt
64 .tc AES_decrypt[TC], AES_decrypt
66 .tc BN_free[TC], BN_free